0

Assume the following code:

#define GL_DEPTH_TEST 0x0B71

std::string shader_args = "GL_DEPTH_TEST";

I want to run something like

glEnable(shader_args);
//Draw stuff
glDisable(shader_args);

I have tried std::atoi(shader_args) but it returns 0 instead of 0x0B71

Dennis Maina
  • 11
  • 1
  • 5
  • `#define GL_DEPTH_TEST 0x0B71` is not an `enum`. Sounds like you might want this: https://stackoverflow.com/questions/207976/how-to-easily-map-c-enums-to-strings – NathanOliver Apr 08 '21 at 14:38
  • Basically there's no easy way like in C#, only the hard ways (see dupe). Question is how did you end up with a string "GL_DEPTH_TEST" in the first place? Maybe that place can be improved. – rustyx Apr 08 '21 at 14:41
  • Basically I want to have a shader to have rendering options like depth test and stencil test. I am trying different ways to implement this like passing the options via a string which is parsed then passed on to OpenGL for rendering. There is probably a better way to that. Hope to find out – Dennis Maina Apr 09 '21 at 17:33
  • Maybe you can generate the C++ code for that. If you take a list of all #defines, you can write a simple sed script to generate std::map code or something like that. – rustyx Apr 09 '21 at 20:29

0 Answers0