Gandi Posted April 18, 2010 Share Posted April 18, 2010 Is there a way of resizing the backbuffer without calling the Graphics() method? I would be also happy with some OpenGL commands for doing it.. I just cant call Graphics() as this seems to create a ned HWND every time, and im using the window as a Child... I got no problem with resizing the rest of the buffers, but im really stuck with the backbuffer.. if noone has a clue i guess, ill just make a backbuffer with screensize and rendering only the visible part, but thats not really the way I'd like to do it if not necessary €: I tried "glViewport(0, 0, width, height);" but that doesnt seem to do anything.. Quote Link to comment Share on other sites More sharing options...
enablerbr Posted April 18, 2010 Share Posted April 18, 2010 i think the only way to do what you want is to create an OpenGL context of your own and use CreateCustomBuffer command instead of the Graphics command. that would mean you would use the OpenGL swapbuffers instead of Leadwerks graphics Flip command. This way your responible for the backbuffer, which will be the custombuffer you create. 1 Quote Q6600, GTX 560Ti, 8GB DDR2, Windows 7 Home Premium 64-bit. Link to comment Share on other sites More sharing options...
Masterxilo Posted April 18, 2010 Share Posted April 18, 2010 Right. Quote Hurricane-Eye Entertainment - Site, blog. Link to comment Share on other sites More sharing options...
Gandi Posted April 18, 2010 Author Share Posted April 18, 2010 Ok.. I managed it.. if some1 is interested: #include <engine.h> #include <gl/gl.h> #include <gl/glu.h> namespace Clockwise { class LECustomWindow { public: LECustomWindow(HWND window); TBuffer GetBackBuffer(); int GetWidth(); int GetHeight(); virtual void SetSize(int width, int height); void Flip(); protected: static void _stdcall makeCurrent(void); static void _stdcall getSize(int* width, int* height); TBuffer BackBuffer; TWorld World; int Width; int Height; }; } #include "LECustomWindow.h" #include <iostream> namespace Clockwise { HDC hDC; HGLRC hRC; void _stdcall LECustomWindow::makeCurrent(void) { wglMakeCurrent( hDC, hRC ); } void _stdcall LECustomWindow::getSize(int* width, int* height) { makeCurrent(); int vPort[4]; glGetIntegerv(GL_VIEWPORT, vPort); *width = vPort[2]; *height = vPort[3]; } void LECustomWindow::SetSize(int width, int height) { Width=width; Height=height; glViewport(0,0,Width,Height); } LECustomWindow::LECustomWindow(HWND window) { hDC=0;hRC=0; PIXELFORMATDESCRIPTOR pfd; int iFormat; hDC = GetDC( window ); 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 = 32; pfd.cAlphaBits = 8; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; iFormat = ChoosePixelFormat( hDC, &pfd ); SetPixelFormat( hDC, iFormat, &pfd ); hRC = wglCreateContext( hDC ); wglMakeCurrent( hDC, hRC ); SetSize(800,600); World = CreateWorld(); BackBuffer = CreateCustomBuffer((byte*)&getSize,(byte*)&makeCurrent); SetBuffer(BackBuffer); glEnable(GL_DEPTH_TEST); } TBuffer LECustomWindow::GetBackBuffer() { return BackBuffer; } int LECustomWindow::GetWidth() { return Width; } int LECustomWindow::GetHeight() { return Height; } void LECustomWindow::Flip() { std::cout<<"FLIP"<<std::endl; SwapBuffers(hDC); } } I know, i got some not really good stuff in the code, but i also had to play around a bit to get it to work.. Quote Link to comment Share on other sites More sharing options...
Sanctus Posted April 26, 2010 Share Posted April 26, 2010 Hey I'm trying to make this work in C# (note that I'm not using any headers). Since I want to create worlds and stuff in C# I only put the actuall OpenGL initialization in a c++ dll. CGLContext::CGLContext(HWND hwnd) { RECT rect; hWnd = hwnd; GetClientRect(hwnd,&rect); hDC = GetDC(hwnd); int depth = 32; PIXELFORMATDESCRIPTOR pfd = {0}; int pixelformat; pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.dwLayerMask = PFD_MAIN_PLANE; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = depth; pfd.cDepthBits = depth; pfd.cAccumBits = 0; pfd.cStencilBits = 0; pixelformat = ChoosePixelFormat(hDC, &pfd); SetPixelFormat(hDC, pixelformat, &pfd); hGLRC = wglCreateContext(hDC); wglMakeCurrent(hDC,hGLRC); glEnable(GL_DEPTH_TEST); width = rect.right -rect.left; height = rect.bottom -rect.top; glViewport(0,0,width,height); currentContext = this; } After this I create the context in C# context = CreateGLContext(this.Handle); backBuffer = LE.CreateCustomBuffer(GetSize, MakeCurrent); I just used a simple LE.RenderWorld(); command and a flip to test if the custombuffer works. Sadly it doesn't and GetSize and MakeCurrent are never called. They are defined like this void _stdcall GetSize(int* width,int* height); void _stdcall MakeCurrent(); and CreateCustomBuffer takes some delegates. I tested and if I manually call GetSize the debugger stops there. Any clues to why this may be? Quote I create the game you play. I create the rulles you will obey. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.