Rev 2 | Rev 4 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | tom | 1 | #include "SDL/SDL.h" |
2 | #include "SDL/SDL_opengl.h" |
||
3 | |||
1 | tom | 4 | #include "sssnakesss.hpp" |
5 | |||
6 | SSSNAKESSS::SSSNAKESSS() |
||
7 | { |
||
2 | tom | 8 | running = false; |
1 | tom | 9 | } |
10 | |||
11 | SSSNAKESSS::~SSSNAKESSS() |
||
12 | { |
||
13 | |||
14 | } |
||
15 | |||
16 | bool SSSNAKESSS::init() |
||
17 | { |
||
18 | if (!initSDL()) |
||
19 | { |
||
20 | return false; |
||
21 | } |
||
22 | |||
23 | if (!initOpenGL()) |
||
24 | { |
||
25 | return false; |
||
26 | } |
||
27 | |||
28 | initData(); |
||
29 | |||
30 | return true; |
||
31 | } |
||
32 | |||
33 | bool SSSNAKESSS::initSDL() |
||
34 | { |
||
3 | tom | 35 | if (SDL_Init(SDL_INIT_EVERYTHING) != 0) |
36 | { |
||
37 | return false; |
||
38 | } |
||
39 | |||
40 | SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
||
41 | |||
42 | screen = SDL_SetVideoMode(640, 480, 16, SDL_OPENGL); |
||
43 | if (!screen) |
||
44 | { |
||
45 | return false; |
||
46 | } |
||
47 | |||
1 | tom | 48 | return true; |
49 | } |
||
50 | |||
51 | bool SSSNAKESSS::initOpenGL() |
||
52 | { |
||
3 | tom | 53 | glEnable(GL_TEXTURE_2D); |
54 | |||
55 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
||
56 | |||
57 | glViewport(0, 0, 640, 480); |
||
58 | |||
59 | glClear(GL_COLOR_BUFFER_BIT); |
||
60 | |||
61 | glMatrixMode(GL_PROJECTION); |
||
62 | glLoadIdentity(); |
||
63 | |||
64 | glOrtho(0.0f, 640, 480, 0.0f, -1.0f, 1.0f); |
||
65 | |||
66 | glMatrixMode(GL_MODELVIEW); |
||
67 | glLoadIdentity(); |
||
68 | |||
1 | tom | 69 | return true; |
70 | } |
||
71 | |||
72 | void SSSNAKESSS::initData() |
||
73 | { |
||
74 | } |
||
75 | |||
76 | void SSSNAKESSS::run() |
||
77 | { |
||
2 | tom | 78 | running = true; |
79 | |||
80 | while (running) |
||
81 | { |
||
82 | checkEvents(); |
||
83 | update(); |
||
84 | draw(); |
||
85 | } |
||
1 | tom | 86 | } |
87 | |||
2 | tom | 88 | void SSSNAKESSS::checkEvents() |
89 | { |
||
3 | tom | 90 | SDL_Event event; |
91 | |||
92 | while (SDL_PollEvent(&event)) |
||
93 | { |
||
94 | switch (event.type) |
||
95 | { |
||
96 | case SDL_QUIT: |
||
97 | running = false; |
||
98 | break; |
||
99 | } |
||
100 | } |
||
2 | tom | 101 | } |
102 | |||
103 | void SSSNAKESSS::update() |
||
104 | { |
||
105 | } |
||
106 | |||
107 | void SSSNAKESSS::draw() |
||
108 | { |
||
109 | } |
||
110 | |||
1 | tom | 111 | void SSSNAKESSS::end() |
112 | { |
||
113 | } |