hello, theres something wrong about my code and i cant find the problem! i know it is a stupid mistake cause it never happened to me…
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
//#include <stdio.h>
//#include <stdlib.h>
GLdouble orthoX1 = -50.0;
GLdouble orthoY1 = +50.0;
GLdouble orthoX2 = -50.0;
GLdouble orthoY2 = +50.0;
GLfloat windowWidth,windowHeight;
GLfloat xjanela, yjanela;
GLint LARGURA = 334;
GLint ALTURA = 334;
void inicializa(void){
glClearColor(1,0,0,1);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH);
}
void Render(void){
glClear(GL_COLOR_BUFFER_BIT);
glLineWidth(2);
glBegin(GL_LINES);
glColor3f(0,0,0);
glVertex3f(0,-5,+2);
glVertex3f(0,5,+2);
glColor3f(0,1,0);
glVertex3f(2,-5,-2);
glVertex3f(2,5,-2);
glColor3f(1,1,1);
glVertex3f(-5,0,0);
glVertex3f(5,0,0);
glEnd();
glFlush();
}
void Reshape(int w, int h){
glViewport(0, 0,(GLsizei)w, (GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(orthoX1, orthoY1, orthoX2, orthoY2, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glutPostRedisplay();}
void main()
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize(LARGURA,ALTURA);
glutInitWindowPosition(350,250);
glutCreateWindow(“camera”);
inicializa();
glutDisplayFunc(Render);
glutReshapeFunc(Reshape);
glutMainLoop();
}
Ok… so the green line should be far, the white in the middle, and the black in the front… but they appear in the order i draw them… the last one to be called will became the closest to the camera… why?
thanks =))