newLisp and OpenGL

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE
Locked
pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

newLisp and OpenGL

Post by pjot »

The previous discussion about floats was needed to create a nice OpenGL demo program. It contains the good old Utah teapot, spinning around the x and y axis.

A screenshot can be found here:
http://www.gtk-server.org/glut.jpg

The code is here:
http://www.gtk-server.org/glut.lsp

You need SDL and GLUT to run.

Enjoy!

Peter

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Now running in Windows as well.

Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Thanks Peter for the demo!

It tested it on WIN/XP and it runs fine. But you are not allowed to
click or move the window, then it hang up.

An improvment for the demo would be to be able to rotate the teapot with the mouse, like other openGL-examples.

Similar to the snowman example from iVRS:
http://www.alh.net/newlisp/phpbb/viewto ... =ivrs#2514
Hans-Peter

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Flashing !
-- (define? (Cornflakes))

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Hi HPW,

You are right, I will look into it today. Any improvements I will notify here.

Peter

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Hi HPW,

The demo is improved:

1) Clicking on the "CLOSE" cross in the upper-right will exit the demo gracefully;
2) Clicking anywhere else on the screen will inverse the rotation.

Maybe not completely the same as your program, but nevertheless, the code shows how to handle events.

Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Thanks Peter for the improvments.

Seems to offer some great possibilitys.
And better than IVRS is, that it is multi-platform.
Maybe worth some deeper look.
Hans-Peter

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Well, it shouldn't be too difficult changing the mouseactions. But it's only a demo... ;-)

First I thought to port the complete GLUT library, but since GLUT relies on callback mechanisms heavily, this was not possible. This is the only reason why SDL is needed: to setup a screen.

I guess the combination SDL+OpenGL (GLU, GLUT) will work very good with newLisp. Almost all GLU and GL functions can be ported. Maybe a standard .lsp file can be created with all GL constants and functions. It should not be difficult to create a newLisp library with some standard defined functions to draw GL graphics. GLUT also contains GUI functions for OpenGL, like drawing text and adding menustructures to an OpenGL image.

Next days I will look into it further, to explore the possibilities.

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

With this modification I used it also successfully from newLISP.DLL called from neobook:

Code: Select all

; Determine which library to use first.
(if (or(=(last (sys-info))6)(=(last (sys-info))70))

Code: Select all

; Exit newLisp
(if (!=(last (sys-info))70)
 (exit))
Hans-Peter

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Thanx!

In the meantime I figured out out to draw OpenGL text on the canvas. Uploaded an updated version + screenshot.

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Hi Hans-Peter!

I couldn't let go your challenge... :-) Now the teapot can be rotated using the mouse. Keep the left button pressed and move, you'll see what happens. If you have a mousewheel, it is possible to zoom in and out also. This way the demo behaves like an OpenGL viewer. Finally, the GLUT Stroked Fonts work (but they are ugly!).

This concludes the OpenGL demo for me. I will concentrate on a more generic OpenGL/SDL project with newLisp... :-)

Cheers & enjoy,

Peter

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

-- (define? (Cornflakes))

Locked