Opengl es 我可以在OpenGL ES 1.1中的顶点着色网格上使用glColor4f吗?
在opengl 1.1中,使用libgdx对预着色网格进行着色或设置alpha是一种方法吗Opengl es 我可以在OpenGL ES 1.1中的顶点着色网格上使用glColor4f吗?,opengl-es,libgdx,alpha,mesh,opengl-es-1.1,Opengl Es,Libgdx,Alpha,Mesh,Opengl Es 1.1,在opengl 1.1中,使用libgdx对预着色网格进行着色或设置alpha是一种方法吗 private Mesh mesh; private Camera camera; @Override public void create() { if (mesh == null) { mesh = new Mesh(true, 3, 1, new VertexAttribute(Usage.Position
private Mesh mesh;
private Camera camera;
@Override
public void create() {
if (mesh == null) {
mesh = new Mesh(true, 3, 1,
new VertexAttribute(Usage.Position, 3, "a_position"),
new VertexAttribute(Usage.ColorPacked, 4, "a_color"));
mesh.setVertices(new float[] { -1f,0f,0.000000f,Color.toFloatBits(255,0,0,255),
1f,0f,0.000000f,Color.toFloatBits(0,255,0,255),
0f,1f,0.000000f,Color.toFloatBits(0,0,255,255)
});
mesh.setIndices(new short[] { 0,1,2});
}
}
@Override
public void render() {
GL11 gl = Gdx.graphics.getGL11();
gl.glEnable(GL10.GL_DEPTH_TEST);
gl.glDepthFunc(GL10.GL_LESS);
camera.update();
camera.apply(Gdx.gl10);
gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
gl.glClearColor(0.15f, 0.15f, 0.15f, 1);
gl.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
gl.glEnable(GL11.GL_BLEND);
gl.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
gl.glShadeModel(GL11.GL_SMOOTH);
gl.glPushMatrix();
//blue overlay + 50% opaque
gl.glColor4f(0f,0f,1f,0.5f); //*** THIS LINE IS IGNORED
mesh.render(GL10.GL_TRIANGLES, 0, 3);
gl.glPopMatrix();
}
@Override
public void resize(int width, int height){
float aspectRatio = (float) width / (float) height;
camera = new OrthographicCamera(10f * aspectRatio, 10f);
}
我会使用纹理我可以使用glColor4f添加阴影或设置透明度,但是如果我使用顶点颜色,我就不能这样做?有glBlendColor功能,我认为它可以满足您的需要,但它仅在GLES 2.0中可用。谢谢,我想您是对的。我做了一些研究,得出了相同的结论。