Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Nov 19, 2017 9:02 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Missing OpenGL Documentation
PostPosted: Mon Oct 26, 2009 11:18 pm 
Offline

Joined: Mon Oct 26, 2009 10:53 pm
Posts: 6
Can anyone point me to documentation of the version of OpenGL as implemented by REALbasic in the OpenGLSurface?

I realize that this was a plug-in created by TinRocket, I have been to their site but it has absolutely no helpful documentation.

I already have the Red Book and several other OpenGL books but I am working in 3D and they all make heavy use of GLUT for the viewing and modelling transformations, which is not included with OpenGLSurface. To make matters worse, many OpenGLSurface methods do not accept arrays but MemoryBlocks and it is not documented how the MemoryBlocks are to be filled.

I even started translating some GLUT routines to REALbasic but the MemoryBlock issue, and the big differences between REALbasic's unique multidimensional array structure and C's array structure are making it almost impossible without some documentation.


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing OpenGL Documentation
PostPosted: Mon Oct 26, 2009 11:58 pm 
Offline

Joined: Fri Sep 30, 2005 12:18 pm
Posts: 629
MemoryBlock can be used any way you want... its essentially raw data that you can work with, or to communicate with other APIs such as OpenGL.

Create a OpenGLArray class and add the methods and computed properties to make it behave like an Array in REALbasic, but the MemoryBlock is the real meat of the class. For example, if you need an array of Floats, you set the size of the MemoryBlock to be 4x the number of singles in the array. Then when you are ready to pass your "array" into OpenGL, you define the "array" as type Pointer, and your data when you call the declare is the actual MemoryBlock... then REALbasic knows it needs to pass the data by reference instead of value.


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing OpenGL Documentation
PostPosted: Tue Oct 27, 2009 12:34 am 
Offline

Joined: Mon Oct 26, 2009 10:53 pm
Posts: 6
Phil M wrote:
MemoryBlock can be used any way you want... its essentially raw data that you can work with, or to communicate with other APIs such as OpenGL.


I understand how to use MemoryBlocks to store floats, doubles, etc. The issue is what array values are loaded in what positions in the MemoryBlock. For instance, are the values loaded by increasing x subscripts first or increasing y subscripts? This can only be answered by having documentation on how the routines that use the MemoryBlock expect the values to be loaded. Many of the OpenGL routines have implicit cascade effects, for instance glMultMatrixf uses only one MemoryBlock as input, so it must implicitly have the second matrix stored somewhere to multiply by. The order of the matrix values in the MemoryBlock is crucial since matrix multiplication is not commutative.

I need the documentation of exactly what the OpenGLSurface methods expect for their input and output values in order to proceed.


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing OpenGL Documentation
PostPosted: Wed Oct 28, 2009 1:56 pm 
Offline

Joined: Fri Sep 30, 2005 8:39 pm
Posts: 364
Location: Arlington, TX
glMultMatrixf multiplies the current matrix, which is designated by the last call to glMatrixMode (Projection, ModelView or Texture), by the values that you submit.

The matrix's are stored left to right, top to bottom in the memory block. Lets take a 3x3 matrix and fill it from an array( 8 ) - Assuming array starts at 0.

We are going to assume that you pass MyArray( 8 ) as a double array and it is your matrix loaded left to right, top to bottom.

Dim memBlock As MemoryBlock
Dim i As Integer

// Creating or memory block, 8 bytes per double.
memBlock = New Memory Block( ( UBound( MyArray ) + 1 ) * 8 )

// Loading our array items into the memory block
For i = 0 To 8
memBlock( i * 8 ) = MyArray( i ) // i * 8 because doubles occupy 8 bytes, if it was a single or long it would be i * 4.
Next

// Multiplying our matrix, assumes that you have all of the opengl calls in a module or local to this code.
glMultMatrixf( memBlock )

_________________
Open Source OpenGL Classes:
Camera (1.1), Light (1.0), Texture (1.2), Font (1.2), Mesh (1.7), Models (1.0)


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing OpenGL Documentation
PostPosted: Mon Nov 02, 2009 9:07 pm 
Offline

Joined: Thu Oct 12, 2006 7:21 am
Posts: 415
Location: California
try something like this, I was able to figure it out.

dim lightColor0 as new MemoryBlock(24)
lightColor0.singleValue(0)=0.5
lightColor0.singleValue(4)=0.5
lightColor0.singleValue(8)=0.5
lightColor0.singleValue(12)=1.0

I did this to make use of one of the opengl functions below.

openGL.glLightfv(openGL.GL_LIGHT0, openGL.GL_DIFFUSE, lightColor0)

the trick is having the memoryblock save it as singleValue's

_________________
Joe Astrahan
CEO - iTechware Inc.
iTechware - Internet, Technology & Software
Google Adwords Campaign Management
"Rocketing you to the top!"
10900 Los Alamitos Blvd, Suite #210
Los Alamitos, CA, 90720
(949)354-4ADS


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing OpenGL Documentation
PostPosted: Wed Nov 04, 2009 1:45 pm 
Offline

Joined: Fri Sep 30, 2005 12:18 pm
Posts: 629
x11joex11 wrote:
the trick is having the memoryblock save it as singleValue's


Been a while since I did OpenGL, and my Red Book is packed away (just moved into new house)... but if I remember correctly, most OpenGL values expect a float (single).

If you are doing a lot of Matrix functions, you might consider wrapping everything into a Matrix class, that would allow you to have a clear usage of the matrices and use the MemoryBlock as a storage device (and functions that accept an Matrix send the data as the MemoryBlock instead of your properties). For example, you could make the Matrix class behave more like a 2D array accessing the elements like myMatrix(1,1) to represent the center.


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing OpenGL Documentation
PostPosted: Wed Nov 04, 2009 2:00 pm 
Offline

