[SDL] sdl with opengl attach to existing window
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:
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.
>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:
> 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.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
> // Set the SDL_WINDOWID environment variable
> char tmp;
> sprintf(tmp, "SDL_WINDOWID=%d", hWnd);
> 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.
>my next idea is to d/l the sdl source *shudders* and work out what the f*ck
>is goin wrong in there.
>Express yourself instantly with MSN Messenger! Download today it's FREE!
>SDL mailing list
>SDL at libsdl.org
Express yourself instantly with MSN Messenger! Download today it's FREE!
More information about the SDL