Sign in to follow this  
vince35

new AA, same textures

Recommended Posts

I tried looking on the web for wglShareLists, but it's very poorly documented, and I didn't any sample code on how to use it.

Here is what I currently do to create my window.



// create temp window
WNDCLASS wc;
RegisterClass(&wc);
AdjustWindowRectEx(&WindowRect, dwstyle, FALSE, dwExstyle);
CreateWindowEx(...);
hDC=GetDC(hWnd);
PixelFormat=ChoosePixelFormat(hDC,&pfd);
SetPixelFormat(hDC,PixelFormat,&pfd);
hRC=wglCreateContext(hDC);
wglMakeCurrent(hDC,hRC);

// Initalize multisampling
HDC hDC2 = GetDC(hWnd);
PixelFormat = wglChoosePixelFormatARB(hDC2,iAttributes,fAttributes,1,&pixelFormat,&numFormats);
wglMakeCurrent(NULL,NULL);

// Delete temp window
wglDeleteContext(hRC);
ReleaseDC(hWnd,hDC);
DestroyWindow(hWnd);
UnregisterClass(_T("OpenGL"),hInstance);

// Create multisample window
RegisterClass(&wc);
AdjustWindowRectEx(&WindowRect, dwstyle, FALSE, dwExstyle);
hWnd=CreateWindowEx(...);
hDC=GetDC(hWnd);
SetPixelFormat(hDC,PixelFormat,&pfd);
hRC=wglCreateContext(hDC);
wglMakeCurrent(hDC,hRC);

ShowWindow(hWnd,SW_SHOW);

{...}

load textures
render scene


How Do I modify it if I want later on to change the number of samples in my multisampling? I know I have to redo the sections "Delete temp window" and "Create multisample window", but how do I use wglShareLists in this to make sure my textures and shaders aren't destroyed with my old window?

Thanks.

Share this post


Link to post
Share on other sites
I have never done it myself but the idea is to create another window that you will not destroy. Setup GL on that window.
Call wglShareLists(firstGLcontext, secondGLContext);

Now if you kill your main window and recreate a new one, call wglShareLists again.

I forget if it is the other way around
wglShareLists(secondGLContext, firstGLcontext);

since it could have an effect whether the function succeeds or not.

I have only used wglShareLists when I needed multiple windows open so I called it as soon as I created all the windows, before I allocated any GL resources like textures.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this