English 中文(简体)
OpenGL ES的颜色缓冲区中需要多少种颜色?
原标题:How many colors in the colorbuffer of OpenGL ES we need?
  • 时间:2011-02-17 09:05:45
  •  标签:
  • opengl-es

If I have a cube mesh in OpenGL ES and I want to have a flat color for each side of the cube so that each side has a different color, do I need to specify color per vertex or color per triangle or color per side? This 2 lines of code:

gl.glEnableClientState(GL10.GL_COLOR_ARRAY); gl.glColorPointer(4, GL10.GL_FLOAT, 0, mColorBuffer);

与这个问题有关。

OpenGL ES如何知道我指定的哪种颜色与立方体的哪一侧匹配?

最佳回答

应该为每个顶点指定颜色,但由于每个面都有不同的颜色,因此无法在面之间共享顶点。与其绘制立方体(8个顶点、8种颜色、12个三角形),不如绘制恰好具有重合顶点位置的6个四边形(24个顶点、24种颜色、十二个三角形)

编辑:四边形只是两个共享一些顶点的三角形。例如,覆盖单位正方形的四边形(在2D中)可以具有顶点阵列和三角形索引阵列,如下所示:

// bottom left, top left, bottom right, top right order
float[] verts = new float[]{ 0, 0, 0, 1, 1, 0, 1, 1 };
// anti-clockwise vertex order
int[] tris = new int[]{ 0, 2, 1, 2, 3, 1 };
问题回答

暂无回答




相关问题
OpenGL ES iPhone - drawing anti aliased lines

Normally, you d use something like: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); glLineWidth(2.0f); glVertexPointer(2, GL_FLOAT, 0, points); ...

iPhone: Quartz2d vs. OpenGL ES

OK, I m still brand new to iPhone development. I have a free game on the app store, Winner Pong, but it s just a Pong clone (who would ve guessed) that uses the standard UIImageViews for the sprites. ...

GLPaint with white background

I m trying draw on a white background by reverse engineering GLPaint. I ve gone through every combination of kSaturation, kLuminosity and glBlendFunc, AND just about every combination I can think of ...

OpenGL ES - how to keep some object at a fixed size?

I m working on a little game in OpenGL ES. In the background, there is a world/map. The map is just a large texture. Zoom/pinch/pan is used to move around. And I m using glOrthof (left, right, bottom,...

Any free polygon library for the iPhone?

I need a library that can manage polygon modeling and basic transformation like rotating and translating. I d rather not redevelop everything from scratch Thanks

热门标签