source: trunk/orbital/orbital.cpp @ 1249

Last change on this file since 1249 was 1249, checked in by sam, 8 years ago

orbital: the mesh builder is now almost operational! vertex colour doesn't
seem to work yet.

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.Flush();
35
36    m_angle = 0;
37
38    m_ready = false;
39}
40
41void Orbital::TickGame(float deltams)
42{
43    WorldEntity::TickGame(deltams);
44
45    m_angle += deltams / 1000.0f * 90.0f;
46
47    mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0))
48              * mat4::rotate(m_angle * 0.25, vec3(0, 0, 1));
49    mat4 model = mat4::translate(vec3(0, 0, -4.5));
50    mat4 view = mat4::lookat(vec3(0, 2, 0), vec3(0, 0, -4), vec3(0, 1, 0));
51    mat4 proj = mat4::perspective(45.0f, 640.0f, 480.0f, 0.1f, 10.0f);
52
53    m_matrix = proj * view * model * anim;
54}
55
56void Orbital::TickDraw(float deltams)
57{
58    WorldEntity::TickDraw(deltams);
59
60    if (!m_ready)
61    {
62        m.MeshConvert();
63
64        /* FIXME: this object never cleans up */
65        m_ready = true;
66    }
67
68    m.Render(m_matrix);
69}
70
71Orbital::~Orbital()
72{
73    ;
74}
75
76int main(int argc, char **argv)
77{
78    Application app("Orbital", ivec2(800, 600), 60.0f);
79
80#if defined _MSC_VER && !defined _XBOX
81    _chdir("..");
82#elif defined _WIN32 && !defined _XBOX
83    _chdir("../..");
84#endif
85
86    new DebugFps(5, 5);
87    new Orbital();
88    app.ShowPointer(false);
89
90    app.Run();
91
92    return EXIT_SUCCESS;
93}
94
Note: See TracBrowser for help on using the repository browser.