Joined: Fri Sep 30, 2005 12:18 pm
Posts: 629
x11joex11 wrote:
try something like this, I was able to figure it out.

dim lightColor0 as new MemoryBlock(24)
lightColor0.singleValue(0)=0.5
lightColor0.singleValue(4)=0.5
lightColor0.singleValue(8)=0.5
lightColor0.singleValue(12)=1.0


For this example, I would probably make the data as an array...
Dim lightColor0( ) As Single = Array( 0.5, 0.5, 0.5, 1.0 )

And then use a function to convert the array into a MemoryBlock
Function RBGLFloatArray( values( ) As Single ) As MemoryBlock
Dim mb As MemoryBlock = New MemoryBlock(( values.Ubound + 1 ) * 4 ) // 4 = size of single
For k As Integer = 0 To values.Ubound
mb.SingleValue( k * 4 ) = values( k )
Next
Return mb
End Function

So your total code for your example would be something like:
Dim lightColor0( ) As Single = Array( 0.5, 0.5, 0.5, 1.0 )
openGL.glLightfv( openGL.GL_LIGHT0, openGL.GL_DIFFUSE, RBGLFloatArray( lightColor0 ))

or skip the creation of the lightColor0 variable entirely and just use:
openGL.glLightfv( openGL.GL_LIGHT0, openGL.GL_DIFFUSE, RBGLFloatArray( Array( 0.5, 0.5, 0.5, 1.0 )))


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing OpenGL Documentation
PostPosted: Fri Nov 06, 2009 6:16 pm 
Offline

Joined: Fri Sep 30, 2005 8:39 pm
Posts: 364
Location: Arlington, TX
Phil M wrote:
Been a while since I did OpenGL, and my Red Book is packed away (just moved into new house)... but if I remember correctly, most OpenGL values expect a float (single).


Actually the type of the variable passed is determined by the last letter in the gl* function

Example:
glVertex2i( X, Y ) - Expects Integers
glVertex2f( X, Y ) - Expects Floats (Singles)
glVertex2d( X, Y ) - Expects Doubles

hope that helps :)

_________________
Open Source OpenGL Classes:
Camera (1.1), Light (1.0), Texture (1.2), Font (1.2), Mesh (1.7), Models (1.0)


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing OpenGL Documentation
PostPosted: Sun Nov 15, 2009 6:39 pm 
Offline

Joined: Fri Sep 30, 2005 1:24 pm
Posts: 119
To go back to the title of this topic-

Where is it Realsoftware?????


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing OpenGL Documentation
PostPosted: Sun Nov 15, 2009 7:17 pm 
Offline

Joined: Fri Sep 30, 2005 8:39 pm
Posts: 364
Location: Arlington, TX
There is no documentation for the OpenGLSurface, its just a gateway to OpenGL.

_________________
Open Source OpenGL Classes:
Camera (1.1), Light (1.0), Texture (1.2), Font (1.2), Mesh (1.7), Models (1.0)


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing OpenGL Documentation
PostPosted: Sun Nov 15, 2009 7:48 pm 
Offline

Joined: Mon Oct 26, 2009 10:53 pm
Posts: 6
The OpenGLSurface is not an exact mapping of OpenGL, so it fails as a simple gateway. There are many routines in OpenGLSurface that use MemoryBlocks for their interface. While this sounds innocuous, it makes it very difficult to follow the Red Book code because, correct me if I am wrong, there is no direct mapping of a MemoryBlock to a REALbasic vector, and definitely not to a REALbasic multidimensional array.

The Red Book, and the GLUT libraries, often use vectors to store multidimensional arrays. This is possible, as you all probably know, because C stores arrays in continguous memory. So there are routines in OpenGL that return vectors which are then sent to routines needing an array, not something that can be done with OpenGLSurface without translation code. REALbasic does not store multidimensional arrays contiguously, so attempts to map directly between the Red Book or GLUT routines and OpenGLSurface fail.

What is needed is either a better OpenGL implementation in REALbasic, or, at the very least, documentation about which OpenGLSurface methods use MemoryBlocks and how the MemoryBlocks are to be packed for proper operation in OpenGLSurface.

Unfortunately, I need to have my applications work on both Mac and PC, without needing external libraries, so I must use OpenGLSurface. The only example provided by REAL Software is a two-dimensional fluid dynamics simulation which is useless for understanding the 3D viewing transforms of OpenGLSurface. So until REAL Software finishes the job or someone (e.g. TinRocket) steps up with the missing documentation, it is extremely frustrating to use OpenGLSurface for anything.

So once again I ask, does anyone have the missing documentation?

FYI, my application is 3D data plotting, not gaming. This is the only 3D forum provided by REAL Software, so I apologize if my posts appear to be off-topic.


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing OpenGL Documentation
PostPosted: Mon Nov 16, 2009 8:09 am 
Offline

Joined: Fri Sep 30, 2005 1:24 pm
Posts: 119
Well said.

It does need some RB specific info. as to what exactly it supports and the various things you will encounter
when trying to use it.

As RS have depricated both the spriteSurface and the original RB3D, this means a lot of work for folks who have used these things and now have to go to OpenGlSurface.


Top
 Profile  
Reply with quote  
 Post subject: Re: Missing OpenGL Documentation
PostPosted: Tue Feb 09, 2010 10:14 pm 
Offline

Joined: Tue Nov 08, 2005 5:52 pm
Posts: 111
I'm looking for a replacement for
gluLookAt()
which there doesn't seem to be unless you rotate/translate the object itself. OpenGL is not straight-forward and without some updated tutorials, it's only harder.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group