Updated OpenGL headers

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Updated OpenGL headers

Postby pestery » Oct 04, 2011 14:06

Hi guys. I've ported gl.h, glu.h and glext.h to FreeBASIC.

The gl.h and glu.h (and the lib*.a files) I borrowed from the MinGW build that comes with CodeBlocks because I couldn't find any more recent versions. I think they're much the same as the current FB files so if you don't used them then no harm done.

The glext.h I got from the OpenGL website and its very up-to-data (last updated 02 Oct 2011). It has lots of new functions and so forth :-)

If you find any errors let me know.
http://www.mediafire.com/download.php?4d0m2yv53n68lhr

Edit: Includes GLFW and freeGLUT
Last edited by pestery on Jan 25, 2012 1:20, edited 8 times in total.
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Postby pestery » Oct 05, 2011 12:53

I've added an updated version of GLFW to the zip file, and updated the link.
dkl
Site Admin
Posts: 3205
Joined: Jul 28, 2005 14:45
Location: Germany

Postby dkl » Oct 05, 2011 23:09

Well done, the headers are looking good. As for the libraries, FB will also use the MinGW ones, so that should be fine. I'm not 100% sure on how precompiled libraries like libglfw.a should be handled in general, but at least in this case it seems to make sense to just include it along with the headers for win32.
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Postby pestery » Oct 06, 2011 4:11

I was going to update the GLUT library, but the version I got from the website seems to be older than the one currently included with FB.

If FB:
#define GLUT_API_VERSION 3
#define GLUT_XLIB_IMPLEMENTATION 15

From the website:
#define GLUT_API_VERSION 3
#define GLUT_XLIB_IMPLEMENTATION 13

Does anyone know the current state of development of GLUT? From a quick read on the net it seemed to me that GLUT has stalled.

Anyway, on another note. I'm thinking of porting OpenGL Mathematics (GLM) library, although it's quite large so it might take a while. The website is http://glm.g-truc.net/
OpenGL Mathematics (GLM) is a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specification.
TJF
Posts: 3456
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Postby TJF » Oct 06, 2011 9:03

Hello pestery, thanks for your work on OgenGl.

I didn't test your headers, just had a short look at the source. I recommend to remove the alias statements by using an EXTERN block:

Code: Select all

EXTERN "C"

DECLARE SUB ...

END EXTERN

It shortens the code and makes compiling faster.

BTW:
pestery wrote:Does anyone know the current state of development of GLUT?

Isn't GLUT replaced by freeglut?
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Postby pestery » Oct 06, 2011 10:45

Thanks TJF. freeGLUT has its last stable release in 2009 and looks newer than the GLUT headers I was looking at before. Although there didn't seem to be a binary download for Windows. I've downloaded the source, but it won't compile (undefined reference to a heap of OpenGL functions). It might be my platform that's causing the trouble. Anyway, without having a lib*.a file for Windows I can't test anything I port.

Is anyone using GLUT in their projects? I'm not, but I thought that as I was porting the rest of the OpenGL header I might as well do GLUT too.

Also, using Extern "C" ... End Extern instead of Alias doesn't work. I just tried it. I just get undefined reference to everything. I think it might be because FB is not case sensitive, but I'm not sure.
podvornyak
Posts: 148
Joined: Nov 12, 2007 11:46
Location: Russia

Postby podvornyak » Oct 06, 2011 11:27

Maybe here http://www.transmissionzero.co.uk/softw ... lut-devel/ you find what you need... As i know freeglut is nix only. And glut gone in history couse of opengl going farther and farther. Version 4.1 now, and got glut utility inside...
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Postby pestery » Oct 06, 2011 12:32

Cool. Thanks podvornyak, that's exactly what I need.
TJF
Posts: 3456
Joined: Dec 06, 2009 22:27
Location: N47°, E15°

Postby TJF » Oct 06, 2011 16:48

pestery wrote:Also, using Extern "C" ... End Extern instead of Alias doesn't work. I just tried it. I just get undefined reference to everything. I think it might be because FB is not case sensitive, but I'm not sure.

You should check this again. In the original FB headers and in my headers it works perfect.

By default FB exports the SUB/FUNCTION names in capital letters. When using EXTERN "C" then names are exported as in the source.
Wiki wrote:Extern "C" blocks provide a default cdecl calling convention to procedures, and also preserve the case of all names declared within them. The same effect can be achieved without the EXTERN block by using cdecl together with an Alias string containing the exact procedure name.
dkl
Site Admin
Posts: 3205
Joined: Jul 28, 2005 14:45
Location: Germany

Postby dkl » Oct 06, 2011 23:11

Be careful not to use CDECL when the API is using STDCALL. FreeBASIC on Windows defaults to STDCALL, but if you use EXTERN "C" the default inside of the block will be CDECL. The linking errors might be the result of the API using STDCALL with @N suffixes on function names, while your EXTERN "C" would not add those suffixes.

You know, perhaps we should add an EXTERN block that just preserves the name but doesn't change the default calling convention. ALIAS ... END ALIAS?
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Postby pestery » Oct 07, 2011 0:59

@dkk
Maybe Extern "Alias" ... End Extern? Also, if Windows defaults to STDCALL, what does Linux default too?

@TJF
I did check that it worked before I posted it :-)
But I've checked again, and using Extern "Windows" ... End Extern without Alias works. Would it also work on Linux? I don't have a dual boot going at the moment so I can't test it.
dkl
Site Admin
Posts: 3205
Joined: Jul 28, 2005 14:45
Location: Germany

Postby dkl » Oct 07, 2011 5:26

Extern "Alias" perhaps, that might work too. Linux/*BSD (and also DOS) default to CDECL. It could work to do something like this:

Code: Select all

#if defined(__FB_WIN32__) or defined(__FB_CYGWIN__)
extern "windows"
#elseif defined(__FB_UNIX__)
extern "c"
#endif

...

end extern


It depends on what's used by the GL API on each platform.
sir_mud
Posts: 1401
Joined: Jul 29, 2006 3:00
Location: US
Contact:

Postby sir_mud » Oct 07, 2011 9:14

Seems like some libraries for windows with some compilers use stdcall but don't decorate the names with @ and a number, so if you get a bunch of undefined references using extern "windows" change it to extern "windows-ms".
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Postby pestery » Oct 09, 2011 1:33

I've ported the freeGLUT library, but I have a quick question before I port it. There are a number of functions that pass function pointers to the library, for use as callback functions. Should I Cdecl the function pointer? I only ask because that's what the current FB GLUT library does.

Code: Select all

Declare Function glutCreateMenu(ByVal callback As Sub(ByVal menu As Integer)) As Integer
Declare Function glutCreateMenu(ByVal callback As Sub Cdecl(ByVal menu As Integer)) As Integer

Also, I mentioned that I was thinking of porting the GLM library. After having a good long look at it I think its beyond my skill level. I don't know enough C++ to translate it (in full) to FB.
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Postby pestery » Oct 09, 2011 2:57

I've updated the original link again. I've added the freeGLUT headers. I've also removed the Alias from the function declarations and instead added Extern "foo" ... End Extern.

Can someone test these headers on Linux. Remember to backup your original files if you replace them, just in case.

Regarding the freeGLUT library, it has the option of a dynamic or static linkage. I've included the requirements for both, but I can't get the static version to work. Maybe someone has some ideas...? The dynamic version works fine.

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 1 guest