okay, i can attach opengl to an already open window using win32 code.
now if i try and do the same with opengl it dies an awful death of… just
closing with out any errors why.
note the code for setting up opengl is in a native c++ dll, while i have a
bunch of wrappers and am trying to do this in c#. so through c# i call c++
dll methods to attach opengl to an existing window.
win32 opengl code:
PIXELFORMATDESCRIPTOR pfd;
int iFormat;
// get the device context (DC)
HDC hDC = GetDC( (HWND)hWnd );
// set the pixel format for the DC
ZeroMemory( &pfd, sizeof( pfd ) );
pfd.nSize = sizeof( pfd );
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
iFormat = ChoosePixelFormat( hDC, &pfd );
SetPixelFormat( hDC, iFormat, &pfd );
// create and enable the render context (RC)
HGLRC hRC = wglCreateContext( hDC );
wglMakeCurrent( hDC, hRC );
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
SetClearColour(0.0f, 0.0f, 0.0f, 0.0f);
glClear( GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
); //GL_COLOR_BUFFER_BIT
SwapBuffers(hDC);
sdl code:
// Set the SDL_WINDOWID environment variable
char tmp[64];
sprintf(tmp, "SDL_WINDOWID=%d", hWnd);
putenv(tmp);
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0)
{
// uh oh
}
// if width = 0 and height = 0, the window is fullscreen
// This is necessary to allow the window to move
// on WIN32 systems. Without this, the window resets
// to the smallest possible size after moving.
SDL_SetVideoMode(100, 100, 0, SDL_OPENGL); // first 0: BitPerPixel,
// second 0: flags (fullscreen/...)
// neither are needed as sets these
note sdl code works fine if the SDL_OPENGL flag is set to 0.
any ideas?
my next idea is to d/l the sdl source shudders and work out what the f*ck
is goin wrong in there.
thanks,
Fabian_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it’s FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/