graphics - Problem when trying to use simple Shaders + VBOs -


Hello I'm trying to convert the following function to a VBO based function for the purpose of learning, on this screen Displays a steady texture. I'm using OpenGL ES 2.0 with Shaders on the iPad (in this case, it should be almost identical with Regular OpenGL), this is what I have worked:

  // Works! - (zero) Drawpoint: (CP point) Depth of point: (CGFLOT) Depth {GL Float coordinate [=] 0, 1, 1, 1, 0, 0, 1, 0}; GLFlot width = (GL float) _ width * _ MaxS, height = (GL float) _height * _maxy; GLfloat Corner [] = {-width / 2 + point.x, -height / 2 + point.y, width / 2 + point.x, -height / 2 + point.y, -width / 2 + point.x, Height / 2 + point.or, width / 2 + point.x, height / 2 + point.i,}; Globindactments (GL_design DD, _name); // Attrib condition and attrib_texen coordination, handles for shaver attributes glavitaxe attribute pointers (ATTRIBO_POSITION, 2, GL_Flat, GL_FLSE, 0, Cortis); GlEnableVertexAttribArray (ATTRIB_POSITION); GlVertexAttribPointer (ATTRIB_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, coordinates); GlEnableVertexAttribArray (ATTRIB_TEXCOORD); GlDrawArrays (GL_TRIANGLE_STRIP, 0, 4); }  

I tried to change VBO to do this, but I do not see anything on this screen with this version:

  // None displayed (zero) drag point: (CGPint) Depth of point: (CGFlot) Depth {GL Float width = (GL float) _ width = _ MXS, height = (GL float) _height * _ MXT; GLfloat position [] = {-width / 2 + point.x, -height / 2 + point.y, width / 2 + point.x, -height / 2 + point.y, -width / 2 + point.x, Height / 2 + point.or, width / 2 + point.x, height / 2 + point.i,}; // Texture on-screen status (x, y is in x-screen cods on top of each) GL Floot coordinates [] = {0, 1, 1, 1, 0, 0, 1, 0}; // 0 to 1 Globe WorktechAreoOoos (WO) textured collar; Glenveretexase OES (1, and VoO); Gleenberg (2, Vibo); // buffer 1 global buffer (GL_ARRAY_BUFFER, vbo [0]); GlobeFedata (GL_ARRAY_BUFFER, 8 * shaped (GL float), position, GLSADATCDRAW); GlEnableVertexAttribArray (ATTRIB_POSITION); GlVertexAttribPointer (ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, position); // buffer 2 global buffer (GL_ARRAY_BUFFER, vbo [1]); GlobeFedata (GL_ARRAY_BUFFER, 8 * size (GLfloat), coordinates, GLDVNAMIDADRD); GlEnableVertexAttribArray (ATTRIB_TEXCOORD); GlVertexAttribPointer (ATTRIB_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, coordinates); // Draw Glide VertexArioes (WAO); Globindactments (GL_design DD, _name); GlDrawArrays (GL_TRIANGLE_STRIP, 0, 4); }  

In both cases I am using this simple vertex shader

  // Vertex Shader attribute vec2 state; // ATTRIB_POSITION bound to feature vec4 color; Attribute vec2 texcoord; // change the vec2 texcoordVariing bound for ATTRIB_TEXCOORD; Uniform Unmatched 4 MVP; Zero main () {// You can not use transpose in glUniformMatrix4fv ... here it goes. Gl_Position = mvp * vec4 (position x, position.y, 0.0, 1.0); Texkordevereering = Teckord; }  

gl_Position is equal to mvp * vec4's product because I am simulating glOrthof in 2D with that MVP

and this piece shad

  // Fragment Shadar Uniform Sample 2D Sampler; Various medium vec2 texcoordVariing; Zero Main () {gl_FragColor = texture2D (Sampler, Texsovering); }  

I need help for this, maybe my shadars are wrong for another matter?

Thanks in advance.

Everything is fine, except glVertexAttribPointer calls.

When you have a VBO bound, the last parameter is used as the O glVertexAttribPointer offset in a VBO, as an indicator (the indicator value is offset). Therefore, your data is in the beginning of VBO, so the last column should be 0 (NULL) for both calls.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -