Sign in to follow this  
sandblasted

window application or openGL application ??

Recommended Posts

Hi guys, My question will probably seem very stupid but I got no choice but to ask. I have just started to learn openGL programming. I am using the codeblocks IDE. I am trying to execute the first example given which would display a white rectangle. But do I write the code in window application or openGL application?? the code according to the book goes like this (can u please also say whether I have used the right header files or not ??) #include <windows.h> #include <GL/gl.h> #include <GL/glu.h> #inlcude <gl/glut.h> void display (void) { //glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); //glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0); glBegin(GL_POLYGON); glVertex3f(0.25,0.25,0.0); glVertex3f(0.75,0.25,0.0); glVertex3f(0.75,0.75,0.0); glVertex3f(0.25,0.75,0.0); glEnd(); glFlush(); } void init (void){ glClearColor(0.0,0.0,0.0,0.0); glMatrixMode (GL_PROJECTION); glLoadIdentity (); glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0); } int main(int argc, char** argv) { glutInit (&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (250, 250); glutInitWindowPosition (100, 100); glutCreateWindow ("hello"); init (); glutDisplayFunc (display); glutMainLoop (); return 0; }

Share this post


Link to post
Share on other sites
Quote:
But do I write the code in window application or openGL application??
There isn't any such thing as an 'OpenGL application', I don't think [Edit: unless you're referring to a project template of some sort], but in this case I don't think you want a Windows application (i.e. with WinMain()).

I've never used Code::Blocks, so I can't give you specifics, but I think you'll probably want to create a generic or 'empty' project for this. I'm sure someone familiar with the IDE will be able to provide more details.

Share this post


Link to post
Share on other sites
Been a while since I used CB but you definitely want the OpenGL template. That will include the right libs, and seeing you have main in there, a winapp will not do since it would expect at WinMain. The libraries you need are opengl32.lib and glut32.lib

Note that I'm not sure the OpenGL template includes glut32.lib (the utility lib you're using). Your system might not even include the glut32.lib, but Google can help you get that fixed ;)

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