PDA

View Full Version : why isn't this a square???



grimoire
03-22-2004, 03:39 PM
#include <GL/gl.h>
#include <GL/glut.h>

static GLdouble points[]={
0.25,0.25,0.0,
0.75,0.25,0.0,
0.75,0.75,0.0,
0.25,0.75,0.0};

void display(void){
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_DOUBLE,0,points);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0,0.0,1.0);
glBegin(GL_POLYGON);
glArrayElement(1);
glArrayElement(2);
glArrayElement(3);
glArrayElement(4);
glEnd();
glFlush();
}
void init(void){
glClearColor(0.0,0.0,0.0,0.0);
glShadeModel(GL_FLAT);
}

int main(int argc,char **argv){
glutInit(&amp;argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(250,250);
glutInitWindowPosition(100,100);
glutCreateWindow("Melancoly");
init();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}Just another beginner question it comes out almost as a square, but has a triangle attached to the bottom.

zeckensack
03-22-2004, 03:48 PM
Originally posted by grimoire:

glBegin(GL_POLYGON);
glArrayElement(1);
glArrayElement(2);
glArrayElement(3);
glArrayElement(4);
glEnd();Array indices start with zero, not one, as is customary in C :)

grimoire
03-22-2004, 04:32 PM
ahhhh i hate that:)

eror
03-22-2004, 05:02 PM
You should know that- not hate.