Archived

This topic is now archived and is closed to further replies.

sebnem_a

why doesn't it work?

Recommended Posts

I ve writted a code that displays an object by triangles.T he code does not give error but doesn''t display something.I think there is a problem in main function which has named ; void __fastcall TForm1::DrawGLSceneClick(TObject *Sender) The code is like the following; void SetupRC() { // Black background glClearColor(0.0f, 0.0f, 0.0f, 1.0f ); // Set color shading model to flat glShadeModel(GL_FLAT); glFrontFace(GL_CW); } void RenderScene(void) { GLfloat x_t,y_t,z_t,rtri; int n1,n2,n3; glRotatef(rtri,1.0f,0.0f,0.0f); if (!wireframe) { glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); } else { glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); } glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT); glBegin(GL_TRIANGLES); // Drawing Pyramid glColor3f(0.0f,1.0f,1.0f); glVertex3f( 0.0f, 1.0f, 0.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f(-1.0f,-1.0f, 1.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f( 1.0f,-1.0f, 1.0f); glColor3f(0.0f,1.0f,1.0f); glVertex3f( 0.0f, 1.0f, 0.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f( 1.0f,-1.0f, 1.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f( 1.0f,-1.0f, -1.0f); glColor3f(0.0f,1.0f,1.0f); glVertex3f( 0.0f, 1.0f, 0.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f( 1.0f,-1.0f, -1.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f( -1.0f,-1.0f, -1.0f); glColor3f(0.0f,1.0f,1.0f); glVertex3f( 0.0f, 1.0f, 0.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f(-1.0f,-1.0f,-1.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f(-1.0f,-1.0f, 1.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f( -1.0f, -1.0f,-1.0f); glVertex3f(-1.0f, -1.0f,1.0f); glVertex3f(1.0f, -1.0f, 1.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f( -1.0f, -1.0f,-1.0f); glVertex3f(1.0f, -1.0f,1.0f); glVertex3f(1.0f, -1.0f, -1.0f); glEnd(); rtri-=1.2f; glutSwapBuffers(); } void __fastcall TForm1::DrawGLSceneClick(TObject *Sender) { MessageDlg("Display Object.", mtInformation, TMsgDlgButtons() << mbOK, 0); wireframe=true; glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB| GLUT_DEPTH); glutCreateWindow("Your Object"); glutReshapeFunc(ChangeSize); glutSpecialFunc(SpecialKeys); glutDisplayFunc(RenderScene); SetupRC(); glutMainLoop(); } I didnt write here specialfunc and change size.. }

Share this post


Link to post
Share on other sites
Hi,

Where do you reset thee matrix before drawing your triangles ?

Just insert this line :

glLoadIdentity();


between this one :


glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);

glBegin(GL_TRIANGLES); // Drawing Pyramid



Perhaps that it''s not the real problem, it''s just one error.

========================
Leyder Dylan (dylan.leyder@slug-production.be.tf
http://www.slug-production.be.tf/

Share this post


Link to post
Share on other sites
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glBegin(GL_TRIANGLES); // Drawing Pyramid


glColor3f(0.0f,1.0f,1.0f); //

glVertex3f( 0.0f, 1.0f, 0.0f); // Top
glColor3f(0.0f,1.0f,0.0f);
...

it doesnt display either..

Share this post


Link to post
Share on other sites
First, try without the blending. Onluy for seeing is something is drawned on the screen.


========================
Leyder Dylan (dylan.leyder@slug-production.be.tf
http://www.slug-production.be.tf/

Share this post


Link to post
Share on other sites