PDA

View Full Version : GLUT still runs when user closes window



cronodragon
14-11-2007, 01:56 AM
How can I detect when a user have closed a window created with GLUT? Otherwise GLUT will keep working in the background. Is there any multiplatform solution? :S

Thanks in advance! :D

Robert Kosek
14-11-2007, 02:55 AM
I took the code from Phoenix as a working example. Here's what you need:
glfwGetWindowParam(GLFW_OPENED) = 1Or:
repeat
// Main loop here..
until glfwGetWindowParam&#40;GLFW_OPENED&#41; <> 1;

waran
14-11-2007, 03:56 AM
Annother solution would be SimpleDirectmediaLayer (SDL)
-> www.libsdl.org

cronodragon
14-11-2007, 04:14 AM
Robert, that paramether is very helpful, thanks! About the second code, I had the idea it was not possible to use your own loop, instead GLUT requires using its events... how do you initialize GLUT to run your own loop?

waran, I'm trying not to use SDL, it would be another library to learn and integrate and I have had enough with DX and GLUT :P

Thanks!

cronodragon
14-11-2007, 02:53 PM
Hey, FPC can't find the glfwGetWindowParam() function. I placed gl, glu and glut in the uses clause. In which unit is it located? :?

Robert Kosek
14-11-2007, 03:03 PM
The unit you need is glfw and I think it's a default in the distribution of FPC. Else you can get it here (http://glfw.sourceforge.net). And basically from there all you do is event snoop. ;) Try looking at Phoenix's (http://www.phoenixlib.net/) phxScreen unit for insights into how Andreaz does it; best method I've seen yet and MPL licensed (free for commercial use). Or you could always make your own unit to handle the window management.

JSoftware
14-11-2007, 05:14 PM
Robert, glfw can't be used since cronodragon probably uses glut for window management

Cronodragon, instead of using glut then use glfw. I find it to be far easier to work with

cronodragon
14-11-2007, 05:29 PM
Oh ok, thanks! GLFW looks so cool, I'm checking the reference. It also allows threads, that's what I wanted in the first place! :D

cronodragon
15-11-2007, 02:42 AM
Does someone have glfw.dll? The download doesn't bring it, I don't know how to compile it (seems to require some sort of C compiler), and I can't find one that works in Internet :cry:

Robert Kosek
15-11-2007, 03:07 AM
Lessee if mine works for you. This DLL is for the 2.5 API version, so I included the same version header unit just in case it differs from the latest. :)

http://thewickedflea.freepgs.com/glfw.zip

cronodragon
15-11-2007, 03:20 AM
Hey, thanks a lot! :D

Reading the reference, I have one question: is it possible to handle more than one window? I see those functions don't have a window handler. Or is there a future plan to implement that feature?

EDIT: Something else, is it possible to compile apps with GLFW in Lazarus/FPC on Linux? I only see Delphi listed.

Robert Kosek
15-11-2007, 03:28 AM
I have absolutely no idea. After a quick browse through of the header I'm pretty sure it's a single window interface at the present time. As for future plans I am not "in the know," as it is called. ;)

cronodragon
15-11-2007, 03:29 AM
Something else, is it possible to compile apps with GLFW in Lazarus/FPC on Linux? I only see Delphi listed.

Robert Kosek
15-11-2007, 03:42 AM
Phoenix uses GLFW for window management and is fully Lazarus/FPC compatible. :)

cronodragon
15-11-2007, 03:35 PM
I see Phoenix also uses dglOpenGL... what is it? :D

Robert Kosek
15-11-2007, 03:48 PM
dglOpenGL are the headers from DelphiGL.com (http://www.delphigl.com/), and in this case they're the headers for OpenGL 2.0. :D The default Delphi header I think is either 1.1 or 1.5; so DGL is one of the latest and greatest.

Andreaz
16-11-2007, 06:42 AM
I see Phoenix also uses dglOpenGL... what is it? :D

From the dglOpenGL.pas unit:

OpenGL 2.0 - Headertranslation (includes GL 1.1 - 2.0)

cronodragon
22-11-2007, 12:33 AM
I'm using GLFW in Lazarus/Linux, and I get this error:

/usr/bin/ld: cannot find -lglfw.dll

Where can I find that file, I checked the other .dll of GLFW and it isn't there.

Thanks!

technomage
22-11-2007, 10:39 AM
glfw.dll definately will not exist under linux, if it is available it will probably be called something like libglfw.so. You will have to update your header files to use that name. You will also need to make sure that libglfw.so is installed as well.

cronodragon
22-11-2007, 03:27 PM
Oh, I see there is a make file to install the library. I'll try it when I get home, thanks!

cronodragon
22-11-2007, 03:37 PM
Lessee if mine works for you. This DLL is for the 2.5 API version, so I included the same version header unit just in case it differs from the latest. :)

http://thewickedflea.freepgs.com/glfw.zip

One question, is that DLL a translation of the library from C to Delphi, and recompiled with Delphi? I don't understand why none the DLLs provided in the GLFW website work with Delphi applications, since those are supposed to be win32 libraries. :?

cronodragon
23-11-2007, 01:48 AM
I found this:


Can't get OpenGL apps to work in Linux

Notify me of responses

I am unable to run any OpenGL applications on RedHat9, the cause might
be GLUT, when i run any FPC or Kylix compiled project that uses GLUT
they display an error about X.. function. I don't have any apps that
use OpenGL directly. I adapted the GLFW unit from
http://glfw.sourceforge.net/ to be crossplatform and i was able to run
GL progs on windows but not on linux, i also linked the C code to so.
I would appreciate some help in running OpenGL apps on Linux.
The C/C++ based examples also Quake 3 run verry well.
-- Razvan Adrian Bogdan, 08 septiembre 2004 16:10 (email)


Answers:


I had the same problem. I tried to use GLUT but it didn't work. Then I tried to use GLX but it didn't work neither. Now, I'm using SDL and this works verry well. SDL is a libery wich can be used to set up an OpenGL window. SDL is available for many platforms. If you want to use it in FreePascal, you can use the Jedi-SDL headers.
-- Bart Tierens, 12 septiembre 2004 12:38

http://community.freepascal.org:10000/bboards/message?message_id=151460&forum_id=24083

So it seems, after all, that I'll have to give a try to SDL, since GLFW is not available for FPC on Linux at the moment. Another dead-end :lol:

Robert Kosek
23-11-2007, 03:01 PM
Wha? Rats. Their website is out of date then, since it claims to be cross platform. Oh well.

cronodragon
23-11-2007, 03:48 PM
It's cross-platform, yes... but that's for C, not for Pascal at the moment.

I think what's missing are FPC's headers, because the headers provided by the GLFW team are based on a DLL, which won't work on Linux AFAIK. Someone should write or modify the headers to work with Linux libraries. I would do it, but I'm just a newbie at FPC and Linux.

Robert Kosek
23-11-2007, 04:09 PM
I would do it, but I'm just a newbie at FPC and Linux.Ditto, and I don't have access to a Linux PC anymore to boot.

cronodragon
23-11-2007, 04:53 PM
I'm using vmware workstation to run Ubuntu Linux on my Windows XP. It's very easy to configure and runs very well. :D