Using OpenGL without the Croquet layer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Using OpenGL without the Croquet layer

Max Melzer-2
Hi there,
I've been wondering about this for a quite long time now: Is there any
way of just using the OpenGL part of Croquet without the Croquet layer
(TSphere etc.)?
I'm really interested in learning OpenGL programming and I like
Smalltalk and Squeak very much, but until now all my experiments in this
direction failed.
( If there is a way it will probably include the usage of a simple
window surrounding the OpenGL output - any help with this would also be
greatly appreciated )


With best regards
Max Melzer
Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

David P. Reed
Two approaches, but you will have to invest some time exploring (reading code):

1. You can study the Croquet initialization code, create your own rendering environment, and use the OpenGL primitives directly.   All of OpenGL is there in the Squeak world.   If you just want to render static images and learn the OpenGL drawing tools, this is the right approach.

2. If you want to start out with a rendering environment that includes scheduling, ... there is no reason not to build your own classes that draw themselves into the Croquet world using the raw OpenGL primitives directly.   Look into the code of TSphere or any other simple class, and study how it draws itself.   Then just write your own Txxx class by subclassing, using the primitive openGL calls to render it. 

Max Melzer wrote:
Hi there,
I've been wondering about this for a quite long time now: Is there any way of just using the OpenGL part of Croquet without the Croquet layer (TSphere etc.)?
I'm really interested in learning OpenGL programming and I like Smalltalk and Squeak very much, but until now all my experiments in this direction failed.
( If there is a way it will probably include the usage of a simple window surrounding the OpenGL output - any help with this would also be greatly appreciated )


With best regards
Max Melzer

Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Paul Trattle - DWP
In reply to this post by Max Melzer-2
Hi there,
I've been wondering about this for a quite long time now: Is there any
way of just using the OpenGL part of Croquet without the Croquet layer
(TSphere etc.)?
I'm really interested in learning OpenGL programming and I like
Smalltalk and Squeak very much, but until now all my experiments in this
direction failed.
( If there is a way it will probably include the usage of a simple
window surrounding the OpenGL output - any help with this would also be
greatly appreciated )


With best regards
Max Melzer

Hi Max,

If you haven't already done so, check out http://www.videotutorialsrock.com/ for OpenGL tutorials. They're quite well developed (from making a the windows box all the way up to incorporating 3d modelling), as well as being a little more accessible than some of NeHe's stuff. Depending on your familiarity with OpenGL, it may be a good place to start.

Regards,

Paul T

Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Max Melzer-2
First thanks to all of your for your answers!

Paul Trattle - DWP wrote:

> Hi Max,
> If you haven't already done so, check out
> http://www.videotutorialsrock.com/ for OpenGL tutorials. They're quite
> well developed (from making a the windows box all the way up to
> incorporating 3d modelling), as well as being a little more accessible
> than some of NeHe's stuff. Depending on your familiarity with OpenGL,
> it may be a good place to start.
>
> Regards,
>
> Paul T

Thank you, I really could not get used to the NeHe tutorials, I will
consider this for learning OpenGL.
But, the point to this is: How to learn OpenGL programming -using
Squeak/Smalltalk-  These tuts are good, but they work based on the
assumption you use C++ ....

David P. Reed wrote:

> Two approaches, but you will have to invest some time exploring
> (reading code):
>
> 1. You can study the Croquet initialization code, create your own
> rendering environment, and use the OpenGL primitives directly.   All
> of OpenGL is there in the Squeak world.   If you just want to render
> static images and learn the OpenGL drawing tools, this is the right
> approach.
>
> 2. If you want to start out with a rendering environment that includes
> scheduling, ... there is no reason not to build your own classes that
> draw themselves into the Croquet world using the raw OpenGL primitives
> directly.   Look into the code of TSphere or any other simple class,
> and study how it draws itself.   Then just write your own Txxx class
> by subclassing, using the primitive openGL calls to render it.
1 was the way I went when I tried some time ago, but it did not really
work out, maybe my understanding of the Croquet architecture was/is not
sufficient. This is also what I want to do. 2 is does not really hit the
point because I want to use OpenGL without any Croquet (I plan on using
it independently of Croquet) though understanding the way Croquet
utilizes OpenGL may prove useful for getting a graphics engine done myself.

