本文整理汇总了Java中javax.media.opengl.GL2GL3类的典型用法代码示例。如果您正苦于以下问题:Java GL2GL3类的具体用法?Java GL2GL3怎么用?Java GL2GL3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GL2GL3类属于javax.media.opengl包,在下文中一共展示了GL2GL3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawScene
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
private void drawScene(GL4bc gl) {
if (this.scene != null){
for (PhysicalObject obj : this.scene){
if (obj.getShape() instanceof AbstractSurface){
AbstractSurface b = (AbstractSurface)obj.getShape();
Color c;
if (obj.getNameString() != null && obj.getNameString().equals("detector")){
c = new Color(1,0,0);
} else {
c = new Color(1,1,1);
}
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL2GL3.GL_LINE );
gl.glPushMatrix();
gl.glScaled(1/getMaxPoint(), 1/getMaxPoint(), 1/getMaxPoint());
CompoundShape cs = (CompoundShape) b.tessellate(1);
if (cs != null)
for (AbstractShape s: cs){
drawTriangle(gl, (Triangle)s, c);
}
gl.glPopMatrix();
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL2GL3.GL_FILL );
}
}
}
}
示例2: init
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
@Override
public void init( final GLAutoDrawable drawable )
{
final GL2 gl = drawable.getGL().getGL2();
gl.setSwapInterval( 1 );
gl.glEnable( GL.GL_DEPTH_TEST );
gl.glDepthFunc( GL.GL_LEQUAL );
gl.glShadeModel( GLLightingFunc.GL_SMOOTH );
gl.glHint( GL2ES1.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST );
// gl.glEnable( GL.GL_BLEND );
// gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA );
gl.glEnable( GL2GL3.GL_POLYGON_SMOOTH );
final float w = this.window.getDrawableSurface().getWidth();
final float h = this.window.getDrawableSurface().getHeight();
// Set the projection matrix (only done once - just here)
gl.glMatrixMode( GLMatrixFunc.GL_PROJECTION );
gl.glLoadIdentity();
this.glu.gluPerspective( 50, (w / h), 0.01, 10 );
// Set the initial model matrix
gl.glMatrixMode( GLMatrixFunc.GL_MODELVIEW );
gl.glLoadIdentity();
gl.glViewport( 0, 0, (int) w, (int) h ); /* viewport size in pixels */
}
示例3: readFrameBuffer
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf) {
GL gl = GLContext.getCurrentGL();
if (fb != null) {
RenderBuffer rb = fb.getColorBuffer();
if (rb == null) {
throw new IllegalArgumentException("Specified framebuffer"
+ " does not have a colorbuffer");
}
setFrameBuffer(fb);
if (context.boundReadBuf != rb.getSlot()) {
gl.getGL2().glReadBuffer(GL.GL_COLOR_ATTACHMENT0 + rb.getSlot());
context.boundReadBuf = rb.getSlot();
}
}
else {
setFrameBuffer(null);
}
gl.glReadPixels(vpX, vpY, vpW, vpH, GL2GL3.GL_BGRA, GL.GL_UNSIGNED_BYTE, byteBuf);
}
示例4: convertWrapMode
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
private int convertWrapMode(Texture.WrapMode mode) {
switch (mode) {
case BorderClamp:
return GL2GL3.GL_CLAMP_TO_BORDER;
case Clamp:
return GL2.GL_CLAMP;
case EdgeClamp:
return GL.GL_CLAMP_TO_EDGE;
case Repeat:
return GL.GL_REPEAT;
case MirroredRepeat:
return GL.GL_MIRRORED_REPEAT;
default:
throw new UnsupportedOperationException("Unknown wrap mode: " + mode);
}
}
示例5: convertFormat
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
@Override
protected int convertFormat(Format format) {
switch (format) {
case Byte:
return GL.GL_BYTE;
case UnsignedByte:
return GL.GL_UNSIGNED_BYTE;
case Short:
return GL.GL_SHORT;
case UnsignedShort:
return GL.GL_UNSIGNED_SHORT;
case Int:
return GL2ES2.GL_INT;
case UnsignedInt:
return GL2ES2.GL_UNSIGNED_INT;
case Half:
return GL.GL_HALF_FLOAT;
case Float:
return GL.GL_FLOAT;
case Double:
return GL2GL3.GL_DOUBLE;
default:
throw new RuntimeException("Unknown buffer format.");
}
}
示例6: convertVertexFormat
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
@Override
protected int convertVertexFormat(VertexBuffer.Format fmt) {
switch (fmt) {
case Byte:
return GL.GL_BYTE;
case Double:
return GL2GL3.GL_DOUBLE;
case Float:
return GL.GL_FLOAT;
case Half:
return GL.GL_HALF_FLOAT;
case Int:
return GL2ES2.GL_INT;
case Short:
return GL.GL_SHORT;
case UnsignedByte:
return GL.GL_UNSIGNED_BYTE;
case UnsignedInt:
return GL2ES2.GL_UNSIGNED_INT;
case UnsignedShort:
return GL.GL_UNSIGNED_SHORT;
default:
throw new UnsupportedOperationException("Unrecognized vertex format: " + fmt);
}
}
示例7: drawCuboid
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
public void drawCuboid(GL4bc gl, PointND location, double scalex, double scaley,double scalez,double colorR, double colorG, double colorB){
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL2GL3.GL_LINE );
gl.glPushMatrix();
gl.glTranslated(location.get(0)/getMaxPoint(), location.get(1)/getMaxPoint(), location.get(2)/getMaxPoint());
gl.glScaled(scalex/getMaxPoint()/3, scaley/getMaxPoint()/3, scalez/getMaxPoint()/3);
OpenGLViewer.makeCube(gl, colorR, colorG, colorB);
gl.glPopMatrix();
gl.glPolygonMode( GL.GL_FRONT_AND_BACK, GL2GL3.GL_FILL );
}
示例8: createOrGetProgram
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
public synchronized int createOrGetProgram(GL2GL3 g) {
if (programId == -1) {
programId = g.glCreateProgram();
for (Shader shader : sources) {
g.glAttachShader(programId, shader.createOrGetShader(g));
}
g.glLinkProgram(programId);
g.glValidateProgram(programId);
IntBuffer intBuffer = IntBuffer.allocate(1);
g.glGetProgramiv(programId, GL2.GL_LINK_STATUS, intBuffer);
if (intBuffer.get(0) != 1) {
g.glGetProgramiv(programId, GL2.GL_INFO_LOG_LENGTH, intBuffer);
int size = intBuffer.get(0);
System.err.println("Program link error: ");
if (size > 0) {
ByteBuffer byteBuffer = ByteBuffer.allocate(size);
g.glGetProgramInfoLog(programId, size, intBuffer, byteBuffer);
for (byte b : byteBuffer.array()) {
System.err.print((char) b);
}
}
else {
System.err.println("Unknown OpenGL shader link error");
}
}
}
return programId;
}
示例9: bind
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
public void bind(GL2GL3 g) {
if (programId == -1) {
createOrGetProgram(g);
}
if (currentProgram != this) {
g.glUseProgram(programId);
currentProgram = this;
}
}
示例10: getUniformLocation
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
private int getUniformLocation(GL2GL3 g, String name) {
Integer location = uniformsLocations.get(name);
if (location == null) {
createOrGetProgram(g);
location = g.glGetUniformLocation(programId, name);
uniformsLocations.put(name, location);
}
return location;
}
示例11: getInt
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
public int getInt(GL2GL3 g, String name) {
bind(g);
int location = getUniformLocation(g, name);
IntBuffer buffer = BufferUtil.newIntBuffer(1);
g.glGetUniformiv(programId, location, buffer);
return buffer.get();
}
示例12: getFloat
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
public float getFloat(GL2GL3 g, String name) {
bind(g);
int location = getUniformLocation(g, name);
FloatBuffer buffer = BufferUtil.newFloatBuffer(1);
g.glGetUniformfv(programId, location, buffer);
return buffer.get();
}
示例13: getVector3f
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
public Vector3f getVector3f(GL2GL3 g, String name) {
bind(g);
int location = getUniformLocation(g, name);
FloatBuffer buffer = BufferUtil.newFloatBuffer(3);
g.glGetUniformfv(programId, location, buffer);
return new Vector3f(buffer.get(), buffer.get(), buffer.get());
}
示例14: setMatrix4f
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
public void setMatrix4f(GL2GL3 g, String name, Matrix4f value) {
bind(g);
int location = getUniformLocation(g, name);
FloatBuffer buffer = BufferUtil.newFloatBuffer(16);
value.get(buffer);
g.glUniformMatrix4fv(location, 1, false, buffer);
}
示例15: getMatrix4f
import javax.media.opengl.GL2GL3; //导入依赖的package包/类
public Matrix4f getMatrix4f(GL2GL3 g, String name) {
bind(g);
int location = getUniformLocation(g, name);
FloatBuffer buffer = BufferUtil.newFloatBuffer(16);
g.glGetUniformfv(programId, location, buffer);
Matrix4f matrix = new Matrix4f(buffer);
return matrix;
}