akudewan
March 20th, 2010, 01:31 PM
Hi,
I'm learning OpenGL, and I'm having some trouble using the glVertex2iv() function:
#include<GL/gl.h>
#include<GL/glu.h>
#include<GL/glut.h>
void init()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
}
void display()
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
GLint foo[] = {100,100,300,300};
glBegin(GL_LINES);
glVertex2iv(foo);
//glVertex2i(100,100);
//glVertex2i(300,300);
glEnd();
glFlush();
}
void reshape(int w, int h)
{
glViewport(0,0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble)w, 0.0, (GLdouble)h);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(640,480);
glutInitWindowPosition(100,100);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
The line in red doesn't work, but the lines in green work. I'm quite new to graphics programming. Am I doing something wrong here?
I'm learning OpenGL, and I'm having some trouble using the glVertex2iv() function:
#include<GL/gl.h>
#include<GL/glu.h>
#include<GL/glut.h>
void init()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
}
void display()
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
GLint foo[] = {100,100,300,300};
glBegin(GL_LINES);
glVertex2iv(foo);
//glVertex2i(100,100);
//glVertex2i(300,300);
glEnd();
glFlush();
}
void reshape(int w, int h)
{
glViewport(0,0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble)w, 0.0, (GLdouble)h);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(640,480);
glutInitWindowPosition(100,100);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}
The line in red doesn't work, but the lines in green work. I'm quite new to graphics programming. Am I doing something wrong here?