PDA

View Full Version : Compilation problems of trivial code on Windows 7



alihelmy
08-16-2012, 03:19 PM
I am trying to compile a very basic OpenGL program that draws a cube using Vertex Array Buffers passed to vertex & fragment shaders

My code is tested & runs perfectly on OSX, however it does not compile on Windows 7 machine. I have the nVidia GeForce 540M chipset and have updated my drivers to the latest

I import the necessary headers using:

#ifdef _WIN32
#include <Windows.h>
#endif

#include <stdlib.h>
#include <stdio.h>
#ifdef __APPLE__
#include <OpenGL/gl.h>
#include <Glut/glut.h>
#else
#include <GL/gl.h>
#include <GL/glut.h>
#endif

however, I get compilation errors in Visual C++ 2010 express saying: ERROR: identifer 'xyz' is undefined, where xyz is one of:

glCreateProgram(), GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, glAttachShader, glLinkProgram and others. stuff like
glClearColor, glEnable, glBlendFunc however is fine and has no compilation errors.

So, why are these symbols undefined? what imports am I missing / doing wrong?

HERE (http://pastebin.com/Hx7mSWXg) is a complete paste of my code if it would help at all. The includes are in the "shaderUtilities.h" file

Thanks for your help in advance

Disclaimer: complete newbie here, so please forgive my ignorance if this is the wrong place to post. Also, I have searched for a similar issue, but could not find one, so if this is indeed a repeated question, please forgive me and kindly redirect me to what I should read / search for

tanzanite
08-18-2012, 05:14 AM
You are missing headers and probably are not loading any of the functions you attempt to use, read:
http://www.opengl.org/wiki/Getting_Started#Getting_Functions

I recommend you use a loading library:
http://www.opengl.org/wiki/OpenGL_Loading_Library

alihelmy
08-18-2012, 03:13 PM
You are missing headers and probably are not loading any of the functions you attempt to use, read:
http://www.opengl.org/wiki/Getting_Started#Getting_Functions

I recommend you use a loading library:
http://www.opengl.org/wiki/OpenGL_Loading_Library

Thanks for the advice and for pointing me into the correct direction

Could you explain why this is not needed on MacOSX though?