FreeGLUT on Windows

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

FreeGLUT on Windows

Ryan Joseph
I’m trying to learn some basics of Windows and porting some OpenGL code. The first step is getting an OpenGL context prepared but I’m already stuck here.

1) GLUT is long dead it looks like and I probably shouldn’t be using it since there’s no official .dll available except from dodgy looking download sites.

2) There is a FreeGLUT package which it looks like FPC supports and I was able to find the units and download a recent .dll but it complains about missing symbols unless I add the glut unit which then attempts to load the glut32.dll and fails.

3) In the Lazarus directory there is a OpenGLControl demo which looks like it makes an OpenGL context but I don’t know anything about that API and forms etc… so I thought starting simple with FreeGLUT makes the most sense (if possible).

Does anyone have a working example of how to run a glut program with FreeGLUT or should I just take the higher learning curve route and break down the OpenGLControl demo and use TOpenGLControl?

Thanks.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FreeGLUT on Windows

Anthony Walter-3
I recommend SDL 2.0.


I have a complete pascal source code declaration of  it here:


I also have an object orient wrapper if you want to get straight into OpenGL:

immediate mode cube

sprites and sounds using wrappers for OpenGL code

an older overview video (it no longer installs Lazarus, instead you use install an lpk)

The new version uses OpenGL ES2.0, and has support for an OpenVG context if users prefer a much easier to work with 2D API.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FreeGLUT on Windows

leledumbo
Administrator
In reply to this post by Ryan Joseph
> There is a FreeGLUT package which it looks like FPC supports and I was able to find the units and download a recent .dll but it complains about missing symbols unless I add the glut unit which then attempts to load the glut32.dll and fails

FreeGLUT is a drop-in replacement for GLUT (well, minus some behavior difference which is documented in their website), so any GLUT program should work on FreeGLUT. The Pascal wrapper, however, is not the same glut32 unit because it links to different dll and FreeGLUT has its own extension so it deserves its own unit, which has been in FPC since 2.4.4: http://svn.freepascal.org/svn/fpc/tags/release_2_4_4/packages/opengl/src/freeglut.pp

> In the Lazarus directory there is a OpenGLControl demo which looks like it makes an OpenGL context but I don’t know anything about that API and forms etc… so I thought starting simple with FreeGLUT makes the most sense (if possible).

Study the demo. Everything makes sense once you start figuring things out either by studying demo or even the source itself. It's no different than just another windowing context creation helper with standard event driven approach that Lazarus does normally.
Reply | Threaded
Open this post in threaded view
|

Re: FreeGLUT on Windows

Ryan Joseph

> On Dec 24, 2015, at 12:28 PM, leledumbo <[hidden email]> wrote:
>
> FreeGLUT is a drop-in replacement for GLUT (well, minus some behavior
> difference which is documented in their website), so any GLUT program should
> work on FreeGLUT. The Pascal wrapper, however, is not the same glut32 unit
> because it links to different dll and FreeGLUT has its own extension so it
> deserves its own unit, which has been in FPC since 2.4.4:
> http://svn.freepascal.org/svn/fpc/tags/release_2_4_4/packages/opengl/src/freeglut.pp

If it's a drop in replacement why do I get compiler errors that functions like glutInitWindowPosition are not declared?

There’s the units from the example program I started from:

{$mode objfpc}{$H+}
program firstprogram;
uses
  gl, glu, freeglut, sysutils, dynlibs;    

And then I’m trying to load the .dll like this:

 LoadFreeGlut(LoadLibrary('/freeglut/bin/freeglut.dll'));

Did I miss something?

Thanks.

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FreeGLUT on Windows

Ryan Joseph
In reply to this post by Anthony Walter-3
Thanks for all the links I appreciate it; I’ll look over these also and compare them to FreeGLUT for my uses.

> On Dec 24, 2015, at 12:02 PM, Anthony Walter <[hidden email]> wrote:
>
> I recommend SDL 2.0.
>
> https://www.libsdl.org/download-2.0.php
>
> I have a complete pascal source code declaration of  it here:
>
> http://github.com/sysrpl/Bare.Game/blob/master/source/bare.interop.sdl2.pas
>
> I also have an object orient wrapper if you want to get straight into OpenGL:
>
> immediate mode cube
> http://www.getlazarus.org/videos/barecube/
>
> sprites and sounds using wrappers for OpenGL code
> http://www.getlazarus.org/videos/baresprites/
>
> an older overview video (it no longer installs Lazarus, instead you use install an lpk)
> http://cache.getlazarus.org/videos/bare-game.mp4
>
> The new version uses OpenGL ES2.0, and has support for an OpenVG context if users prefer a much easier to work with 2D API.
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FreeGLUT on Windows

Michalis Kamburelis-3
In reply to this post by Ryan Joseph
Ryan Joseph wrote:
> I’m trying to learn some basics of Windows and porting some OpenGL
> code. The first step is getting an OpenGL context prepared but I’m
> already stuck here.
>

I would recommend our Castle Game Engine
http://castle-engine.sourceforge.net/ . It can be used together with
Lazarus form (as TCastleControl, descendant from Lazarus TOpenGLControl).

Or you can use CastleWindow unit, which gives you a window with OpenGL
context, without any Lazarus/LCL dependencies. It includes TCastleWindow
class, which is kind of "modern and object-oriented GLUT". It works on
Linux, Windows, Mac OS X, Android, iOS...

You can use there high-level Castle Game Engine features for 2D and 3D
rendering, but you can also write your own direct OpenGL calls in
TCastlewindow.OnRender, OnOpen, OnClose and such callbacks.

Regards,
Michalis
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal