newLisp and OpenGL

Started by pjot, November 06, 2004, 01:39:17 PM

Previous topic - Next topic

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">http://www.gtk-server.org/glut.jpg



The code is here:

http://www.gtk-server.org/glut.lsp">http://www.gtk-server.org/glut.lsp



You need SDL and GLUT to run.



Enjoy!



Peter

pjot

#1
Now running in Windows as well.



Peter

HPW

#2
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/viewtopic.php?p=2514&highlight=ivrs#2514">http://www.alh.net/newlisp/phpbb/viewto ... =ivrs#2514">http://www.alh.net/newlisp/phpbb/viewtopic.php?p=2514&highlight=ivrs#2514
Hans-Peter

newdep

#3
Flashing !
-- (define? (Cornflakes))

pjot

#4
Hi HPW,



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



Peter

pjot

#5
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

#6
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

#7
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

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



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



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

pjot

#9
Thanx!



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

pjot

#10
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

#11
http://www.sjbaker.org/wiki/index.php?title=The_History_of_The_Teapot">//http://www.sjbaker.org/wiki/index.php?title=The_History_of_The_Teapot
-- (define? (Cornflakes))