PLEASE HELP

Started by
6 comments, last by dimebolt 18 years, 7 months ago

const GLubyte *szExtensions = glGetString(GL_EXTENSIONS);
char m[1000];

sprintf(m, "%s", (char *)szExtensions);
MessageBox(NULL, m, "Error", MB_OK | MB_TOPMOST);

The message box text says NULL... What is wrong with my code? I have also tried some casts... If you can please help... Thanks in advance.
This world is ruled by big furry CATS!! :)Meow! :)
Advertisement
char* Buffer = (char*)malloc(strlen((char*)glGetString(GL_EXTENSIONS))+1);strcpy(Buffer, (char*)glGetString(GL_EXTENSIONS));MessageBox(NULL, Buffer, "Error", MB_OK);free(Buffer);
Looks like an error occured. E.g. if you call glGetString between glBegin()/glEnd(), it will return 0. Use glGetError() to retrieve the error code.
Quote:Original post by UltimaX
*** Source Snippet Removed ***


Unhandled exception at 0x0041bad0 in Ancient Spirit Engine.exe: 0xC0000005: Access violation reading location 0x00000000.

this is the error i get...
This world is ruled by big furry CATS!! :)Meow! :)
Quote:Original post by Konfusius
Looks like an error occured. E.g. if you call glGetString between glBegin()/glEnd(), it will return 0. Use glGetError() to retrieve the error code.


actually im not drawing at all... i havent even initialized the HGLRC or HDC... no PIXELFORMAT and etc...

Error: invalid handle...
This world is ruled by big furry CATS!! :)Meow! :)
That is the problem. You need a valid GL context before you can call any OpenGL calls.
*FEELS STUPID*
...............................................
ow.... now i get it... DUH....

Thanks you all :)
This world is ruled by big furry CATS!! :)Meow! :)
const GLubyte *szExtensions = glGetString(GL_EXTENSIONS);char m[1000];sprintf(m, "%s", (char *)szExtensions);MessageBox(NULL, m, "Error", MB_OK | MB_TOPMOST);


I'd like to add that 1000 characters is probably not enough to fit every extension, except on older graphics cards. If you're using C, you should use strlen, malloc and strncpy to make m the proper size, if you use C++ use std::string...

Tom

This topic is closed to new replies.

Advertisement