#include <windows.h>
#include <stdio.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glut.h>
#include <gl\glaux.h>
GLuint texture_id;
int LoadTextures()
{
AUX_RGBImageRec *TI;
if (TI=auxDIBImageLoad("test.bmp"))
{
glGenTextures(1, &texture_id);
glBindTexture(GL_TEXTURE_2D, texture_id);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TI->sizeX, TI->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TI->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
}
void init(void)
{
glEnable ( GL_TEXTURE_2D );
LoadTextures();
}
void reshape( int w, int h )
{
glViewport ( 0, 0, w, h );
glMatrixMode ( GL_PROJECTION );
glLoadIdentity ( );
gluPerspective ( 80, ( float ) w / ( float ) h, 1.0, 1000.0 );
glMatrixMode ( GL_MODELVIEW );
glLoadIdentity ( );
}
void display( void )
{
init();
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity ( );
glPushMatrix();
glTranslatef ( 0.0, 0.0, -5.0 );
glBindTexture ( GL_TEXTURE_2D, texture_id );
glBegin ( GL_QUADS );
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glEnd();
glPopMatrix();
glutSwapBuffers();
}
void keyboard ( unsigned char key, int x, int y )
{
if (key == 27) exit(0);
}
int main ( int argc, char** argv )
{
glutInit( &argc, argv );
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE );
glutInitWindowSize (500, 500 );
glutCreateWindow ( "" );
glutFullScreen();
glutDisplayFunc( display );
glutReshapeFunc( reshape );
glutKeyboardFunc( keyboard );
glutIdleFunc( display );
glutMainLoop();
}
|