Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Disappearing triangle  (Read 787 times)

0 Members and 1 Guest are viewing this topic.

Mr.Light

  • Newbie
  • *
  • Posts: 2
    • View Profile
Disappearing triangle
« on: April 28, 2011, 11:59:51 pm »
I am trying to draw a triangle which is translated 6 units into the screen. The program runs but I cannot see the triangle. I can only see the triangle if I translate less then or equal to ±1 along the z axis.

Why can't I see it when I try to translate it -6 units in the z direction?

Here is the code

Code: [Select]

#include <SFML/Graphics.hpp>

int DrawGLScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glLoadIdentity();
glTranslatef(0.0f,0.0f, -6.0f);

glBegin(GL_TRIANGLES);

glVertex3f( 0.0f, 1.0f, 0.0f); // Top
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd();

}

...


Mr.Light

  • Newbie
  • *
  • Posts: 2
    • View Profile
Disappearing triangle
« Reply #1 on: April 29, 2011, 09:31:36 pm »
Fixed.

Forgot to add this stuff.

Code: [Select]

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.f, 1.f, 1.f, 500.f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

 

anything