5 static void cleanup(void);
7 static void display(void *cls);
8 static void reshape(int x, int y, void *cls);
9 static void keyb(int key, int pressed, void *cls);
10 static void mbutton(int bn, int pressed, int x, int y, void *cls);
11 static void mmove(int x, int y, void *cls);
16 static const float vdata[] = {
17 -0.25f, -0.25f, 0.25f, 0.25f, -0.25f, 0.25f, 0.25f, -0.25f, -0.25f, -0.25f, -0.25f, -0.25f,
18 -0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, -0.25f, -0.25f, 0.25f, -0.25f
20 static const float vcolors[] = {
21 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0,
22 0, 1, 1, 1, 0, 1, 1, 0.5, 0, 0.5, 0.5, 0.5
25 static const unsigned int idata[] = {
36 static nex_buffer *vbuf, *ibuf, *cbuf;
37 static nex_geometry *geom;
38 static nex_sdrprog *sdrprog;
42 nex_gfxapi_opengl(3, 3, NEX_OPENGL_DEBUG);
43 if(nex_initgfx(1280, 800, 0) == -1) {
47 nex_cbdisplay(display, 0);
48 nex_cbreshape(reshape, 0);
50 nex_cbmousebn(mbutton, 0);
51 nex_cbmousemove(mmove, 0);
57 while(nex_evloop_wait() && !quit);
67 nex_clearcolor(0.1, 0.12, 0.2);
69 vbuf = nex_alloc_buffer(sizeof vdata, vdata);
70 cbuf = nex_alloc_buffer(sizeof vcolors, vcolors);
71 ibuf = nex_alloc_buffer(sizeof idata, idata);
72 geom = nex_alloc_geometry();
73 nex_geom_vbuffer(geom, 0, vbuf, 3 * sizeof(float));
74 nex_geom_vbuffer(geom, 1, cbuf, 3 * sizeof(float));
75 nex_geom_vattr(geom, ATTR_POS, NEX_VEC3, 0, 0);
76 nex_geom_vattr(geom, ATTR_COL, NEX_COL3, 1, 0);
77 nex_geom_ibuffer(geom, ibuf);
79 if(!(sdrprog = nex_load_sdrprog("test.v.spv", "test.p.spv"))) {
85 static void cleanup(void)
87 nex_free_buffer(vbuf);
88 nex_free_buffer(cbuf);
89 nex_free_buffer(ibuf);
90 nex_free_geometry(geom);
91 nex_free_sdrprog(sdrprog);
94 static void display(void *cls)
98 nex_bind_sdrprog(sdrprog);
99 nex_draw_geometry(geom, NEX_TRIANGLES, 0);
104 static void reshape(int x, int y, void *cls)
106 nex_viewport(0, 0, x, y);
109 static void keyb(int key, int pressed, void *cls)
120 static void mbutton(int bn, int pressed, int x, int y, void *cls)
124 static void mmove(int x, int y, void *cls)