简体   繁体   中英

Prefixing hex value with 0x

I'm querying a GL_TYPE in OpenGL and it's reporting back the hexadecimal value as an integer, as it should .

For example: 0x1406 is #define'd as GL_FLOAT but is being given to me from OpenGL in integer form as 5126.

Unfortunately OpenGL doesn't just return the type and it also doesn't just accept the integer (read: hex) value back. It apparently needs it to be prefixed with 0x before being used.

I'm trying to save myself a switch/case and instead cast/convert on the fly but I don't see another way. Do I have any other options? No boost please.

It's unclear what sort of "conversion" you have in mind: 0x1406 equals 5126. They're just different ways of writing the same number in source code, and the compiler translates them both into the binary form that's used at runtime.

You should be able to just use the == operator to compare the result of glGetProgramResource against a constant like GL_FLOAT , regardless of whether that constant is defined as 0x1406 or 5126 in the source code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM