source: trunk/orbital/orbital.cpp @ 1254

Last change on this file since 1254 was 1254, checked in by sam, 10 years ago

orbital: use standard OpenGL winding order even when using Direct3D.

File size: 1.6 KB
Line 
1//
2// Orbital
3//
4// Copyright: (c) 2012 Various People
5//
6
7#if defined HAVE_CONFIG_H
8#   include "config.h"
9#endif
10
11#if defined _WIN32
12#   include <direct.h>
13#endif
14
15#if USE_SDL && defined __APPLE__
16#   include <SDL_main.h>
17#endif
18
19#include "core.h"
20#include "loldebug.h"
21
22using namespace std;
23using namespace lol;
24
25#include "orbital.h"
26#include "mesh.h"
27
28Orbital::Orbital()
29{
30    m.SetCurColor(vec4(1.0, 1.0, 0.0, 1.0));
31    m.AppendBox(vec3(1.0, 1.0, 1.0));
32    m.Duplicate();
33    m.RotateX(45);
34    m.Translate(vec3(0.5, 0.0, 0.0));
35    m.Flush();
36
37    m_angle = 0;
38
39    m_ready = false;
40}
41
42void Orbital::TickGame(float deltams)
43{
44    WorldEntity::TickGame(deltams);
45
46    m_angle += deltams / 1000.0f * 90.0f;
47
48    mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0))
49              * mat4::rotate(m_angle * 0.25, vec3(0, 0, 1));
50    mat4 model = mat4::translate(vec3(0, 0, -4.5));
51    mat4 view = mat4::lookat(vec3(0, 2, 0), vec3(0, 0, -4), vec3(0, 1, 0));
52    mat4 proj = mat4::perspective(45.0f, 640.0f, 480.0f, 0.1f, 10.0f);
53
54    m_matrix = proj * view * model * anim;
55}
56
57void Orbital::TickDraw(float deltams)
58{
59    WorldEntity::TickDraw(deltams);
60
61    if (!m_ready)
62    {
63        m.MeshConvert();
64
65        /* FIXME: this object never cleans up */
66        m_ready = true;
67    }
68
69    m.Render(m_matrix);
70}
71
72Orbital::~Orbital()
73{
74    ;
75}
76
77int main(int argc, char **argv)
78{
79    Application app("Orbital", ivec2(800, 600), 60.0f);
80
81#if defined _MSC_VER && !defined _XBOX
82    _chdir("..");
83#elif defined _WIN32 && !defined _XBOX
84    _chdir("../..");
85#endif
86
87    new DebugFps(5, 5);
88    new Orbital();
89    app.ShowPointer(false);
90
91    app.Run();
92
93    return EXIT_SUCCESS;
94}
95
Note: See TracBrowser for help on using the repository browser.