#define GL_GLEXT_PROTOTYPES #include #include #include #include // This includes the necessary X headers^M #include #include #define GL_GLEXT_PROTOTYPES #include #include #include #include struct Vertex { int x; int y; int tex_x; int tex_y; } ; void draw (void) { struct Vertex vertices[4]; GLuint vbo; GLuint g_textureID; glGenTextures( 1, &g_textureID ); glBindTexture( GL_TEXTURE_2D, g_textureID ); glEnable(GL_VERTEX_ARRAY); glEnable(GL_TEXTURE_COORD_ARRAY); glEnable(GL_TEXTURE_2D);//tex-.target; glGenBuffersARB(1, &vbo); glBindBufferARB(GL_ARRAY_BUFFER, vbo); vertices[0].x = 10; vertices[0].y = 10; vertices[0].tex_x = 0.0f; vertices[0].tex_y = 0.0f; vertices[1].x = 12; vertices[1].y = 12; vertices[1].tex_x = 12; vertices[1].tex_y = 0.0f; vertices[2].x = 11; vertices[2].y = 11; vertices[2].tex_x = 11; vertices[2].tex_y = 11; vertices[3].x = 11; vertices[3].y = 11; vertices[3].tex_x = 0.0f; vertices[3].tex_y = 11; glBufferDataARB(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW_ARB); // glBindBufferARB(GL_ARRAY_BUFFER, quad->vbo); glBindTexture(GL_TEXTURE_2D, g_textureID); glVertexPointer(2, GL_FLOAT, sizeof(Vertex), (const GLvoid *) 0); glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), (const GLvoid *) (2 * sizeof(GLfloat))); glDrawArrays(GL_QUADS, 0, 4); glFlush (); /* glBegin (GL_QUADS); glVertex2f (0, 0); glEnd (); glFlush ();*/ } void reshape (int width, int height) { glViewport (0, 0, width, height); glMatrixMode (GL_PROJECTION); glLoadIdentity (); glOrtho (0, width, 0, height, 0, 1); glMatrixMode (GL_MODELVIEW); glLoadIdentity (); glutPostRedisplay (); } void keyboard (unsigned char key, int x, int y) { exit (0); } int main (int argc, char *argv[]) { glutInitWindowSize (640, 480); glutInit (&argc, argv); glutInitDisplayMode (GLUT_RGB); glutCreateWindow (argv[0]); glutReshapeFunc (reshape); glutDisplayFunc (draw); glutKeyboardFunc (keyboard); glutMainLoop (); exit (0); }