source: trunk/games/demo-jnat/demo-jnat.cpp @ 1715

Last change on this file since 1715 was 1715, checked in by Jnat, 9 years ago
File size: 2.0 KB
Line 
1// LOL
2
3#if defined HAVE_CONFIG_H
4#   include "config.h"
5#endif
6
7#if defined _WIN32
8#   include <direct.h>
9#endif
10
11#if defined _XBOX
12#   define _USE_MATH_DEFINES /* for M_PI */
13#   include <xtl.h>
14#   undef near /* Fuck Microsoft */
15#   undef far /* Fuck Microsoft again */
16#elif defined _WIN32
17#   define _USE_MATH_DEFINES /* for M_PI */
18#   define WIN32_LEAN_AND_MEAN
19#   include <windows.h>
20#   undef near /* Fuck Microsoft */
21#   undef far /* Fuck Microsoft again */
22#else
23#   include <cmath>
24#endif
25
26#include "core.h"
27
28using namespace std;
29using namespace lol;
30
31
32#include "demo-jnat.h"
33
34
35
36DemoJnat::DemoJnat()
37{
38    m_angle = 0;
39               
40        // set color
41    m_mesh.Compile("sc#221 scb#1c1");
42        m_mesh.AppendFlatChamfBox(vec3(1000, 10, 500), 1.f);
43
44        m_player = new Player();
45        Ticker::Ref(m_player);
46
47    /* Center everything -- is it needed? */
48    //m_mesh.Compile("tx4 tz4");
49
50    m_camera = new Camera(vec3(0.f, 600.f, 0.f),
51                            vec3(0.f, 0.f, 0.f),
52                            vec3(0, 1, 0));
53    m_camera->SetPerspective(70.f, 960.f, 600.f, .1f, 1000.f);
54    m_camera->SetTarget(vec3(0.f, 0.f, 0.f));
55    m_camera->SetPosition(vec3(0.f, 80.f, -100.f));
56    Ticker::Ref(m_camera);
57
58    m_ready = false;
59}
60
61DemoJnat::~DemoJnat(){
62        Ticker::Unref(m_player);
63}
64
65void DemoJnat::TickGame(float seconds)
66{
67    WorldEntity::TickGame(seconds);
68
69
70        // exit
71        if (Input::GetButtonState(27 /*SDLK_ESCAPE*/))
72                Ticker::Shutdown();
73
74        m_angle = 0;
75
76    mat4 anim = mat4::rotate(m_angle, vec3(0, 1, 0));
77    mat4 model = mat4::translate(vec3(0, 0, 0));
78
79    m_matrix = model * anim;
80}
81
82void DemoJnat::TickDraw(float seconds)
83{
84    WorldEntity::TickDraw(seconds);
85
86    if (!m_ready)
87    {
88        m_mesh.MeshConvert();
89        m_ready = true;
90    }
91
92    Video::SetClearColor(vec4(0.0f, 0.0f, 0.0f, 1.0f));
93
94    m_mesh.Render(m_matrix);
95}
96
97
98int main(int argc, char **argv)
99{
100    Application app("Jnat Demo", ivec2(960, 600), 60.0f);
101    new DemoJnat();
102    app.Run();
103
104    return EXIT_SUCCESS;
105}
106
Note: See TracBrowser for help on using the repository browser.