[SDL] sdl with opengl attach to existing window

Fabian Mathews supagu at hotmail.com
Fri Sep 16 06:36:34 PDT 2005


Okay, ive delved in to the SDL code and i've found the problem line of code:

the method:

static void Init_WGL_ARB_extensions(_THIS)

is to blame, looks like it opens a temporary window, when this window is 
destroyed, ( DestroyWindow(hwnd); )

at the end of the function, it obviously does something funky in c# causing 
the application to close.
why are we using a temporary window for this code?

if any one has any suggestions what to do about it, currently i have the 
destory window commented out.

Thanks,
Fabian




>From: "Fabian Mathews" <supagu at hotmail.com>
>Reply-To: "A list for developers using the SDL library. 
>(includesSDL-announce)" <sdl at libsdl.org>
>To: sdl at libsdl.org
>Subject: [SDL] sdl with opengl attach to existing window
>Date: Fri, 16 Sep 2005 12:09:34 +0000
>
>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:
>[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);
>[/code]
>
>sdl code:
>[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
>[/code]
>
>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/
>
>
>_______________________________________________
>SDL mailing list
>SDL at libsdl.org
>http://www.libsdl.org/mailman/listinfo/sdl

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/





More information about the SDL mailing list