intravenous

diff src/cockpit.cc @ 3:94d4c60af435

some progress
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 22 Apr 2012 03:35:18 +0300
parents
children c6a6a64df6de
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/cockpit.cc	Sun Apr 22 03:35:18 2012 +0300
     1.3 @@ -0,0 +1,52 @@
     1.4 +#include "opengl.h"
     1.5 +#include "cockpit.h"
     1.6 +#include "tex.h"
     1.7 +
     1.8 +static unsigned int tex;
     1.9 +
    1.10 +bool cockpit_init()
    1.11 +{
    1.12 +	if(!(tex = load_texture("data/cockpit.png"))) {
    1.13 +		return false;
    1.14 +	}
    1.15 +	return true;
    1.16 +}
    1.17 +
    1.18 +void cockpit_destroy()
    1.19 +{
    1.20 +	free_texture(tex);
    1.21 +}
    1.22 +
    1.23 +void cockpit_draw()
    1.24 +{
    1.25 +	glPushAttrib(GL_ENABLE_BIT);
    1.26 +	glDisable(GL_LIGHTING);
    1.27 +
    1.28 +	glEnable(GL_BLEND);
    1.29 +	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    1.30 +
    1.31 +	bind_texture(tex);
    1.32 +
    1.33 +	glMatrixMode(GL_MODELVIEW);
    1.34 +	glPushMatrix();
    1.35 +	glLoadIdentity();
    1.36 +	glMatrixMode(GL_PROJECTION);
    1.37 +	glPushMatrix();
    1.38 +	glLoadIdentity();
    1.39 +
    1.40 +	glBegin(GL_QUADS);
    1.41 +	glColor3f(1, 1, 1);
    1.42 +	glTexCoord2f(0, 1); glVertex2f(-1, -1);
    1.43 +	glTexCoord2f(1, 1); glVertex2f(1, -1);
    1.44 +	glTexCoord2f(1, 0); glVertex2f(1, 1);
    1.45 +	glTexCoord2f(0, 0); glVertex2f(-1, 1);
    1.46 +	glEnd();
    1.47 +
    1.48 +	glPopMatrix();
    1.49 +	glMatrixMode(GL_MODELVIEW);
    1.50 +	glPopMatrix();
    1.51 +
    1.52 +	bind_texture(0);
    1.53 +
    1.54 +	glPopAttrib();
    1.55 +}