0
\$\begingroup\$

I'm not sure which way is the best way to do this for my purposes.
My purposes being having a textured (with an image) cube.

Also, I've been following a blend of tutorials, so I'm not sure which way is the most right and what I'm doing wrong (currently I haven't had the texture fit right).

  1. Do I use glDrawArrays or glDrawElements?

  2. For pointers, do I say gl.glVertexPointer(3, GL.GL_FLOAT, 0, vertices); and gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, textureData);
    or
    gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0); and gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, 0);

  3. When do I bind/unbind the buffers? (gl.glBindBuffer(GL.GL_ARRAY_BUFFER, VBOVertices); gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboTextureCoordHandle);) Before I establish the pointers or not in my drawing method at all?

  4. Do I need to specify the UV coordinates/Texture Coordinates in the shader? If I'm getting a weirdly stretched texture, does that mean my fragment shader and setting the uniforms is working correctly?

Thank you!
I can supply more code, but I think I just need more information on the basics.

\$\endgroup\$
2
  • \$\begingroup\$ You really should consider reading different tutorial. \$\endgroup\$
    – wondra
    Commented Aug 11, 2014 at 23:10
  • \$\begingroup\$ There are so many tutorials out there, but none of them fit my exact situation, so I've been reading several and have found they are not all consistent: now I have this problem of not knowing what to take away from each tutorial. \$\endgroup\$ Commented Aug 12, 2014 at 3:29

1 Answer 1

0
\$\begingroup\$
  1. Depends whether you use indices(elements) or not (arrays).
  2. niether, you should use gl.glVertexPointer(3, GL.GL_FLOAT, stride, (const GLvoid *) offsetOfFirst), unless you lib overrides it ofcourse.
  3. no idea, sorry, I use attributes
  4. means you pass wrong UVs. To shader you pass only sample location. (make sure UVs are in range 0.0 - 1.0)
  5. you really should find alternative tutorial if you dont understand part of one
\$\endgroup\$
1
  • \$\begingroup\$ please correct me if I am wrong at any statement \$\endgroup\$
    – wondra
    Commented Aug 11, 2014 at 23:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .