Jump to content

Image of the Day

Setting up a playground for our bad boys... #maya #gameart #screenshotsaturday #gamedev https://t.co/V5mfxWkzHg
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.

Sign up now

OpenGL's glDrawRangeElements not working on Windows/freeglut?

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 BlinksTale   Members   


Posted 27 September 2012 - 04:47 PM

Hello everyone, still pretty new feeling for opengl here. Using freeglut for Windows, I've been getting an error for code that was working in my Linux build. My makefile code includes the following for importing webgl stuff:

ifeq ($(shell uname), Linux)
  Graphics = -I/usr/X11R6/include -L/usr/X11R6/bin -lglut -lGL -lGLU
else ifeq ($(shell uname), Darwin) # Darwin = Mac
  Graphics = -framework OpenGL -framework GLUT
  Graphics = -I ".\include" -L ".\lib" -lglut -lGLU -lGL  -lfreeglut -lglu32 -lopengl32 -Wl,--subsystem,windows -static

where .\include and .\lib are just the folders from freeglut-MinGW-2.8.0-1.mp.zip, and my src folder has the freeglut dll inside. So, that said, this is the error I'm getting:

error: 'glDrawRangeElements' was not declared in this scope

due to this call:

glDrawRangeElements(GL_TRIANGLES, 0, 3, 6, GL_UNSIGNED_BYTE, indices+6*i);

So, Googling the error only gives one good Google result, and it's a cryptic dead link reply along with, using glext.h, the following:

glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)wglGetProcAddress("glDrawRangeElements");

So I tried #include glext.h with the file in my src folder, and it tells me glDrawRangeElements doesn't have a type.

error: 'glDrawRangeElements' does not name a type

Surprisingly, tweaking the above code makes the error go away by removing the middle step:

But when it finally gets to the display of the game, if any instances of glDrawRangeElements are left, it just gives a blank white screen. Commenting out those instances of glDrawRangeElements makes everything except for that work, but trying to include them breaks everything.

Another, unrelated Google result brought this code up:

#ifdef _WIN32
// function pointer to OpenGL extensions
// glDrawRangeElements() defined in OpenGL v1.2 or greater
#define glDrawRangeElements pglDrawRangeElements

along with

#ifdef _WIN32
  // get function pointer to glDrawRangeElements
  glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)wglGetProcAddress("glDrawRangeElements");

But I'm basically getting the same errors. If I assign anything to glDrawRangeElements, it says pglDrawRangeElements does not name a type. I have glext.h included too, so this comes off as especially strange. So, any thoughts? I'm on a Windows 7 64-bit OS using OpenGL, GLU, and freeglut as far as I can tell.

#2 BlinksTale   Members   


Posted 28 September 2012 - 03:09 PM

Well, at the least, I found that this works with similar results:

glDrawRangeElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices+6*i);

Might be a bit laggier, not sure yet, but definitely runs on Windows and Linux both. Anyways, just posting this in case someone comes across this same issue!

#3 dave j   Members   


Posted 29 September 2012 - 03:08 AM

Two things:

Windows's native OpenGL support is for an old version. To use the newer APIs you need to use wglGetProcAddress. Most people use an extension loading library for this and I notice that you are not linking with any. Details of extension loading libraries can be found here. They work on other platforms as well so you don't have to write conditional code.

The other thing is you are linking with the -static flag which will prevent linking with dynamic libraries - this might also cause problems.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.