Also, most of the OpenGL tutorials out there are in some way related to
GLU or GLUT, and that is (at least I think so) a big problem because
there is nothing similar in Croquet's OGL implementation. Any ideas here?

A short note: I know JUN, but its documentation is only completely
available in Japanese and I do not really know OGL well enough to see
its usefulness.
Additionally it is not available for Squeak ..... and I don't really
like CST.

So this question still remains: How can I program with OpenGL using
Squeak while involving as few Croquet as possible ?

Cheers

Max




Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Bert Freudenberg

On 02.06.2008, at 16:32, Max Melzer wrote:

> First thanks to all of your for your answers!
>
> Paul Trattle - DWP wrote:
>> Hi Max,
>> If you haven't already done so, check out http://www.videotutorialsrock.com/ 
>>  for OpenGL tutorials. They're quite well developed (from making a  
>> the windows box all the way up to incorporating 3d modelling), as  
>> well as being a little more accessible than some of NeHe's stuff.  
>> Depending on your familiarity with OpenGL, it may be a good place  
>> to start.
>>
>> Regards,
>>
>> Paul T
>
> Thank you, I really could not get used to the NeHe tutorials, I will
> consider this for learning OpenGL.
> But, the point to this is: How to learn OpenGL programming -using
> Squeak/Smalltalk-  These tuts are good, but they work based on the
> assumption you use C++ ....
>
> David P. Reed wrote:
>> Two approaches, but you will have to invest some time exploring  
>> (reading code):
>>
>> 1. You can study the Croquet initialization code, create your own  
>> rendering environment, and use the OpenGL primitives directly.    
>> All of OpenGL is there in the Squeak world.   If you just want to  
>> render static images and learn the OpenGL drawing tools, this is  
>> the right approach.
>>
>> 2. If you want to start out with a rendering environment that  
>> includes scheduling, ... there is no reason not to build your own  
>> classes that draw themselves into the Croquet world using the raw  
>> OpenGL primitives directly.   Look into the code of TSphere or any  
>> other simple class, and study how it draws itself.   Then just  
>> write your own Txxx class by subclassing, using the primitive  
>> openGL calls to render it.
> 1 was the way I went when I tried some time ago, but it did not really
> work out, maybe my understanding of the Croquet architecture was/is  
> not
> sufficient. This is also what I want to do. 2 is does not really hit  
> the
> point because I want to use OpenGL without any Croquet (I plan on  
> using
> it independently of Croquet) though understanding the way Croquet
> utilizes OpenGL may prove useful for getting a graphics engine done  
> myself.
>
> Also, most of the OpenGL tutorials out there are in some way related  
> to
> GLU or GLUT, and that is (at least I think so) a big problem because
> there is nothing similar in Croquet's OGL implementation. Any ideas  
> here?
>
> A short note: I know JUN, but its documentation is only completely
> available in Japanese and I do not really know OGL well enough to see
> its usefulness.
> Additionally it is not available for Squeak ..... and I don't really
> like CST.
>
> So this question still remains: How can I program with OpenGL using
> Squeak while involving as few Croquet as possible ?

For example, in a workspace like this:

| ogl green |
ogl := OpenGL newIn: (0@0 extent: 100@100).
green := 1.
[[
        ogl glClearColor(0, green, 0, 1).
        ogl glClear(16r4000).
        ogl swapBuffers.
        Sensor waitClickButton.
        green := 1 - green.
] repeat] ensure: [ogl destroy]

