PDA

View Full Version : plz help!!

10-11-2001, 04:54 PM
i do the rigth code to show me a triangle... but no way... i didnt seen my triangle in my form..
can anybody help me??

Gavin
10-11-2001, 11:54 PM
How do you know you have the right code? Make sure you have the triangle within the viewing area. Make sure you are drawing it a different colour to the background.

10-12-2001, 07:17 AM
ok.. i copy the code of the program11, and.. i cant see my triangle.... does the code is complete......if it imcomplete... what the rest of the code plz... im a really beginner..
lol

spidey
10-12-2001, 10:42 AM

kehziah
10-12-2001, 12:16 PM
One common beginner mistake is to forget to translate things into the viewing volume.

In many tutorials, the neat clipping plane is set to 1, so if you try to draw a triangle in XY plan without translating it, it will be culled.

glMatrixMode(GL_PROJECTION);
gluPerspective(45,aspect,1,10);
glMatrixMode(GL_MODELVIEW);
glTranslatef(0.0f,0.0f,-5.0f);
glBegin(GL_TRIANGLES);
glVertex3f(-1.0f, -1.0f, 0.0f);
glVertex3f( 1.0f, -1.0f, 0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glEnd();

Notice that here we set near clipping plane to 1, and far clipping plane to 10.
So before rendering our triangle, we move 5 units "into the screen".

Of course you don't need to reset the perspective every frame. I just put it here so that you can see where are clipping planes set up.

10-12-2001, 09:20 PM
the code like this:
void make_shape ( void )
{
GLUtriangulatorObj *tess;
GLdouble outside [4][3] = { { -0.9, -0.9, 0.0 },
{ 0.9, -0.9, 0.0 },
{ 0.9, 0.9, 0.0 },
{ -0.9, 0.9, 0.0 } };
GLdouble inside [3][3] = { { 0.0, 0.3, 0.0 },
{ 0.3, -0.3, 0.0 },
{ -0.3, -0.3, 0.0 } };
list[0] = glGenLists ( 1 );
tess = gluNewTess ( );
gluTessCallback ( tess, GLU_BEGIN, ( void ( __stdcall *) ( void ))glBegin );
gluTessCallback ( tess, GLU_VERTEX, ( void ( __stdcall *) ( void ))glVertex3dv );
gluTessCallback ( tess, GLU_END, glEnd );
glNewList ( list[0], GL_COMPILE );
gluBeginPolygon ( tess );
for ( int i = 0; i < 4; i++ )
gluTessVertex ( tess, outside[i], outside[i] );
gluNextContour ( tess, GLU_INTERIOR );
for ( int i = 0; i < 3; i++ )
gluTessVertex ( tess, inside[i], inside[i] );

gluEndPolygon ( tess );
glEndList ( );
gluDeleteTess ( tess );
}

So im trying the code submit bye kehziah and i've not seen my triangle.. sorry.. i really not understand how to show my triangle;

kehziah
10-13-2001, 12:04 AM
Is your code supposed to draw a simple triangle?? If so, drop it. You're taking a big hammer to squash a fly.

About the piece of code I posted :
did you properly calculate the aspect ratio of your viewport? (the "aspect" parameter in the gluPerspective call) I remind you that it is calculated by
aspect = width / height;
Be careful if you're in windowed mode that height does not become 0, or make a test to avoid divide by 0.

10-13-2001, 07:26 AM
with my code givin up.. what u suggest that i can build and see my triangle....

W
10-15-2001, 12:53 AM
How do you create your window? What are your transformation settings (MODELVIEW and PROJECTION)?

10-15-2001, 06:11 AM
i've use the code gived by kehziah for my viewport and projection, i see my form in gray color that is the default givin by builder c++ ... but i dont see my triangle

10-20-2001, 12:34 AM
hm... Have you used wglMakeCurrent ()?

MofuX
10-20-2001, 01:00 AM
tip:
use the nehe tutorials if you really want to learn opengl...
http://nehe.gamedev.net/