PDA

View Full Version : OpenGL Error



Joshhua5
01-02-2011, 02:47 AM
Hello, Been looking through some OpenGL tutorials and I've hit a problem with the most basic of things and i have No idea what the problem is...

the code is




#include <stdlib.h>
#include <gl/glut.h>

void renderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5,-0.5,0);
glVertex3f(0.5,0.0,0.0);
glVertex3f(0.0,0.5,0.0);
glEnd();
glFlush();
}


void main(int *argc, char **argv)
{
glutInit(argc, argv);
glutInitWindowPosition(100,100);
glutInitWindowSize(660,430);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH);
glutCreateWindow("Glut Window Test");
glutDisplayFunc(renderScene);
glutMainLoop();
}


and my Error is

http://img534.imageshack.us/img534/9140/capturezi.jpg

mobeen
01-02-2011, 03:13 AM
Hello, Been looking through some OpenGL tutorials and I've hit a problem with the most basic of things and i have No idea what the problem is...

the code is


code stripped for space concerns

and my Error is

image removed for space concerns
Change the following lines


void main(int argc, char **argv)
{
glutInit(&amp;argc, argv);

argc is the total number of command line args passed into ur program its not an int pointer just an int variable.
you pass this argc int variable as a pointer to glutInit.

Hope this helps,
Mobeen

Wopple
01-02-2011, 03:13 AM
Try sending the address of argc to glutInit so:


glutInit(&amp;argc, argv);

Joshhua5
01-02-2011, 03:26 AM
Thank you, and I'll like to say
the tutorial is Doing it wrong.

Dark Photon
01-02-2011, 02:46 PM
Thank you, and I'll like to say the tutorial is Doing it wrong.
Which tutorial? Let's ping the author so they can get it fixed.

Best I can tell, that tutorial isn't on the opengl.org web site: search link (http://www.google.com/search?q=glutinit+site%3Aopengl.org&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a#sclient=psy&amp;hl=en&amp;client=firefox-a&amp;hs=QqB&amp;rls=org.mozilla:en-US%3Aofficial&amp;q=glutinit+tutorial+site:opengl.org+-inurl%3Adiscussion_boards&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=&amp;gs_rf ai=&amp;pbx=1&amp;fp=83f87efc6f926f13)