OpenGL => GLFW context

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

OpenGL => GLFW context

Post by newdep »

More OpenGL..

GLFW 2.6 context added for OpenGL I/O handling =>
(load "http://www.nodep.nl/downloads/newlisp/glfw.lsp")


GLFW is available for Windows, Mac OS X and Unix-like systems such as Linux, Solaris and FreeBSD.

More to come !
-- (define? (Cornflakes))

m35
Posts: 171
Joined: Wed Feb 14, 2007 12:54 pm
Location: Carifornia

Post by m35 »

Thanks for putting this together. I've recently been working with OpenGL, so this is interesting to see.

Have you tested the multi-threading abilities of the library with newlisp? I can't imagine how that would even work.

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

Post by newdep »

Yes glfw was missing and I like the setup of the code so i though lets
make a context of it..

It seems we can create the thread, but the return of the thread
just kills newlisp..There is probably a something that
cant be catched by newlisp and it "Segment Faults" =>

;; example
(define (handler sig) (println "Signal => " sig) (exit))
(for (s 1 32) (signal s 'handler))

;; example
(load "glfw.lsp")
(glfw:Init)
(define (*hello*) (println "Hello "))
(set 'thread (glfw:CreateThread (address (*hello*)) NULL))
(glfw:WaitThread thread glfw:GLFW_WAIT)
(println "thread!")
(glfw:Terminate)


..After the CreateThread it goes wrong,
the (*hello*) is executed with success
and the Thread returns 1 and newlisp returns a "Seg Fault ;-)"

I cant figure it out but it seems newlisp and glfw dont like this togther..
If I figured it out ill drop a note here..
-- (define? (Cornflakes))

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

Post by newdep »

I think its not going to work..

the first "Hello" is returned because of (address ....) and not
because of the thread.. The Thread though is started and killed
but not as it should.. Mmmm "Out of resources" at the moment ;-)
-- (define? (Cornflakes))

cavva
Posts: 16
Joined: Sun Nov 11, 2007 2:45 am

Post by cavva »

hi newdep,

can you have some example code using glfw?

I'm using newlisp + glfw 2.6 + osx, i've made a little test to see the how "key listener callback" could work, but when i type sometingh the application crash... so i don't understand if i made some mistake ... here is the code:

Code: Select all

(load "glfw.lsp" )
(load "gl.lsp" )

(define (reshape width height) 
	(println "reshape")
)

(define (keypress key action) 
	(println "keypress")
)

(glfw:Init)

(glfw:OpenWindow 640 400 0 0 0 0 16 0 glfw:GLFW_WINDOW)

(glfw:SetWindowTitle "Test Carlo")
(glfw:SetKeyCallback 'keypress )

(while (!= (glfw:GetKey glfw:GLFW_KEY_ESC) glfw:GL_TRUE)
	(begin
		(gl:Clear gl:GL_COLOR_BUFFER_BIT)
		(glfw:SwapBuffers)
	)
)

(glfw:Terminate)

(exit)

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Perhaps you are not using 'glfw:SetKeyCallback' correctly. newLISP has a function 'callback' which probably should be used here. Try this:

Code: Select all

(glfw:SetKeyCallback (callback 1 'keypress))
here is example code using OpenGL and GLUT for registering callbacks:

http://www.newlisp.org/syntax.cgi?downl ... mo-lsp.txt

it works well on Mac OS X (Intel processor required) with nothing additional to be installed and works with the GLUT Framework for handling input and window handling.

Using GLFW it will work in a similar fashion.

Ryon
Posts: 248
Joined: Thu Sep 26, 2002 12:57 am

Post by Ryon »

If anyone has trouble running the above example under Ubuntu, check this bug report. I solved the problem by removing xorg-driver-fglrx.

cavva
Posts: 16
Joined: Sun Nov 11, 2007 2:45 am

Post by cavva »

Lutz, with 'callback all works great !!
Lutz wrote:
here is example code using OpenGL and GLUT for registering callbacks:

http://www.newlisp.org/syntax.cgi?downl ... mo-lsp.txt

it works well on Mac OS X (Intel processor required) with nothing additional to be installed and works with the GLUT Framework for handling input and window handling.
I know that GLUT is on most platform, but reading some tutorials all says it's only for basic demos, so i've choosen another lib (without knowing if glut fame was real )...

the first was SDL, but on Mac osx the lib need to istantiate a NSAutoreleasePool obj, and i don't have the knowledge required for it

so my second try was GLFW, it's small, simple, portble and written in Carbon... it was love at first sight :)

Locked