OpenGL triangle not rendering
in
Core Library Questions
•
1 year ago
I'm having a really weird problem while trying to render triangles with openGL and processing, I don't know if its an issue of openGL or not but I've tried in both windows and mac with the same results.
I'm trying to render a triangle with the following vertices
The weird thing is that if I change the second vertex to 0.85065 1,0.0,-0.525731. It works.
I really don't know what is going on so if someone has any clue please help me.
Here is the actual processing code of the scene for you to play around:
I'm trying to render a triangle with the following vertices
vertex(0.850651,0.0,0.525731);
vertex(0.850652,0.0,-0.525731)
;
vertex(0.525731,0.850651,0.0);
The weird thing is that if I change the second vertex to 0.85065 1,0.0,-0.525731. It works.
I really don't know what is going on so if someone has any clue please help me.
Here is the actual processing code of the scene for you to play around:
- import processing.opengl.*;
float time = 0;
void setup() {
size(400, 400, OPENGL);
//noStroke();
}
void draw() {
resetMatrix();
background(255);
perspective (PI * 0.333, 1.0, 0.01, 1000.0);
camera (0.0, -5.0, 5.0, 0.0, 0.0, -1.0, 1.0, 1.0, 0.0);
scale (1.0, -1.0, 1.0);
ambientLight(102, 102, 102);
lightSpecular(204, 204, 204);
directionalLight(102, 102, 102, -0.7, -0.7, -1);
directionalLight(152/2, 152/2, 152/2, 0, 0, -1);
pushMatrix();
fill(200, 200, 200);
ambient (200, 200, 200);
specular(0, 0, 0);
shininess(1.0);
rotate (time, 0.0, 1.0, 0.0);
beginShape();
vertex(0.850651,0.0,0.525731);
vertex(0.850652,0.0,-0.525731); //Try changing the 2 for a 1
vertex(0.525731,0.850651,0.0);
endShape(CLOSE);
popMatrix();
time += 0.05;
}
1