java - GLColorPointer isn't working with glDrawArrays -


i quite new opengl , having bit of trouble colorpointer function in conjunction drawarrays ... can't seem object render color .. when used glcolor4f function works .. thinking how construct color floatbuffer .. can't seem figure out.

please have @ of code , let me know doing wrong here ... first stack on flow post (:

// function draws vertices in 3d space public void draw(gl10 gl){     // enable client side access since arrays store on client side heap     // , opengl considered server side     gl.glenableclientstate(gl10.gl_vertex_array);     gl.glenableclientstate(gl10.gl_normal_array);     gl.glenable(gl10.gl_color_array);     gl.glenable(gl10.gl_cull_face); // enable cull face     gl.glcullface(gl10.gl_back);    // cull face (don't display)     gl.glenable(gl10.gl_color_material);      gl.glvertexpointer(3, gl10.gl_float, 0, binarystlparser.getvertices());     gl.glnormalpointer(gl10.gl_float, 0, binarystlparser.getnormalvectors());     gl.glcolorpointer(4, gl10.gl_float, 0, binarystlparser.colours);     gl.gldrawarrays(gl10.gl_triangles, 0, (binarystlparser.getnumoffacets() * 3));      //gl.glshademodel(gl10.gl_shininess);     // disables access given client side heap opengl     gl.gldisableclientstate(gl10.gl_vertex_array);     gl.gldisableclientstate(gl10.gl_normal_array);     gl.gldisable(gl10.gl_color_array);     gl.gldisable(gl10.gl_cull_face);     gl.gldisable(gl10.gl_color_material); } 

this class

numoffacets = bytebuffer.wrap(numberoffacets).order(byteorder.nativeorder()).getint();          // allocate memory floatbuffers since know number of facets         // use bytebuffer ensure native ordering .........         // * 3 each vertex point in 3d (* 3) space. size of float 4 bytes         vertices = bytebuffer.allocatedirect((numoffacets * 3 * 3) * 4)                         .order(byteorder.nativeorder()).asfloatbuffer();          // * 3 each coordinate in vector. size of float 4 bytes         normalvectors = bytebuffer.allocatedirect((numoffacets * 3) * 4)                         .order(byteorder.nativeorder()).asfloatbuffer();          // * 3 each vertex point in 4d (* 4) rbga space. size of float 4 bytes         colours = bytebuffer.allocatedirect((numoffacets * 3 * 4) * 4)                 .order(byteorder.nativeorder()).asfloatbuffer();          for(int = 0 ; < numoffacets*3; i++){             colours.put(new float[] {0.0f, 1.0f, 0.0f, 0.5f});         }         colours.position(0); 

i figured out ! wanted post answer incase helps else (:

silly mistake ... looks using:

gl.glenable(gl10.gl_color_array);

instead of

gl.glenableclientstate(gl10.gl_color_array);

floatbuffers stored on client side heap, , opengl considered server side suppose.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -