glDrawElements and direct buffer access

Problems with Canvas, OpenGL, etc...

glDrawElements and direct buffer access

Postby mvdgaag » Sat Jun 12, 2010 12:01 pm

Hi all,

Have an object that I want to procedurally change the colors off. I use glDrawElements, but openGL needs a direct buffer that I cannot just change the values in without using the put() method, that I assume would be very slow if I have to call it 1000 times a frame.

Is there a way to directly mess in a FloatBuffer AND having openGL accept it in glDrawElements?

Otherwise would glDrawArrays be a better solution?

Thanks a lot!

Maarten
mvdgaag
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Jun 09, 2010 10:02 pm

Top

Re: glDrawElements and direct buffer access

Postby mvdgaag » Sat Jun 12, 2010 12:09 pm

Hmm... DrawArrays isn't an option, because I can't use indexing and will have to find and update the colors of 'double' vertices in my triangle strip.
mvdgaag
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Jun 09, 2010 10:02 pm

Re: glDrawElements and direct buffer access

Postby mvdgaag » Sat Jun 12, 2010 1:06 pm

this is terrible, I know :D. Does anyone know to supply glDrawElements with a buffer where I don't have to edit another buffer and copy the whole thing?

Code: Select all
// class variables
   private FloatBuffer colorBuffer;
   private static float colors[];

// every frame!!!!
   colorBuffer.position(0);
   colorBuffer.put(colors);
   colorBuffer.position(0);
mvdgaag
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Jun 09, 2010 10:02 pm

Re: glDrawElements and direct buffer access

Postby dinamic » Mon Jun 14, 2010 6:00 am

If you going procedural go for olddays of precalculated values if you want speed..

anther way is doing the GL in native code...

Myself does uses put() withtin rendering loop for colors and havn't have a speed problem..
ofcourse it hasnt been much of resource intensitive rendering thuog...

/H
dinamic
Freshman
Freshman
 
Posts: 8
Joined: Thu Jun 10, 2010 2:31 pm

Re: glDrawElements and direct buffer access

Postby dinamic » Mon Jun 14, 2010 6:00 am

If you going procedural go for olddays of precalculated values if you want speed..

anther way is doing the GL in native code...

Myself does uses put() withtin rendering loop for colors and havn't have a speed problem..
ofcourse it hasnt been much of resource intensitive rendering thuog...

/H
dinamic
Freshman
Freshman
 
Posts: 8
Joined: Thu Jun 10, 2010 2:31 pm

Re: glDrawElements and direct buffer access

Postby mvdgaag » Mon Jun 14, 2010 7:32 am

It is a 100*100 field of vertices that does some simplified fluid dynamics (just in the color buffer), so precalculation is no option. I'll look into making this thing in native code.

Thanks
mvdgaag
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Jun 09, 2010 10:02 pm

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 2 guests