This does not use Croquet at all but just OpenGL. I blogged about it a  
while ago:
http://croquetweak.blogspot.com/2007/02/opengl-in-workspace.html
A better way would be using OpenGL in Morphic or Tweak. I posted a  
Tweak version, also a while ago:
http://permalink.gmane.org/gmane.comp.lang.smalltalk.tweak/198
But that doesn't work anymore ... attached is one that I just tested  
in the 1.0.18 SDK.
- Bert -


COpenGLPlayer.st.gz (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Peter Moore-5

On Jun 2, 2008, at 11:35 AM, Bert Freudenberg wrote:
<snip>


This does not use Croquet at all but just OpenGL. I blogged about it a while ago:
http://croquetweak.blogspot.com/2007/02/opengl-in-workspace.html
A better way would be using OpenGL in Morphic or Tweak. I posted a Tweak version, also a while ago:
http://permalink.gmane.org/gmane.comp.lang.smalltalk.tweak/198
But that doesn't work anymore ... attached is one that I just tested in the 1.0.18 SDK.
- Bert -

<COpenGLPlayer.st.gz>

David Faught contributed a working version of Bert's OpenGL Tweak player that also includes a few of the NeHe tutorials. It's available from the Public Contributions project in the Hedgehog source repository here: http://hedgehog.software.umn.edu:8888

Peter B. Moore
Academic Computing - Office of Information Technology
University of Minnesota



Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Bert Freudenberg

On 02.06.2008, at 19:35, Peter Moore wrote:

>
> On Jun 2, 2008, at 11:35 AM, Bert Freudenberg wrote:
>> <snip>
>
>>
>> This does not use Croquet at all but just OpenGL. I blogged about  
>> it a while ago:
>> http://croquetweak.blogspot.com/2007/02/opengl-in-workspace.html
>> A better way would be using OpenGL in Morphic or Tweak. I posted a  
>> Tweak version, also a while ago:
>> http://permalink.gmane.org/gmane.comp.lang.smalltalk.tweak/198
>> But that doesn't work anymore ... attached is one that I just  
>> tested in the 1.0.18 SDK.
>> - Bert -
>>
>> <COpenGLPlayer.st.gz>
>
> David Faught contributed a working version of Bert's OpenGL Tweak  
> player that also includes a few of the NeHe tutorials. It's  
> available from the Public Contributions project in the Hedgehog  
> source repository here: http://hedgehog.software.umn.edu:8888

Interesting ... how would the package be called?

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

David Faught
On 6/2/08, Bert Freudenberg <[hidden email]> wrote:
> On 02.06.2008, at 19:35, Peter Moore wrote:
> > On Jun 2, 2008, at 11:35 AM, Bert Freudenberg wrote:
> > > <snip>

> > > This does not use Croquet at all but just OpenGL. I blogged about it a
> while ago:
> > >
> http://croquetweak.blogspot.com/2007/02/opengl-in-workspace.html
> > > A better way would be using OpenGL in Morphic or Tweak. I posted a Tweak
> version, also a while ago:
> > >
> http://permalink.gmane.org/gmane.comp.lang.smalltalk.tweak/198
> > > But that doesn't work anymore ... attached is one that I just tested in
> the 1.0.18 SDK.
> > > - Bert -
> > >
> > > <COpenGLPlayer.st.gz>
> > >
> >
> > David Faught contributed a working version of Bert's OpenGL Tweak player
> that also includes a few of the NeHe tutorials. It's available from the
> Public Contributions project in the Hedgehog source repository here:
> http://hedgehog.software.umn.edu:8888
> >
>
> Interesting ... how would the package be called?

There is a lot of information about this project at
http://croquetconsortium.org/index.php/Procedural_Texturing

It depends on the OpenGL updates that Peter posted in the Jabberwocky
(not Hedgehog) repository.  The actual package with Bert's OpenGL
Tweak Player is
http://jabberwocky.croquetproject.org:8889/PublicContributions/Tweak-OpenGL-daf.12.mcz

Cheers,
Dave
Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Max Melzer-2
Thanks to Bert and Dave, those were exactly the right hints, now I got
it...it was too simple to find out on my own, doh!
Anyhow, the COpenGLPlayer just shows a black rectangle...but maybe I'll
have to modify it because my GPU doesn't support GLSL (despite the fact
that chkGPUInfo says it does). Thank you all for your responsiveness.

