Advertisement

why doesn't it work?

Started by October 12, 2003 12:46 PM
6 comments, last by sebnem_a 21 years, 4 months ago
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.. }
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/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
Advertisement
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..
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/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
glRectf(100.0f, 150.0f, 150.0f, 100.0f);
yes it displays it..
Ok, so my help was not necessary .

========================
Leyder Dylan (dylan.leyder@slug-production.be.tf
http://www.slug-production.be.tf/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
Advertisement
thank you
You''re welcome.

========================
Leyder Dylan (dylan.leyder@slug-production.be.tf
http://www.slug-production.be.tf/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/

This topic is closed to new replies.

Advertisement