本文整理汇总了Java中javax.microedition.khronos.opengles.GL10.glMaterialfv方法的典型用法代码示例。如果您正苦于以下问题:Java GL10.glMaterialfv方法的具体用法?Java GL10.glMaterialfv怎么用?Java GL10.glMaterialfv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.khronos.opengles.GL10
的用法示例。
在下文中一共展示了GL10.glMaterialfv方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawLines
import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
/**
* 画坐标
* @param gl
*/
private void drawLines(GL10 gl){
gl.glLineWidth(3f);
float[] vertexArray = { -100, 0, 0, 100, 0, 0, 0, -100, 0, 0, 100, 0, 0, 0, -100, 0, 0, 100 };
FloatBuffer lineBuffer = getFloatBufferFromArray(vertexArray);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, lineBuffer);
// X : red
gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[] { 1.0f, 0f, 0f, 0.75f }, 0);
gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[] { 1.0f, 0f, 0f, 0.5f }, 0);
gl.glDrawArrays(GL10.GL_LINES, 0, 2);
// Y : blue
gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[] { 0f, 0f, 1.0f, 0.75f }, 0);
gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[] { 0f, 0f, 1.0f, 0.5f }, 0);
gl.glDrawArrays(GL10.GL_LINES, 2, 2);
// Z : green
gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[] { 0f, 1.0f, 0f, 0.75f }, 0);
gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[] { 0f, 1.0f, 0f, 0.5f }, 0);
gl.glDrawArrays(GL10.GL_LINES, 4, 2);
}
示例2: drawGrids
import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
/**
* 画网格
* @param gl
*/
private void drawGrids(GL10 gl) {
List<Float> lineList = new ArrayList<Float>();
for (int x = -100; x <= 100; x += 5) {
lineList.add((float) x);
lineList.add(-100f);
lineList.add(0f);
lineList.add((float)x);
lineList.add(100f);
lineList.add(0f);
}
for (int y = -100; y <= 100; y += 5) {
lineList.add(-100f);
lineList.add((float) y);
lineList.add(0f);
lineList.add(100f);
lineList.add((float) y);
lineList.add(0f);
}
FloatBuffer lineBuffer = getFloatBufferFromList(lineList);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, lineBuffer);
gl.glLineWidth(1f);
gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[]{0.5f, 0.5f, 0.5f, 1.0f}, 0);
gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[]{0.5f, 0.5f, 0.5f, 1.0f}, 0);
gl.glDrawArrays(GL10.GL_LINES, 0, lineList.size() / 3);
}
示例3: onDrawFrame
import javax.microedition.khronos.opengles.GL10; //导入方法依赖的package包/类
@Override
public void onDrawFrame(GL10 gl) {
if (bufferCounter < 1) {
return;
}
bufferCounter--;
gl.glLoadIdentity();
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glTranslatef(positionX, -positionY, 0);
// rotation and apply Z-axis
gl.glTranslatef(0, 0, translation_z);
gl.glRotatef(angleX, 0, 1, 0);
gl.glRotatef(angleY, 1, 0, 0);
scale_rember=scale_now*scale;
gl.glScalef(scale_rember, scale_rember, scale_rember);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glMatrixMode(GL10.GL_MODELVIEW);
// draw X-Y field
if (displayGrids) {
drawGrids(gl);
}
// // draw axis
// if (displayAxes) {
// gl.glLineWidth(3f);
// float[] vertexArray = { -100, 0, 0, 100, 0, 0, 0, -100, 0, 0, 100, 0, 0, 0, -100, 0, 0, 100 };
// FloatBuffer lineBuffer = getFloatBufferFromArray(vertexArray);
// gl.glVertexPointer(3, GL10.GL_FLOAT, 0, lineBuffer);
//
// // X : red
// gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[] { 1.0f, 0f, 0f, 0.75f }, 0);
// gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[] { 1.0f, 0f, 0f, 0.5f }, 0);
// gl.glDrawArrays(GL10.GL_LINES, 0, 2);
//
// // Y : blue
// gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[] { 0f, 0f, 1.0f, 0.75f }, 0);
// gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[] { 0f, 0f, 1.0f, 0.5f }, 0);
// gl.glDrawArrays(GL10.GL_LINES, 2, 2);
//
// // Z : green
// gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_AMBIENT, new float[] { 0f, 1.0f, 0f, 0.75f }, 0);
// gl.glMaterialfv(GL10.GL_FRONT_AND_BACK, GL10.GL_DIFFUSE, new float[] { 0f, 1.0f, 0f, 0.5f }, 0);
// gl.glDrawArrays(GL10.GL_LINES, 4, 2);
// }
// draw object
if (stlObject != null) {
gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_AMBIENT, new float[] { 0.75f,0.75f,0.75f,1.0f }, 0);
gl.glMaterialfv(GL10.GL_FRONT, GL10.GL_DIFFUSE, new float[] { 0.75f,0.75f,0.75f,1.0f }, 0);
gl.glEnable(GL10.GL_COLOR_MATERIAL);
gl.glPushMatrix();
gl.glColor4f(red,green,blue, 1.0f);
stlObject.draw(gl);
gl.glPopMatrix();
gl.glDisable(GL10.GL_COLOR_MATERIAL);
}
}