Max Melzer

Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Max Melzer-2
Hi all,
since the last problem (setting up the basic OpenGL area) has been
resolved, I've been encountering all sorts of other problems.
The worst of it is I cannot even get the NeHe #01 tutorial to work
(drawing a simple triangle). The OGL area just displays a black
rectangle. The problem could be that virtually all OGL tuts out there
are written for C++ and I cannot properly adapt them to Smalltalk. Could
somebody please point out how to run a basic OGL demo with source code
included? And yes, I tried to get information from the OGL classes
inside Croquet, but that was, so to speak, a complete waste of time.

Thanks in advance (and the hope I'm not just too stupid for this)

Max Melzer
Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Bert Freudenberg

On 04.06.2008, at 19:01, Max Melzer wrote:

> Hi all,
> since the last problem (setting up the basic OpenGL area) has been  
> resolved, I've been encountering all sorts of other problems.
> The worst of it is I cannot even get the NeHe #01 tutorial to work  
> (drawing a simple triangle). The OGL area just displays a black  
> rectangle. The problem could be that virtually all OGL tuts out  
> there are written for C++ and I cannot properly adapt them to  
> Smalltalk. Could somebody please point out how to run a basic OGL  
> demo with source code included? And yes, I tried to get information  
> from the OGL classes inside Croquet, but that was, so to speak, a  
> complete waste of time.
>
> Thanks in advance (and the hope I'm not just too stupid for this)


Why don't you try the examples David and I posted, and take it from  
there?

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Max Melzer-2
To Bert: Using your examples is exactly what I want to do, but at the
moment I'm not able to modify them without breaking them.
To give you an example here is what I put together from NeHe tutorial
#05 (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=05), your
example and an example in the current TweakOGL package from David:

| ogl dx dy dz |

ogl := OpenGL newIn: (0@0 extent: 800@600).
dx := 1.0.
dy := 1.0.
dz := 1.0.

[[
    ogl glClearColor(0,0,0,0).
    ogl glClear(16r4000).
    ogl glLoadIdentity().
    ogl glTranslatef(1.5,0.0,-7.0).
    ogl glBegin(16r0007).
    ogl glColor3f(0.0,1.0,0.0).
    ogl glVertex3f( dx negated, dy, dz ).
    ogl glVertex3f( dx negated, dy negated, dz ).
    ogl glVertex3f( dx, dy negated, dz ).
    ogl glVertex3f( dx, dy, dz ).
    ogl glEnd.
    ogl swapBuffers.
] repeat] ensure: [ogl destroy]

This just gives me a plain black rectangle or various error messages.
The other thing that keeps bothering me is that the GL_*** constants
don't work, I always have to replace them with the correct value (and
yes, I have reinitialized OpenGLConstants).

Please help me, I just want to know what I have to do in order to use
the NeHe or whatever tutorials and make this work.
What I think is the point I fail is the initialization before the actual
drawing can be done, but NeHe relies on GLU/GLUT for this and these
libraries are not available in Smalltalk.
Sad enough to say that by now I have approx. spent 12+ hours of my life
trying to get OpenGL in Croquet to work as it should...

With best regards and a little desperate

Max Melzer
Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Darius Clarke
Hi Max,

Just to let you know, the demo works on my system. So, at least, the code is good as I've loaded it.

Perhaps it's a driver issue. How do other OpenGL applications work on your system?
Have you tried running this same image on another computer that has OpenGL (without any changes)?

If you have an Nvidia card, you do need to turn off "Threaded Optimization" for Croquet to work. Other OpenGL applications don't seem to mind that setting.

Cheers,
Darius
_______

On Thu, Jun 5, 2008 at 9:07 AM, Max Melzer <[hidden email]> wrote:
To Bert: Using your examples is exactly what I want to do, but at the moment I'm not able to modify them without breaking them.
To give you an example here is what I put together from NeHe tutorial #05 (http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=05), your example and an example in the current TweakOGL package from David:


Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Bert Freudenberg
In reply to this post by Max Melzer-2
On 05.06.2008, at 18:07, Max Melzer wrote:

>
> | ogl dx dy dz |
>
> ogl := OpenGL newIn: (0@0 extent: 800@600).
> dx := 1.0.
> dy := 1.0.
> dz := 1.0.
>
> [[
>   ogl glClearColor(0,0,0,0).
>   ogl glClear(16r4000).
>   ogl glLoadIdentity().
>   ogl glTranslatef(1.5,0.0,-7.0).
>   ogl glBegin(16r0007).
>   ogl glColor3f(0.0,1.0,0.0).
>   ogl glVertex3f( dx negated, dy, dz ).
>   ogl glVertex3f( dx negated, dy negated, dz ).
>   ogl glVertex3f( dx, dy negated, dz ).
>   ogl glVertex3f( dx, dy, dz ).
>   ogl glEnd.
>   ogl swapBuffers.
> ] repeat] ensure: [ogl destroy]
>
> This just gives me a plain black rectangle or various error messages.

You missed the InitGL() and ReSizeGLScene() setup code from

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=01

These do set up a perspective projection, without which your code will  
not render as expected.

> The other thing that keeps bothering me is that the GL_*** constants  
> don't work, I always have to replace them with the correct value  
> (and yes, I have reinitialized OpenGLConstants).

This won't work in a generic Workspace, because it does not "import"  
the OpenGLConstants. But go to class OpenGL in a Browser, and type  
GLQuads somewhere, select "print it" - it will evaluate to 7. So you  
could use a Browser as workspace, or you should move your code into a  
class that also imports OpenGLConstants just as OpenGL does (my Tweak  
player uses this).

I just tried this (pasted into a Browser on OpenGL class), and it  
works (I just changed a few numbers to make it look interesting, and  
removed the loop - click to quit):

================
| ogl dx dy dz |
ogl := OpenGL newIn: (0@0 extent: 200@200).
dx := 0.5.
dy := 0.5.
dz := 0.5.
ogl glClearColor(0,1,0,1);
        glClear(GLColorBufferBit+GLDepthBufferBit);
        glLoadIdentity();
        glBegin(GLQuads);
        glColor3f(1,0,0);
        glVertex3f( dx negated, dy, dz );
        glVertex3f( dx negated, dy negated, dz );
        glVertex3f( dx, dy negated, dz );
        glVertex3f( dx, dy, dz );
        glEnd;
        swapBuffers.
Sensor waitButton.
ogl destroy
================

A workaround for the Workspace case would be

        OpenGLConstants classPool at: #GLQuads


> Please help me, I just want to know what I have to do in order to  
> use the NeHe or whatever tutorials and make this work.
> What I think is the point I fail is the initialization before the  
> actual drawing can be done, but NeHe relies on GLU/GLUT for this and  
> these libraries are not available in Smalltalk.

Croquet is independent of the platform.

        OpenGL newIn: (0@0 extent: 800@600)

does the setup for you, it uses WGL on  Windows and GLX on Linux and  
AGL on MacOS ...

And do not despair, *every* student starting with OpenGL will gets to  
experience the "black screen phenomenon", a.k.a. "where did my objects  
go"? You will need to learn about coordinate systems, projections,  
transformations etc. to make your scene actually render in front of  
your virtual camera.

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Joshua Gargus-2

On Jun 5, 2008, at 11:35 AM, Bert Freudenberg wrote:

> On 05.06.2008, at 18:07, Max Melzer wrote:
>>
>> The other thing that keeps bothering me is that the GL_***  
>> constants don't work, I always have to replace them with the  
>> correct value (and yes, I have reinitialized OpenGLConstants).

A quick hack for programming in the workspace (not to be used in  
production code) is to add OpenGLConstants to the pool dictionaries of  
UndefinedObject:

Object subclass: #UndefinedObject
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: 'OpenGLConstants'
        category: 'Kernel-Objects'

(you can of course do the same for GLExtConstants)

> And do not despair, *every* student starting with OpenGL will gets  
> to experience the "black screen phenomenon", a.k.a. "where did my  
> objects go"? You will need to learn about coordinate systems,  
> projections, transformations etc. to make your scene actually render  
> in front of your virtual camera.

Preach it, brother Bert!  Truer words have never been spoken.

Josh



>
>
> - Bert -
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

Max Melzer-2
In reply to this post by Bert Freudenberg
Thank you Bert! You're a real life-saver, you helped me getting past
this point I've given up at time after time. Your latest codesnippet
works for me hoooooooray!
Big big thanks....... also to all the other guys (especially David)
answering my dumb questions. The posts of David have also given me the
answer to the question wether there is something going on in Croquet
related to OGL 2.x - that's great news.

Now kind of happy because of getting OGL really working for the very
first time

Max Melzer
Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

David Faught
On 6/5/08, Max Melzer <[hidden email]> wrote:

> Thank you Bert! You're a real life-saver, you helped me getting past this
> point I've given up at time after time. Your latest codesnippet works for me
> hoooooooray!
> Big big thanks....... also to all the other guys (especially David)
> answering my dumb questions. The posts of David have also given me the
> answer to the question wether there is something going on in Croquet related
> to OGL 2.x - that's great news.
>
> Now kind of happy because of getting OGL really working for the very first
> time

Hey thanks, but I don't want to give you the wrong impression.  I'm
okay with answering dumb questions - I have quite a few of those
myself - but Bert and Joshua (and maybe a few others) are the real
experts with OpenGL and Croquet.  And I don't know of anyone actively
trying to extend Croquet to support OGL 2.x outside of the couple of
interesting parts already done.  But OGL is a fun thing and I'm glad
you got off the ground with it.

Dave
Reply | Threaded
Open this post in threaded view
|

Re: Using OpenGL without the Croquet layer

ccrraaiigg
In reply to this post by Joshua Gargus-2

 > > And do not despair, *every* student starting with OpenGL will gets
 > > to experience the "black screen phenomenon", a.k.a. "where did my
 > > objects go"? You will need to learn about coordinate systems,
 > > projections, transformations etc. to make your scene actually render
 > > in front of your virtual camera.
 >
 > Preach it, brother Bert!  Truer words have never been spoken.

      :)


-C


Reply | Threaded
Open this post in threaded view
|

Odd slow-downs

hendikon
In reply to this post by Bert Freudenberg
Why might my Croquet worlds be slowing down dramatically when I
mouse-over things in the world (e.g. TWindows & TSpinners) ? The same
thing happens for the demo worlds that come with the SDK; reasonable
speeds like 25fps until I mouse-over or manipulate something, when it
drops to 5fps. I discovered that when this happens, normal speed can be
restored by selecting something from the Squeak world menu, e.g.
open>workspace.
Reply | Threaded
Open this post in threaded view
|

Re: Odd slow-downs

hendikon
Never mind, after fruitless minutes with MessageTally I finally sorted
it out by making a changeset for my work and filing that into a fresh
Jabberwocky image (in the process learning about changesets).Now speeds
are consistent.


Matthew Chadwick wrote:
> Why might my Croquet worlds be slowing down dramatically when I
> mouse-over things in the world (e.g. TWindows & TSpinners) ? The same
> thing happens for the demo worlds that come with the SDK; reasonable
> speeds like 25fps until I mouse-over or manipulate something, when it
> drops to 5fps. I discovered that when this happens, normal speed can
> be restored by selecting something from the Squeak world menu, e.g.
> open>workspace.
>