Question

I want to use OpenGL with C++ to create a basic scene with a "camera" (perspective) and an object to look at. I've found a sample code here. But for some reason, despite the fact that I've tied all the necessary includes and libs together (see below),

// OpenGL init and components:
#include <glload/gl_3_3.h>
#include <glload/gl_load.hpp>
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/freeglut.h>
#include <excpt.h>
#include <glm/glm.hpp>

the IDE (Visual Studio Express 2012 for Windows Desktop) disagrees with me:

identifier undefined for glMatrixMode() and GL_PROJECTION

If you need more information of a certain kind, please let me know.

=============================================================================

Update: After some fiddling around with opengl-related files, this is what I came up with:

// Basics:
#include <windows.h>
#include <string>
#include <exception>
#include <stdexcept>
#include <stdio.h>
#include <stdlib.h>

// OpenGL init and components:
#include <glload/gl_3_1_comp.h>
#include <glload/gl_3_2_comp.h>

#include <glload/gl_3_3.h>

#include <glload/gl_4_0_comp.h>
#include <glload/gl_4_1_comp.h>
#include <glload/gl_4_2_comp.h>
#include <glload/gl_4_3_comp.h>
#include <glload/gl_4_4_comp.h>

#include <glload/gl_load.hpp>
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <excpt.h>
#include <glm/glm.hpp>

And it tells me that GLEW_OK is undefined, albeit it's right there in glew.h:

#define GLEW_OK 0
Was it helpful?

Solution

I see that you're using glew, have you called glewInit()?

Also make sure you're checking if the initialization was a success.

GLenum err = glewInit();
if (GLEW_OK != err)
{
  /* Problem: glewInit failed, something is seriously wrong. */
  fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}

OR, It could be something like this it happened to me this morning, a restart solved my problems

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top