Jump to content
  • Advertisement
Sign in to follow this  
wforl

vertex arrays

This topic is 4017 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can anyone tell me what im doing wrong with the following code, i dont get any errors or anything, it builds fine, but i get nothing on the screen.

#include <GL/glut.h>
#include <stdlib.h>

void display(void)
{

   glClear (GL_COLOR_BUFFER_BIT);
   glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

   glEnableClientState (GL_COLOR_ARRAY);
   glEnableClientState (GL_VERTEX_ARRAY);


   static GLint verts[] = {0.25, 0.25, 0.0,
                          0.75, 0.25, 0.0 ,
                          0.75, 0.75, 0.0,
                          0.25, 0.75, 0.0,
                          9.0, 13.3, -10.4,
                          10.0, 14.4, -10.4};

	static GLfloat colors[] = {1.0, 0.2, 0.2,
                          0.2, 0.2, 1.0,
                          0.8, 1.0, 0.2,
                          0.75, 0.75, 0.75,
                          0.35, 0.35, 0.35,
                          0.5, 0.5, 0.5};



glColorPointer (3, GL_FLOAT, 0, colors);
glVertexPointer (3, GL_FLOAT, 0, verts);




glBegin(GL_QUADS);
glArrayElement (0);
glArrayElement (1);
glArrayElement (2);
glArrayElement (3);
glEnd();

   glFlush ();
}

void init (void) 
{
/* select clearing color 	*/
   glClearColor (0.0, 0.0, 0.0, 0.0);

/* initialize viewing values  */
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);

  

}

int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
   glutInitWindowSize (250, 250); 
   glutInitWindowPosition (100, 100);
   glutCreateWindow ("hello");
   init ();
   glutDisplayFunc(display); 
   glutMainLoop();
   return 0;   /* ANSI C requires main to return int. */
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!