Archived

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

OpenGL A new too OpenGL

This topic is 5652 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi, Why does OpenGL draw a triangle across 1/4 of the buffer? I just use this code.

glBegin(GL_TRIANGLES);
glVertex3f(0.0f,0.0f,1.0f);
glVertex3f(1.0f,0.0f,1.0f);
glVertex3f(1.0f,1.0f,1.0f);
glEnd();

Best Regards, Michael

Share on other sites
I don''t understand your question. You mean that the triangle is too big, or what?

Height Map Editor | Eternal lands

Share on other sites
Let me see if I can tackle this...

You are wondering why you see something like this:

.............*........**.......***...........

when you wanted to see something like this:
.............*.......***.....*****...........

Well, openGL plotted exactly what you gave it.

glBegin(GL_TRIANGLES);          glVertex3f(0.0f,0.0f,1.0f);          glVertex3f(1.0f,0.0f,1.0f);          glVertex3f(1.0f,1.0f,1.0f);    glEnd();

to
glBegin(GL_TRIANGLES);          glVertex3f(-1.0f,0.0f,1.0f);          glVertex3f(1.0f,0.0f,1.0f);          glVertex3f(0.0f,1.0f,1.0f);    glEnd();

Share on other sites
Hey,
I see someting like this.
.....*....
.....***..
.....*****
..........
..........
When i use that code. I want to see a triangle the size of a pixel. I typed:
glBegin(GL_TRIANGLES);
glVertex3f(0.0f,0.0f,1.0f);
glVertex3f(1.0f,0.0f,1.0f);
glVertex3f(1.0f,1.0f,1.0f);
glEnd();
I would expect to see this.
..........
..........
....*.....
..........
..........
And if i did want to see what i did, i would type:
glBegin(GL_TRIANGLES);
glVertex3f(0.0f,0.0f,1.0f);
glVertex3f(width,0.0f,1.0f);
glVertex3f(width,height,1.0f);
glEnd();

I hope this helped to clear-up what i was asking.

Share on other sites
then replace the z with something like 30.0f instead of 1.0f

Height Map Editor | Eternal lands

Share on other sites
So you want the units of x, y in the vertex position to be one pixel each?

You need to use an orthographic projection instead of a persective one. Use
gluOrtho2D(-windowWidth/2, -windowHeight/2, windowWidth/2, windowHeight/2);

http://users.ox.ac.uk/~univ1234

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631768
• Total Posts
3002240
×