Jump to content
  • Advertisement
Sign in to follow this  
Tom Backton

OpenGL Pointer Arguments to OpenGL Funtions

This topic is 3048 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been reading OpenGL 3.2's specification and I noticed that pointer arguments to some functions, for example glMultiDrawArrays, are not pointers-to-const while data is not written through them. I opened the gl3.h file available at opengl.org and indeed in some functions these pointers are not const. As a result, I can't pass pointers to const arrays to these functions without C-style explicit type-casting or const_cast<>(). Is it possible/safe to edit the gl3.h file (make those pointers const) or I'll just have to use type-casting? And why are these pointers not const in the first place, if there are no writes through the pointers?

Share this post


Link to post
Share on other sites
Advertisement
const_cast may be evil, but editing 3rd party API headers is just diabolical.

[edit] Remember that GL is a C API, not a C++ API -- Perhaps they don't use const because it is a relatively new addition to the C language (it was borrowed from C++), and they want to be compatible with all C compilers?

[Edited by - Hodgman on February 13, 2010 6:53:07 AM]

Share this post


Link to post
Share on other sites
I don't think so because some pointers, like const void* pointer in glMultiDrawArrays and all other VA functions, does use the const qualifier, while other for-reading-only pointer arguments don't use const. Also, in other functions, like glMultiDrawElements, pointers ARE const, but if I'm not mistaken it doesn't appear in the spec (in which they aren't const), only in the downloadable gl3.h. While the const void* pointer is const in the spec too. I don't understand why...if the implementation perfectly follows the spec and doesn't write through the pointers then editing the header and using const_cast are both practically safe, but they are still theoretically not type-safe...So what should I do? And why aren't these pointers const if nothing is written through them?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!