Jump to content
  • Advertisement
Sign in to follow this  
broady

Help with Icosahedron - Ogl

This topic is 3663 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

Hey there, i need some help with a very simple code. That is:
#include <GL/gl.h>
#include <GL/glut.h>



#define X .525731112119133606 
#define Z .850650808352039932


void Init(void )
{
	glClearColor (0.0, 0.0, 0.0, 0.0);
	glShadeModel (GL_FLAT);
}

void display(void)
{
	
   

    glClear (GL_COLOR_BUFFER_BIT);
/* select white for all lines  */
    glColor3f (0.0, 0.0, 0.0);
	

	static GLfloat vdata[12][3] = {    
    {-X, 0.0, Z}, {X, 0.0, Z}, {-X, 0.0, -Z}, {X, 0.0, -Z},    
   	{0.0, Z, X}, {0.0, Z, -X}, {0.0, -Z, X}, {0.0, -Z, -X},    
   	{Z, X, 0.0}, {-Z, X, 0.0}, {Z, -X, 0.0}, {-Z, -X, 0.0} 
	};
	

	static GLuint tindices[20][3] = { 
   	{0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1},    
   	{8,10,1}, {8,3,10}, {5,3,8}, {5,2,3}, {2,7,3},    
   	{7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6}, 
   	{6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11} };

	int i;


	glBegin(GL_TRIANGLES);    
	for (i = 0; i < 20; i++) {    
   		/* color information here */ 
		      
      	glVertex3fv(&vdata[tindices[0]][0]); 
      	glVertex3fv(&vdata[tindices[1]][0]); 
      	glVertex3fv(&vdata[tindices[2]][0]); 

		}
	
	glEnd();
	glFlush ();
}


void reshape (int w, int h)
{
   glViewport (0, 0, (GLsizei) w, (GLsizei) h);
   glMatrixMode (GL_PROJECTION);
   glLoadIdentity ();
   gluOrtho2D (0.0, (GLdouble) w, 0.0, (GLdouble) h);
}

int main(int argc, char** argv)
{
   glutInit(&argc, argv);
   glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
   glutInitWindowSize (400, 150); 
   glutInitWindowPosition (100, 100);
   glutCreateWindow (argv[0]);
   Init ();
   glutDisplayFunc(display); 
   glutReshapeFunc(reshape);
   glutMainLoop();
   return 0;
}
It's pretty simple: i have got 2 2-dimensional arrays. The data one stores the coords of the vertexs, the second one stores the order for the vertex. So i.e. the first triangle had the zeroth, the 4th and the 1st vertexes. Now i can compile it without warnings/errors but i see nothing on my screen. Maybe a viewpoint problem? I am not sure since i am reading step by step the redbook and it still didn't focus on this topic (just 2 lines in the first chapter). So guys, thanks for all :D bye Bro

Share this post


Link to post
Share on other sites
Advertisement
This looks suspect:
/* select white for all lines  */
glColor3f (0.0, 0.0, 0.0);

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
This looks suspect:
/* select white for all lines  */
glColor3f (0.0, 0.0, 0.0);


can u explain better please?
I don't see problems in this code -.-

Edit: yea i was using a back color on a black background. This is not the problem but.

[Edited by - broady on June 13, 2008 9:59:21 AM]

Share this post


Link to post
Share on other sites
What i can see is just a pixel in the down-left corner of the window, and it sounds possible since the definition of the costants.

Any help is accepted thanks :D

Share this post


Link to post
Share on other sites
You've set up your projection matrix so that 1 unit of world space = 1 pixel. Then you're drawing an icosahedron about 1 unit across, and it's drawing 1 pixel. So if you want a bigger icosahedron, either use a different projection, or scale up the model.

Share this post


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

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!