Skip to main content
GameDev.net gamedev.net
🔒 Locked

Windowing functionality

Started by vertexShaded May 26, 2009 at 11:32 PM 4 replies 650+ views
Original Post
vertexShaded
vertexShaded
Hi, I've started learning OpenGL and I've noticed how all books stress the fact that opengl doesn't provide windowing support since that feature is platform specific. Well, I've been wondering, when I set up opengl, I download .lib and .dll files that are meant for usage with windows only(there are separate files for macs). The binaries compiled using these libraries will run only on windows. Doesn't this mean that opengl is platform specific in a way, anyway? Why not add windowing functionality to it as well and let each implementation handle it for its own platform? Regards, vertexShaded
Brother Bob
Brother Bob
OpenGL is only for rendering graphics to a buffer, nothing more. Anything else around that, like setting up the render buffers and environment, is up to the platform to provide. This is, in fact, a platform independent way of doing it by keeping OpenGL's responsibility very narrow.

The more you add to a platform independent API, the more have to think about how it will be implemented. If you add a windowing interface to OpenGL, the windowing interface must be designed such that it doesn't use features exclusive to a single platform. You need to aim for the lowers common denominator for each target platform, and that is not just a handful of platforms in the case of OpenGL.

Once you've added windowing, you've tied yourself to input as well. Mouse and keyboard at least. And again, you cannot design the API to require platform specific solutions. And you still have other input solutions to handle for games, like joysticks, wheels and game pads, or perhaps trackballs. And then there's audio; add to OpenGL or stick with platform specific solution? When you aim for the lowers common denominator, there are people that needs the platform specific features not exposed. They are required to implement the platform libraries anyway.

Does all this make OpenGL platform independent? Yes, it is what makes it platform independent. Note here, the OpenGL code is platform independent. That is as far as OpenGL can guarantee. OpenGL cannot guarantee that your other parts are platform independent. So you need to create a rendering target, and that is up to the platform to provide, and each platform will require different code to set up the rendering target. Just like different platform plays audio differently, and how inputs are handled differently.
Lord_Evil
Lord_Evil
A DLL does not necessarily have to be platform specific. With mono you can use .Net DLLs on mac and linux as well.

And there are toolkits like GLUT that provide the cross-platform windowing/input functionality for OpenGL. However, it restricts you to their perception of a lowers common denominator so it's not usefull for everyone (e.g. people who want finer control over windowing and input - like me [grin]).
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
V-man
V-man
Quote:
Original post by Lord_Evil
A DLL does not necessarily have to be platform specific. With mono you can use .Net DLLs on mac and linux as well.

And there are toolkits like GLUT that provide the cross-platform windowing/input functionality for OpenGL. However, it restricts you to their perception of a lowers common denominator so it's not usefull for everyone (e.g. people who want finer control over windowing and input - like me [grin]).


I think he is talking about opengl32.dll and opengl32.lib.
You should never download opengl32.dll since this is part of Windows. It is a system file.

As for platform independent, there are many ways to achieve it. For C and C++ users, SDL or freeGLUT or openGLUT for handling windowing and input.
For Java users, things are already built in.
C#....well this is basically the same concept as Java.

Keep in mind that OpenGL's focus is 3D graphics. It doesn't load image files (png, bmp, jpg), it doesn't load model files (md2, md3, 3ds), it doesn't load sound files, it doesn't optimize your scene for you. It is a low level library for 3D graphics.

Quite a lot of programmers should not use OpenGL. There are ready made engines like Ogre3D, Crytalspace, Irclicht.
vertexShaded
vertexShaded
I understand that opengl as it is, is independent of the platform its running on. Then why is it necessary to include windows.h before gl.h or glu.h?
Brother Bob
Brother Bob
Because the implementation of OpenGL that you use, Microsoft's, require things that is defined in windows.h. Now, it's only a few names you can defined manually and get rid of windows.h, but they are still defined in windows.h and is the intended way to define the names.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.