9 static void gen_default_textures(void);
11 static unsigned int sdr_foo;
12 static unsigned int tex_logo;
16 if(init_opengl() == -1) {
19 if(init_assman() == -1) {
23 /* global "debug" shader which just visualizes normals */
24 if(!(sdr_dbg = get_sdrprog("sdr/dbg.v.glsl", "sdr/dbg.p.glsl"))) {
27 cmesh_bind_sdrloc(sdr_dbg);
29 gen_default_textures();
31 if(!(sdr_foo = get_sdrprog("sdr/foo.v.glsl", "sdr/foo.p.glsl"))) {
34 if(!(tex_logo = get_tex2d("data/ml_logo_old.png"))) {
37 glBindTexture(GL_TEXTURE_2D, tex_logo);
38 glUseProgram(sdr_foo);
52 glEnable(GL_DEPTH_TEST);
53 glEnable(GL_CULL_FACE);
57 void demo_cleanup(void)
61 glDeleteTextures(1, &deftex_white);
62 glDeleteTextures(1, &deftex_black);
63 glDeleteTextures(1, &deftex_normal);
66 void demo_display(void)
68 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
70 glBindTexture(GL_TEXTURE_2D, tex_logo);
71 glUseProgram(sdr_foo);
85 void demo_reshape(int x, int y)
87 glViewport(0, 0, x, y);
90 win_aspect = (float)x / (float)y;
93 void demo_keyboard(int key, int pressed)
97 void demo_mouse(int bn, int pressed, int x, int y)
101 void demo_motion(int x, int y)
105 static void gen_default_textures(void)
107 static const uint32_t col[] = {0xff000000, 0xffffffff, 0xffff7f7f};
111 glGenTextures(3, tex);
113 glBindTexture(GL_TEXTURE_2D, tex[i]);
114 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
115 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
116 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, col + i);
119 deftex_black = tex[0];
120 deftex_white = tex[1];
121 deftex_normal = tex[2];