Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-12

FreeGLUT on Windows

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

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

Reply by email

Anthony Walter
to Ryan Joseph

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.

Reply by email

leledumbo
to Ryan Joseph: I’m trying to learn some basics of Windows and porting some OpenGL code. The first step…
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.

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 .

Reply by email

Ryan Joseph
to leledumbo
Show quoted text 8 lines
On Dec 24, 2015, at 12:28 PM, leledumbo 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

Reply by email

Ryan Joseph
to Anthony Walter: I recommend SDL 2.0. https://www.libsdl.org/download-2.0.php I have a complete pascal…

Thanks for all the links I appreciate it; I’ll look over these also and compare them to FreeGLUT for my uses.

Show quoted text 25 lines
On Dec 24, 2015, at 12:02 PM, Anthony Walter 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 - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Regards,
Ryan Joseph

Reply by email

Michalis Kamburelis
to Ryan Joseph: I’m trying to learn some basics of Windows and porting some OpenGL code. The first step…
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

Reply by email