iphone - iOS OpenGL ES 2.0 Draw 3D Line and Set Color -


i can draw lines in opengl es 2.0 on iphone following code. disabling textures , blending glkbaseeffects 'useconstantcolor' not seem color line - black! cannot set color! how can that?

    // turn off texturing     self.effect.texture2d0.enabled = no;     self.effect.texture2d1.enabled = no;      // turn off blending     gldisable(gl_blend);     gldisable(gl_texture_2d);      // draw line     self.effect.useconstantcolor = gl_true;      // make line red color     self.effect.constantcolor = glkvector4make(                                                1.0f, // red                                                0.0f, // green                                                0.0f, // blue                                                1.0f);// alpha      // prepare effect rendering     [self.effect preparetodraw];      glfloat line[] = { -1.0, -1.0, -6.0, 1.0, 1.0, 5.0, 1.0, -1.0, 2.0 };      // create handle buffer object array     gluint bufferobjectnamearray;      // have opengl generate buffer name , store in buffer object array     glgenbuffers(1, &bufferobjectnamearray);      // bind buffer object array gl_array_buffer target buffer     glbindbuffer(gl_array_buffer, bufferobjectnamearray);      // send line data on target buffer in gpu ram     glbufferdata(                  gl_array_buffer,   // target buffer                  sizeof(line),      // number of bytes put buffer                  line,              // pointer data being copied                  gl_static_draw);   // usage pattern of data      // enable vertex data fed down graphics pipeline drawn     glenablevertexattribarray(glkvertexattribposition);      // specify how gpu looks data     glvertexattribpointer(                           glkvertexattribposition, // bound buffer holds data                           3,                       // number of coordinates per vertex                           gl_float,                // data type of each component                           gl_false,                // can data scaled // * incorrect *          3,                       // how many bytes per vertex (3 floats per vertex)                           0,                       // stride (0 bytes between coordinates.) ~olie // * incorrect *          null);                   // offset first coordinate, in case 0                            line);                   // pointer buffer draw. ~olie      // set line width     gllinewidth(5.0);      // render line     gldrawarrays(gl_line_loop, 0, 3);      // turn on blending     gldisable(gl_blend);      // turn on texturing     self.effect.texture2d0.enabled = yes;     self.effect.texture2d1.enabled = yes; 

try adding this:

// turn off lighting self.effect.light0.enabled = gl_false; 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -