• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GL2GL3类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.media.opengl.GL2GL3的典型用法代码示例。如果您正苦于以下问题:Java GL2GL3类的具体用法?Java GL2GL3怎么用?Java GL2GL3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GL2GL3类属于javax.media.opengl包,在下文中一共展示了GL2GL3类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 );
			}
		}
	}
}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:27,代码来源:XRayViewer.java


示例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 */
	}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:27,代码来源:Visualisation3D.java


示例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);
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:20,代码来源:JoglRenderer.java


示例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);
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:17,代码来源:JoglRenderer.java


示例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.");

    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:27,代码来源:JoglRenderer.java


示例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);
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:26,代码来源:JoglRenderer.java


示例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 );

}
 
开发者ID:akmaier,项目名称:CONRAD,代码行数:13,代码来源:XRayViewer.java


示例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;
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:30,代码来源:Program.java


示例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;
    }
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:11,代码来源:Program.java


示例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;
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:11,代码来源:Program.java


示例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();
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:8,代码来源:Program.java


示例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();
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:8,代码来源:Program.java


示例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());
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:8,代码来源:Program.java


示例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);
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:8,代码来源:Program.java


示例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;
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:9,代码来源:Program.java


示例16: getShaderType

import javax.media.opengl.GL2GL3; //导入依赖的package包/类
private int getShaderType(String extension) {
    switch (extension) {
        case "vert":
            return GL2GL3.GL_VERTEX_SHADER;
        case "frag":
            return GL2GL3.GL_FRAGMENT_SHADER;
        default:
            throw new IllegalArgumentException("Cannot parse shader type");
    }
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:11,代码来源:Shader.java


示例17: createOrGetShader

import javax.media.opengl.GL2GL3; //导入依赖的package包/类
public synchronized int createOrGetShader(GL2GL3 g) {
    if (shaderId == -1) {
        try (InputStream stream = source.openStream()) {
            String[] line = new String[] { IOUtils.toString(stream) };
            shaderId = g.glCreateShader(type);
            g.glShaderSource(shaderId, 1, line, null, 0);
            g.glCompileShader(shaderId);
        } catch (IOException ex) {
            Log.err(ex);
        }
    }
    
    return shaderId;
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:15,代码来源:Shader.java


示例18: update

import javax.media.opengl.GL2GL3; //导入依赖的package包/类
public void update(GL2GL3 g) {
    if (textureId == -1) {
        g.glEnable(GL2GL3.GL_TEXTURE_2D_ARRAY);
        IntBuffer singleTexBuffer = GLBuffers.newDirectIntBuffer(1);

        g.glGenTextures(1, singleTexBuffer);
        textureId = singleTexBuffer.get();
        g.glBindTexture(GL2GL3.GL_TEXTURE_2D_ARRAY, textureId);
        g.glTexStorage3D(GL2GL3.GL_TEXTURE_2D_ARRAY, 255, GL2GL3.GL_RGBA8, width, height, depth);
    }
    
    if (lastUpdate == subtexturesCount) {
        return;
    }
    
    g.glBindTexture(GL2GL3.GL_TEXTURE_2D_ARRAY, textureId);
    
    for (int i = lastUpdate; i < subtexturesCount; i++) {
        try {
            String texturePath = subtexturesLocations.get(i);
            TextureData data = TextureIO.newTextureData(GLProfile.getDefault(), new File(texturePath), true, FilenameUtils.getExtension(texturePath));
            
            if (data.getWidth() != width || data.getHeight() != height) {
                throw new IllegalArgumentException("Textures width/height does not match.");
            }
            
            g.glTexSubImage3D(GL2GL3.GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, width, height, subtexturesCount, GL2GL3.GL_RGBA, GL2GL3.GL_UNSIGNED_BYTE, data.getBuffer());
            g.glGenerateMipmap(GL2GL3.GL_TEXTURE_2D_ARRAY);
            
            if (g.glGetError() != GL2GL3.GL_NO_ERROR) {
                throw new GLException("Failed subtexture loading");
            }
        } catch (IOException ex) {
            Log.err(ex);
        }
    }
    
    lastUpdate = subtexturesCount;
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:40,代码来源:ArrayTex.java


示例19: checkFrameBufferError

import javax.media.opengl.GL2GL3; //导入依赖的package包/类
@Override
protected void checkFrameBufferError() {
    GL gl = GLContext.getCurrentGL();
    int status = gl.glCheckFramebufferStatus(GL.GL_FRAMEBUFFER);
    switch (status) {
        case GL.GL_FRAMEBUFFER_COMPLETE:
            break;
        case GL.GL_FRAMEBUFFER_UNSUPPORTED:
            // Choose different formats
            throw new IllegalStateException("Framebuffer object format is "
                    + "unsupported by the video hardware.");
        case GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
            throw new IllegalStateException("Framebuffer has erronous attachment.");
        case GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
            throw new IllegalStateException("Framebuffer is missing required attachment.");
        case GL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
            throw new IllegalStateException(
                    "Framebuffer attachments must have same dimensions.");
        case GL.GL_FRAMEBUFFER_INCOMPLETE_FORMATS:
            throw new IllegalStateException("Framebuffer attachments must have same formats.");
        case GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
            throw new IllegalStateException("Incomplete draw buffer.");
        case GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
            throw new IllegalStateException("Incomplete read buffer.");
        case GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
            throw new IllegalStateException("Incomplete multisample buffer.");
        default:
            // Programming error; will fail on all hardware
            throw new IllegalStateException("Some video driver error "
                    + "or programming error occured. "
                    + "Framebuffer object status is invalid. ");
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:34,代码来源:JoglRenderer.java


示例20: convertTextureType

import javax.media.opengl.GL2GL3; //导入依赖的package包/类
@Override
protected int convertTextureType(Texture.Type type) {
    switch (type) {
        case TwoDimensional:
            return GL.GL_TEXTURE_2D;
        case TwoDimensionalArray:
            return GL.GL_TEXTURE_2D_ARRAY;
        case ThreeDimensional:
            return GL2GL3.GL_TEXTURE_3D;
        case CubeMap:
            return GL.GL_TEXTURE_CUBE_MAP;
        default:
            throw new UnsupportedOperationException("Unknown texture type: " + type);
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:16,代码来源:JoglRenderer.java



注:本文中的javax.media.opengl.GL2GL3类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IDiamondSpriteVertexBufferObject类代码示例发布时间:2022-05-22
下一篇:
Java AmazonGlacierClient类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap