intravenous

view src/cockpit.cc @ 4:c6a6a64df6de

normalmap
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 22 Apr 2012 05:20:03 +0300
parents 94d4c60af435
children
line source
1 #include "opengl.h"
2 #include "cockpit.h"
3 #include "tex.h"
5 #define TEX_ASPECT (16.0 / 9.0)
6 extern int win_xsz, win_ysz;
8 static unsigned int tex;
10 bool cockpit_init()
11 {
12 if(!(tex = load_texture("data/cockpit.png"))) {
13 return false;
14 }
15 return true;
16 }
18 void cockpit_destroy()
19 {
20 free_texture(tex);
21 }
23 void cockpit_draw()
24 {
25 float view_aspect = (float)win_xsz / (float)win_ysz;
26 float aspect = TEX_ASPECT / view_aspect;
28 glPushAttrib(GL_ENABLE_BIT);
29 glDisable(GL_LIGHTING);
31 glEnable(GL_BLEND);
32 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
34 bind_texture(tex);
36 glMatrixMode(GL_MODELVIEW);
37 glPushMatrix();
38 glLoadIdentity();
39 glMatrixMode(GL_PROJECTION);
40 glPushMatrix();
41 glLoadIdentity();
43 glBegin(GL_QUADS);
44 glColor3f(1, 1, 1);
45 glTexCoord2f(0, 1); glVertex2f(-aspect, -1);
46 glTexCoord2f(1, 1); glVertex2f(aspect, -1);
47 glTexCoord2f(1, 0); glVertex2f(aspect, 1);
48 glTexCoord2f(0, 0); glVertex2f(-aspect, 1);
49 glEnd();
51 glPopMatrix();
52 glMatrixMode(GL_MODELVIEW);
53 glPopMatrix();
55 bind_texture(0);
57 glPopAttrib();
58 }