1. Still having OpenGL problems

I have two code snippets here, the first in Euphoria the second in C++.  The
Euphoria code fails to unregister the window class, the C++ works.  Can anybody
spot my error in the Euphoria code?

--Euphoria procedure--
procedure KillGLWindow() 

    if fullscreen then
        if c_func(ChangeDisplaySettingsA,{NULL,0}) then end if
        if c_func(ShowCursor,{TRUE}) then end if
    end if

    if hRC then
        if c_func(wglMakeCurrent,{NULL,NULL}) then end if
        if c_func(wglDeleteContext,{hRC}) then end if
        hRC = NULL
    end if

    if hRC and not c_func(ReleaseDC,{hWnd,hDC}) then
        hDC = NULL
    end if

    if hWnd and not c_func(DestroyWindow,{hWnd}) then
        hWnd = NULL
    end if

    if not c_func(UnregisterClassA,{ClassName,hInstance}) then
        hInstance = NULL
    end if

end procedure

//C++ function
GLvoid KillGLWindow(GLvoid)
{
	if (fullscreen)
	{
		ChangeDisplaySettings(NULL,0);
		ShowCursor(TRUE);
	}

	if (hRC)
	{
		if (wglMakeCurrent(NULL,NULL))
		if (wglDeleteContext(hRC))
		hRC = NULL;
	}

	if (hDC && !ReleaseDC(hWnd,hDC))
	     hDC = NULL;

	if (hWnd && !DestroyWindow(hWnd))
	     hWnd = NULL;

	if (!UnregisterClass("OpenGL",hInstance))
	     hInstance = NULL;
}

new topic     » topic index » view message » categorize

2. Re: Still having OpenGL problems

I made an opengl demo for win32lib, go look at it, it might help.

Daniel Kluss
----- Original Message ----- 
From: <1evan at sbcglobal.net>
To: "EUforum" <EUforum at topica.com>
Subject: Still having OpenGL problems


>
>
> I have two code snippets here, the first in Euphoria the second in C++.
The Euphoria code fails to unregister the window class, the C++ works.  Can
anybody spot my error in the Euphoria code?
>
> --Euphoria procedure--
> procedure KillGLWindow()
>
>     if fullscreen then
>         if c_func(ChangeDisplaySettingsA,{NULL,0}) then end if
>         if c_func(ShowCursor,{TRUE}) then end if
>     end if
>
>     if hRC then
>         if c_func(wglMakeCurrent,{NULL,NULL}) then end if
>         if c_func(wglDeleteContext,{hRC}) then end if
>         hRC = NULL
>     end if
>
>     if hRC and not c_func(ReleaseDC,{hWnd,hDC}) then
>         hDC = NULL
>     end if
>
>     if hWnd and not c_func(DestroyWindow,{hWnd}) then
>         hWnd = NULL
>     end if
>
>     if not c_func(UnregisterClassA,{ClassName,hInstance}) then
>         hInstance = NULL
>     end if
>
> end procedure
>
> //C++ function
> GLvoid KillGLWindow(GLvoid)
> {
> if (fullscreen)
> {
> ChangeDisplaySettings(NULL,0);
> ShowCursor(TRUE);
> }
>
> if (hRC)
> {
> if (wglMakeCurrent(NULL,NULL))
> if (wglDeleteContext(hRC))
> hRC = NULL;
> }
>
> if (hDC && !ReleaseDC(hWnd,hDC))
>      hDC = NULL;
>
> if (hWnd && !DestroyWindow(hWnd))
>      hWnd = NULL;
>
> if (!UnregisterClass("OpenGL",hInstance))
>      hInstance = NULL;
> }
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

new topic     » goto parent     » topic index » view message » categorize

3. Re: Still having OpenGL problems

Eureka!  I was linking to the wrong function for DestroyWindow.  I had 
GetDC in there.

xerox_irs at lvcm.com wrote:

>
>
>I made an opengl demo for win32lib, go look at it, it might help.
>
>Daniel Kluss
>----- Original Message ----- 
>From: <1evan at sbcglobal.net>
>To: "EUforum" <EUforum at topica.com>
>Sent: Tuesday, May 27, 2003 6:17 AM
>Subject: Still having OpenGL problems
>
>
>>I have two code snippets here, the first in Euphoria the second in C++.
>>    
>>
>The Euphoria code fails to unregister the window class, the C++ works.  Can
>anybody spot my error in the Euphoria code?
>  
>
>>--Euphoria procedure--
>>procedure KillGLWindow()
>>
>>    if fullscreen then
>>        if c_func(ChangeDisplaySettingsA,{NULL,0}) then end if
>>        if c_func(ShowCursor,{TRUE}) then end if
>>    end if
>>
>>    if hRC then
>>        if c_func(wglMakeCurrent,{NULL,NULL}) then end if
>>        if c_func(wglDeleteContext,{hRC}) then end if
>>        hRC = NULL
>>    end if
>>
>>    if hRC and not c_func(ReleaseDC,{hWnd,hDC}) then
>>        hDC = NULL
>>    end if
>>
>>    if hWnd and not c_func(DestroyWindow,{hWnd}) then
>>        hWnd = NULL
>>    end if
>>
>>    if not c_func(UnregisterClassA,{ClassName,hInstance}) then
>>        hInstance = NULL
>>    end if
>>
>>end procedure
>>
>>//C++ function
>>GLvoid KillGLWindow(GLvoid)
>>{
>>if (fullscreen)
>>{
>>ChangeDisplaySettings(NULL,0);
>>ShowCursor(TRUE);
>>}
>>
>>if (hRC)
>>{
>>if (wglMakeCurrent(NULL,NULL))
>>if (wglDeleteContext(hRC))
>>hRC = NULL;
>>}
>>
>>if (hDC && !ReleaseDC(hWnd,hDC))
>>     hDC = NULL;
>>
>>if (hWnd && !DestroyWindow(hWnd))
>>     hWnd = NULL;
>>
>>if (!UnregisterClass("OpenGL",hInstance))
>>     hInstance = NULL;
>>}
>>
>>
>>TOPICA - Start your own email discussion group. FREE!
>>
>>
>
>
>TOPICA - Start your own email discussion group. FREE!
>
>

-- 
     |\      _,,,---,,_
    /,`.-'`'    -.  ;-;;,_
   |,4-  ) )-,_..;\ (  `'-'
  '---''(_/--'  `-'\_)`-'\_)

new topic     » goto parent     » topic index » view message » categorize

4. Re: Still having OpenGL problems

Though you don't really need UnregisterClass:

"All window classes that an application registers are unregistered when it 
terminates. "

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu