realbasic-games
[Top] [All Lists]

Re: realbasic-games Digest, Vol 12, Issue 24

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: realbasic-games Digest, Vol 12, Issue 24
From: Asher Dunn <asher at fireyesoftware dot com>
Date: Mon, 28 Mar 2005 21:28:34 -0500
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <20050328205416 dot 29305 dot qmail at web21327 dot mail dot yahoo dot com>

On Mar 28, 2005, at 3:54 PM, cap'n bishop wrote:

My question is this: would it be
faster to store geometric information in an array of primitives
...or to store it in
a memoryblock

Those would be approximately the same performance wise, but if you're
passing arrays to OpenGL you have to use memoryblocks.

The types of values in this case won't be passed to OpenGL.  Anyway
that answers that question, best to use arrays for heightmaps.

If you are going to be using glVertex*** to draw the heightmaps (vertex arrays would be faster...)

For cleaner code, what if I were to create memoryblock subclasses
with
accessors (for each type of data, like verticies) and stored those
in
an array, how would that compare?  This would probably be best
since
then the data could be sent to OpenGL by just passing the
memoryblock.

If you want speed, DO NOT use accessors.

I'd like to go for reusable structures if possible.  The accessor would
simply recall or set a single piece of data to a hard coded location in
the memory block; and this is no different than what would be done
without the accessor.  Are you absolutely possitive there would be a
performance hit?

In my simple spur-of-the-moment test, accessors were more than twice as slow as direct property access.

Let me give a more specific case.  If I were to load information into a
3DS type data structure I would probably want to store stuff like faces
and verticies (where verticies are 3 values for a points in 3D space
and faces are 3 values referencing vertices; just like a trimesh in
Quesa) in subclasses which would then be stored into a "Face" or
"Vertex" array.  If these subclasses were memoryblocks then the
verticies would be very convienient to send straight to OpenGL.  All in
all this would be much cleaner than storing all face or vertex values
into a large multi dimentional array.

Why would you need a multidimensional array? You could have a single dimensional array of vertices, every 3 values being (x, y, z), and a single dimensional array of vertex indices, every three of these being treated as a face. If you do it that way, you might as well go with memoryBlocks and use OpenGL vertex arrays.

Anyway are you CERTAIN that using these subclasses with accessors would
be slower than accessing the memoryblock directly?

Definitely.

Asher Dunn
--------------------------------------------------------
President and Head Developer of Fireye Software <http://www.fireyesoftware.com/>
AIM and Yahoo: fireye7517

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>