Forum > General
Creating a SDL child window on a form or panel control?
(1/1)
sysrpl:
I am attempting to use SDL2 on Linux (gtk2 widgetset) to create an OpenGL window inside a child control. I got the idea or impression that this was possible using the SDL_CreateWindowFrom function of SDL2, but all execution stops when I call the function.
Here is a bit of code from my TEmbedWindow class that is attempting to wrap a control / SDL OpenGL together in a class.
Does anyone have any suggestions as to how to get this working? Currently when the line with SDL_CreateWindowFrom is reached, my program just exits.
Thank you for any suggestions you might have.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TEmbedWindow.Start: Boolean;var W: TXID;begin Result := False; // FAssociate is a TWinControl and has a x windows handle if FAssociate = nil then Exit; // I have also tried with just SDL_INIT_VIDEO or SDL_INIT_TIMER if SDL_Init(SDL_INIT_EVERYTHING) < 0 then Exit; // Configure the OpenGL context request SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); // This gets the x window handle from a gtk2 based control W := GDK_WINDOW_XWINDOW(PGtkWidget(PtrUInt(FAssociate.Handle))^.window); // This line stops all execution FWindow := SDL_CreateWindowFrom(Pointer(W)); // The program exits from the line above if FWindow = nil then Exit; FCtx := SDL_GL_CreateContext(FWindow); if FCtx = nil then Exit; SDL_GL_MakeCurrent(FWindow, FCtx); FStarted := LoadGL(SDL_GL_GetProcAddress); Result := FStarted;end;
hukka:
I haven't tried this on Linux, but on Windows I can successfully embed SDL2 into a TPanel with
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---SDL_CreateWindowFrom(Pointer(HostPanel.Handle));
Navigation
[0] Message Index