Sign in to follow this  
Tirdad

Problem with Header files in GLUT OpenGL programmin

Recommended Posts

Tirdad    128
[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]Hi there[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]I’m using openGL with GLUT framework .[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]I’ve got some problem with my first code :[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]Here’s the condiotion :[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]Windows 7 64 bit[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]DevC++ , Pelles C compiler[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]GLUT 3.7[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]==============================[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]I got the GLUT 3.7 files from the site .[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]In which folders I must put them ? glut.h / glut.lib /glut.dll[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]And the code :[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]==============================[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]#include <windows.h>[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]#include <GL/glut.h>[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]#include <GL/gl.h>[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]#include <GL/glu.h>[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"] [/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]void display(void)[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]{[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glClear(GL_COLOR_BUFFER_BIT);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glColor3f(1.0,1.0,1.0);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glBegin(GL_POLYGON);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glVertex3f(0.25,0.25,0.0);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glVertex3f(0.75,0.25,0.0);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glVertex3f(0.75,0.75,0.0);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glVertex3f(0.25,0.75,0.0);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glEnd();[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glFlush();[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"] [/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]}[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"] [/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]void init(void)[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]{[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glClearColor(0.0,0.0,0.0);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glMatrixMode(GL_PROJECTION);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glLoadIdentity();[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]}[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]int main(int argc,char** argv)[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]{[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glutInit(&argc,argv);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glutInitWindowSize(250,250);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glutInitWindowPosition(100,100);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glutCreateWindow("hello");[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]init();[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glutDisplayFunc(display);[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]glutMainLoop();[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"] [size="3"]return0;[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]}[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]============================[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]Error code :[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]========================================================[/size][/font]

[font="Times New Roman"][size="3"][/size][/font][b]C:\Users\Tirdad\Documents\PellesC Projects\first\gl1.c(24): error #2070: Insufficient number of arguments to'function'.[/b]

[font="Times New Roman"][size="3"][/size][/font][b]C:\Users\Tirdad\Documents\PellesC Projects\first\gl1.c(30): warning #2203: Function 'main' can't be __stdcall,changed to __cdecl.[/b]

[font="Times New Roman"][size="3"][/size][/font][b]C:\Users\Tirdad\Documents\PellesC Projects\first\gl1.c(37): warning #2168: Operands of '=' have incompatibletypes 'void __cdecl function(void)' and 'void __stdcall function(void)'.[/b]

[font="Times New Roman"][size="3"][/size][/font][b]C:\ProgramFiles\PellesC\Include\Win\GL\glut.h(549): warning #2135: Static'glutCreateMenu_ATEXIT_HACK' is not referenced.[/b]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"] [/size][/font]

[font="Times New Roman"][size="3"][/size][/font][font="Calibri"][size="3"]========================================================[/size][/font]

[font="Times New Roman"][size="3"][/size][/font]

Share this post


Link to post
Share on other sites
jesse007    158
Your call to glClearColor () has only 3 arguments but you need to also supply the alpha argument so you need one more 0.0 or whatever you want to pass. Also, you have a syntax error on the "return0" statement. You probably don't want to be using Dev++ and glut either as both are quite old. The free Visual Studio Express C++ from Microsoft or minimalist gcc for Windows along with Code::Blocks or Eclipse is a better choice. Use freeglut instead of glut. Another thing, why not try learning modern OpenGL 3/4 instead of the old classic OpenGL? Unless you're planning on working with legacy code I really don't see why you would want to learn it. But if you are learning it, then just go to the [url="http://nehe.gamedev.net"]NeHe[/url] website--it will answer almost all your questions.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this