starting a new 3d engine
[nexus3d] / test.c
1 #include <stdio.h>
2 #include "nexus3d.h"
3
4
5 static void display(void *cls);
6 static void reshape(int x, int y, void *cls);
7 static void keyb(int key, int pressed, void *cls);
8 static void mbutton(int bn, int pressed, int x, int y, void *cls);
9 static void mmove(int x, int y, void *cls);
10
11
12 static int quit;
13
14 int main(void)
15 {
16         nex_gfxapi_opengl(3, 3, NEX_OPENGL_DEBUG);
17         if(nex_initgfx(1280, 800, 0) == -1) {
18                 return 1;
19         }
20
21         nex_cbdisplay(display, 0);
22         nex_cbreshape(reshape, 0);
23         nex_cbkey(keyb, 0);
24         nex_cbmousebn(mbutton, 0);
25         nex_cbmousemove(mmove, 0);
26
27         while(nex_evloop_wait() && !quit);
28
29         nex_closegfx();
30         return 0;
31 }
32
33
34 static void display(void *cls)
35 {
36         nex_clear();
37
38         nex_swap_buffers();
39 }
40
41 static void reshape(int x, int y, void *cls)
42 {
43         nex_viewport(0, 0, x, y);
44 }
45
46 static void keyb(int key, int pressed, void *cls)
47 {
48         if(!pressed) return;
49
50         switch(key) {
51         case 27:
52                 quit = 1;
53                 break;
54         }
55 }
56
57 static void mbutton(int bn, int pressed, int x, int y, void *cls)
58 {
59 }
60
61 static void mmove(int x, int y, void *cls)
62 {
63 }