Discussion:
[fpc-pascal] FreeGLUT on Windows
Ryan Joseph
2015-12-24 02:10:52 UTC
Permalink
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 - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pas
Anthony Walter
2015-12-24 05:02:17 UTC
Permalink
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
<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.
Ryan Joseph
2015-12-24 11:03:04 UTC
Permalink
Thanks for all the links I appreciate it; I’ll look over these also and compare them to FreeGLUT for my uses.
Post by Anthony Walter
I recommend SDL 2.0.
https://www.libsdl.org/download-2.0.php
http://github.com/sysrpl/Bare.Game/blob/master/source/bare.interop.sdl2.pas
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.
_______________________________________________
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Regards,
Ryan Joseph

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freep
leledumbo
2015-12-24 05:28:24 UTC
Permalink
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
Post by Ryan Joseph
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.



--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/FreeGLUT-on-Windows-tp5723462p5723464.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/l
Ryan Joseph
2015-12-24 11:02:17 UTC
Permalink
Post by leledumbo
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
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 - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pas
Michalis Kamburelis
2015-12-24 13:42:46 UTC
Permalink
Post by 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.
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 - fpc-***@lists.freepascal.org
http://lists.freepa

Loading...