On Fri, Mar 28, 2008 at 12:31 PM, Serg Kovrov <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Recently I came across small OpenGL ES demo named Wake Breaker (by
> Peter Angstadt) - a game project. The one that comes with trial
> version of gDEBugger (wonderful tool, btw). Eventually I decided to
> try to translate it to Python, and now the port is complete and should
> be as playable as original. All original issues are preserved though,
> so there plenty room for improvements still.
>
> The source code, original description and a screenshot available on
> project's page - http://wakebreaker.googlecode.com/
>
> Although, I run into one nasty issue - sometimes (not allways) there
> is an access violation in glDrawArrays call. This one is tricky.
>
> There is a particle system - essentially ctypes array of Parcice
> structures. Parcice has position (Vector3) and some other fields.
> Particle and Vector3 are actually ctypes structures.
>
> To draw it, glVertexPointer used to set pointer to beginning of
> Vector3 (first particle's position), an offset (as there is other than
> position stuff in Particle), and type of vertex data (3 GL_FLOAT).
> Than glDrawArrays fired with actual length of array.
>
> The code is not that complex -
> http://code.google.com/p/wakebreaker/source/browse/trunk/fx.py?r=2#50
>
> It actually woks quite well in most cases, but on one of my machines
> it gives me access violation in 1 run of 4. It happens not totally
> random, but coincidentally with other events (like keyboard events or
> console output, or at program exit). At first I have thought GC is
> releasing this data prematurely, but so far I can see actual data data
> is not corrupted even at crash time.
>
> So I kind of lost and confused here. If anyone could confirm this
> issue and even better - have an idea what could cause this, I would
> very much appreciate it.
The texture coordinate array is enabled but not valid in these cases.
The following is a simple fix:
glDisableClientState(GL_TEXTURE_COORD_ARRAY)
glDrawArrays(GL_POINTS, 0, len(self.__particles))
glEnableClientState(GL_TEXTURE_COORD_ARRAY)
I tend to glPushClientAttrib, enable just the necessary arrays, draw,
then glPopClientAttrib to avoid these kinds of problems (at the cost
of some state switching overhead).
Great port by the way, nicely done.
Alex.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---