PDA

View Full Version : problems with z axis!!



frog
01-04-2001, 05:44 AM
I just started learning open gl. I 've a big probleme concerning the 3d rendering. When i draw some points in my window like this:
glBegin(GL_POINTS)
GlVertex3f(10.0f,10.0f,0.0f)
glEnd()
there are any problems, whereas when I include a value to the z coordinate, my points are invisible. I got the same problems when I do "auxWireTeapot", I can just see the shape but not in 3d...
thanks for your help and excuse my english!!


mail me: yanntraveling@yahoo.fr

Glossifah
01-04-2001, 05:53 AM
Are you setting up a 3d viewing volume? It sounds like you are using Ortho2d for the scene. If you are using a viewing volume, check your near and far clipping planes to be sure that you aren't clipping +1 and -1 z.

Just my 2 cents.

Glossifah

frog
01-04-2001, 07:16 AM
thanks for helping me !!!

I'm sure that I did a viewing volume. Each time I change the z coordinate (z!=0) the vertex don't appear: look at my listing:

void ChangeSize(GLsizei w,GLsizei h)
{

GLfloat nRange=500.0f;
if (h==0)
h==1;
glViewport(0,0,w,h);
glColor3f(1.0f,0.0f,0.0f);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w<= h)
glOrtho(-nRange,nRange, -nRange*h/w, nRange*h/w, -nRange,nRange);
else
glOrtho(-nRange*w/h,nRange*w/h, -nRange, nRange, -nRange,nRange);


glMatrixMode(GL_MODELVIEW);
glLoadIdentity();


}

Glossifah
01-04-2001, 08:18 AM
Can you post the code in it's entirety, or post a link to the code? I'll fiddle with it and see what I can see.

Glossifah

Glossifah
01-05-2001, 09:21 PM
Frog,

Sorry so late with the reply. I got your email and reviewed the code. Just a few mistakes, but here's the working version:




#include<gl\glaux.h>

void SetupRC()
{
glClearColor(0.0f,0.0f,1.0f,1.0f);
glColor3f(1.0f,0.0f,0.0f);
}

void CALLBACK ChangeSize(GLsizei w,GLsizei h)
{
GLfloat nRange=50.0f;
if (h==0)
h=1;
glViewport(0,0,w,h);

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

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

if (w<= h)
glOrtho(-nRange,nRange, -nRange*h/w, nRange*h/w, -nRange,nRange);
else
glOrtho(-nRange*w/h,nRange*w/h, -nRange, nRange, -nRange,nRange);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void CALLBACK RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
auxWireTeapot(50.0f);
glBegin(GL_POINTS);
glVertex3f(10.0f,10.0f,0.0f);
glVertex3f(10.0f,10.0f,-10.0f);
glEnd();
glFlush();
}

void main()
{
auxInitDisplayMode(AUX_SINGLE|AUX_DEPTH|AUX_RGBA);
auxInitPosition(100,100,400,400);
auxInitWindow("fenetre 3d");
auxReshapeFunc(ChangeSize);
SetupRC();
auxMainLoop(RenderScene);
}



From there you can see what I added. You never referenced SetupRC(), you didn't set the reshape function, and I added a window size function. Other than that, it works great.

Feel free to email me if you have further questions, or post on this board so others can learn along with you.

Oh, je parle un peu, mais je ne sais pas plus des paroles. Je pense que c'est sont un peu des personnes qui parlez en Francais ici.

Glossifah

frog
01-10-2001, 07:27 AM
I use opengl because I have a enginering projet to make for my study. So I need to use opengl for apply deformations to a rendered object. In fact I need to load in memory each coordinate. If somebody know how can I load by myself an object modelized by 3dmax...

mcbastian
01-12-2001, 02:58 AM
Hi!

Use the ASE-Export-function.
SIMPLE loader at my website metroplex.gobi-gotha.de

or use the 3dexplorer-program, which can convert 3ds-files (and of course other!) direct into cpp-code :-) it is well-documented. i think you find a link on nehe's site nehe.gamedev.net.