0

My Code:

const wchar_t  *foo = reinterpret_cast<const wchar_t *>(glGetString(GL_SHADING_LANGUAGE_VERSION));
LPCTSTR sversion = foo;
MessageBox(NULL, sversion, TEXT("GL_SHADING_LANGUAGE_VERSION"), MB_OK);

The problem:

This results into some weird content of mostly Chinese and some other characters instead of the GL_SHADING_LANGUAGE_VERSION, as the reinterpret_cast "interprets" the thing as something else as I've wanted it to. I've also tried to do it with normal C casts, but this results into the same problem and because glGetString returns an GLubyte* I cannot put the code directly into the MessageBox function as this requires an LPCTSTR as an input.

Note:

I've defined the UNICODE keyword in my files. This is why I am using wchar_t instead of char.

ShadowDragon
  • 2,238
  • 5
  • 20
  • 32
  • You can't randomly cast between `char*` as returned by `glGetString()` and `wchar_t*` willy-nilly like that. see https://stackoverflow.com/questions/8032080/how-to-convert-char-to-wchar-t –  Jul 31 '17 at 20:24
  • Thats what I noticed. My problem is now, I want to display the output from glGetString in a windows message box, so how am I able to achieve this? – ShadowDragon Jul 31 '17 at 20:26
  • 2
    Just use `MessageBoxA` it will display ASCII in a Unicode application. (`MessageBox` is a macro that maps to `MessageBoxW` or `MessageBoxA` depending on your unicode build settings.) – Richard Critten Jul 31 '17 at 20:32

0 Answers0