当前位置: 首页>>代码示例>>Java>>正文


Java Util类代码示例

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


Util类属于org.lwjgl.opengl包,在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: enable

import org.lwjgl.opengl.Util; //导入依赖的package包/类
@Override
    public void enable() {
        if (pvs != null && pvs.singleOwner) pvs.tick();
        if (pfs != null && pfs.singleOwner) pfs.tick();
        if ((pvs != null && oldVGen != pvs.generator) || (pfs != null && oldFGen != pfs.generator)) {
            //TODO asserts?
//            asserts();
            ShaderHandler np = newShaderProgram();
            shaderState.deleteProgram();
            shaderState = np;
            if (pvs != null) oldVGen = pvs.generator;
            if (pfs != null) oldFGen = pfs.generator;
        }

        shaderState.enable();
        if (currentVBO != null) {//because we can use built in vertex attributes
            glBindBuffer(GL_ARRAY_BUFFER, currentVBO.bufferId);
            Util.checkGLError();
            for (int i = 0; i < currentStructure.size(); i++) currentStructure.get(i).turnOn();
            Util.checkGLError();
        }
    }
 
开发者ID:kravchik,项目名称:senjin,代码行数:23,代码来源:GProgram.java

示例2: Simple3DWatch

import org.lwjgl.opengl.Util; //导入依赖的package包/类
public Simple3DWatch(int w, int h, boolean createThread) {
        this.w = w;
        this.h = h;
//        if (SIMPLE_AA) {
            simpleAA = new SimpleAntiAliasing2();
//        }

        final Simple3DWatch THIS = this;
        cam.lookAt = new Vec3f(0, 0, 100);


        if (createThread) Threads.tick(new Threads.Tickable() {
            @Override
            public void tick(float dt) throws Exception {
                dt = fixedDt == null ? dt : fixedDt;
                commonTick(dt);
                THIS.tick(dt);
                Util.checkGLError();
                if (SIMPLE_AA) simpleAA.renderFBO();
                Display.update();
                if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) || Display.isCloseRequested()) exit = true;
            }

        }, 10);
    }
 
开发者ID:kravchik,项目名称:senjin,代码行数:26,代码来源:Simple3DWatch.java

示例3: getTexture

import org.lwjgl.opengl.Util; //导入依赖的package包/类
public Texture getTexture(int width, int height, int flags)
{
    int textureID =  glGenTextures();
    Texture texture = new Texture(GL_TEXTURE_2D, textureID, width, height);
    
    GLCache.bindTexture(texture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    
    GL11.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
            texture.getWidth(), texture.getHeight(), 0, GL_RGBA,
            GL_UNSIGNED_BYTE, (ByteBuffer) null);
    
    Util.checkGLError();
    
    return texture;
}
 
开发者ID:TheWhiteShadow3,项目名称:cuina,代码行数:18,代码来源:TextureLoader.java

示例4: gluErrorString

import org.lwjgl.opengl.Util; //导入依赖的package包/类
public static String gluErrorString(int error_code) {
	switch (error_code) {
		case GLU_INVALID_ENUM:
			return "Invalid enum (glu)";
		case GLU_INVALID_VALUE:
			return "Invalid value (glu)";
		case GLU_OUT_OF_MEMORY:
			return "Out of memory (glu)";
		default:
			return Util.translateGLErrorString(error_code);
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:GLU.java

示例5: checkGLError

import org.lwjgl.opengl.Util; //导入依赖的package包/类
protected boolean checkGLError(){
    try {
        Util.checkGLError();
    } catch (OpenGLException ex){
        listener.handleError("An OpenGL error has occured!", ex);
    }
    // NOTE: Always return true since this is used in an "assert" statement
    return true;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:LwjglOffscreenBuffer.java

示例6: glCheckError

import org.lwjgl.opengl.Util; //导入依赖的package包/类
/**
 * check GL errors. Log an error if one occurred
 */
public static boolean glCheckError() {
    try {
        Util.checkGLError();
        return true;
    } catch (OpenGLException e) {
        logger.error("GL error [" + e.getClass().getSimpleName() + "] "
                + e.getMessage());
        return false;
    }
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:14,代码来源:GLTools.java

示例7: sendShaderToCard

import org.lwjgl.opengl.Util; //导入依赖的package包/类
/**<br><br><b>Don't forget to remove shader after programs compilation*/
    public void sendShaderToCard() {
        if (generator.shaderType.equals("vs")) shaderIndex = createVertexShader(stringToBuffer(generator.resultSrc));
        else if (generator.shaderType.equals("fs")) shaderIndex = createFragmentShader(stringToBuffer(generator.resultSrc));
        else BadException.die("unknown shader type: " + generator.shaderType);
//        printLogInfo(shaderIndex);
        Util.checkGLError();
    }
 
开发者ID:kravchik,项目名称:senjin,代码行数:9,代码来源:GShader.java

示例8: initFBO

import org.lwjgl.opengl.Util; //导入依赖的package包/类
public FrameBuffer initFBO(SomeTexture... tt) {
    // init our fbo
    if (textures != null) {
        for (SomeTexture texture : textures) texture.release();
    }
    this.textures = al(tt);
    w = textures.car().width;
    h = textures.car().height;
    for (SomeTexture t : textures) if (t.width != w || t.height != h) BadException.die("all textures must be of same size");
    framebufferID = glGenFramebuffers();											// create a new framebuffer
    depthRenderBufferID = glGenRenderbuffers();									// And finally a new depthbuffer
    glBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferID); 						// switch to the new framebuffer

    IntBuffer drawBufferParam;
    drawBufferParam = BufferUtils.createIntBuffer(tt.length);
    for (int i = 0; i < tt.length; i++) {
        drawBufferParam.put(GL_COLOR_ATTACHMENT0_EXT + i);
        glBindTexture(GL_TEXTURE_2D, tt[i].textureObjectId);
        glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + i, GL_TEXTURE_2D, tt[i].textureObjectId, 0); // attach texture to the framebuffer
    }
    drawBufferParam.rewind();
    GL20.glDrawBuffers(drawBufferParam);



    // initialize depth renderbuffer
    glBindRenderbuffer(GL_RENDERBUFFER_EXT, depthRenderBufferID);				// bind the depth renderbuffer
    glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT32, tt[0].width, tt[0].height);	// get the data space for it
    glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_RENDERBUFFER_EXT, depthRenderBufferID); // bind it to the renderbuffer
    int result = glCheckFramebufferStatus(GL_FRAMEBUFFER);
    if (result != GL_FRAMEBUFFER_COMPLETE) BadException.die("Wrong FBO status: " + result);
    glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);									// Swithch back to normal framebuffer rendering

    Util.checkGLError();

    return this;
}
 
开发者ID:kravchik,项目名称:senjin,代码行数:38,代码来源:FrameBuffer.java

示例9: getUniformLocation

import org.lwjgl.opengl.Util; //导入依赖的package包/类
int getUniformLocation(String loc_name, int programID) {
	byte[] bs = loc_name.getBytes();
	ByteBuffer b = Utils.allocByteBuffer(bs.length+1);
	b.put(bs); b.put((byte)0);
	b.flip();
	int ret = ARBShaderObjects.glGetUniformLocationARB(programID, b);
	if (ret == -1) {
		Logger.logWarning(this, "    WARNING: Shader: "+programID+": could not get uniform location " + loc_name);
	}
	Util.checkGLError();
	return ret;
}
 
开发者ID:Erkaman,项目名称:NeoTextureEdit2,代码行数:13,代码来源:OpenGLTextureRenderCanvas.java

示例10: Program

import org.lwjgl.opengl.Util; //导入依赖的package包/类
public Program(final String shaderName, final String[] uniformNames) {
	final int vsID = Program.loadShader(Program.class.getResourceAsStream("/shaders/" + shaderName + "/vertex.glsl"), GL20.GL_VERTEX_SHADER);
	final int fsID = Program.loadShader(Program.class.getResourceAsStream("/shaders/" + shaderName + "/fragment.glsl"), GL20.GL_FRAGMENT_SHADER);
	
	this.id = GL20.glCreateProgram();
	GL20.glAttachShader(this.id, vsID);
	GL20.glAttachShader(this.id, fsID);
	
	GL20.glLinkProgram(this.id);
	Program.checkLinkage(this.id);
	
	//GL20.glValidateProgram(this.id);
	//Program.checkValidation(this.id);
	
	GL20.glDetachShader(this.id, vsID);
	GL20.glDetachShader(this.id, fsID);
	
	GL20.glDeleteShader(vsID);
	GL20.glDeleteShader(fsID);

	this.uniformLocations = new HashMap<>(uniformNames.length + 1, 1);
	for (final String name : uniformNames) {
		final int loc = GL20.glGetUniformLocation(this.id, name);
		this.uniformLocations.put(name, loc);
		System.out.println("UniformLoc for " + name + "=" + loc);
	}

	Util.checkGLError();
}
 
开发者ID:JanStrauss,项目名称:veya,代码行数:30,代码来源:Program.java

示例11: SpriteRendererDefault

import org.lwjgl.opengl.Util; //导入依赖的package包/类
SpriteRendererDefault() {
	System.out.println("Shootout Implementation: OpenCL GPU animation");

	final int vshID = glCreateShader(GL_VERTEX_SHADER);
	glShaderSource(vshID, "#version 150\n" +
	                      "void main(void) {\n" +
	                      "     gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +
	                      "}");
	glCompileShader(vshID);
	if ( glGetShaderi(vshID, GL_COMPILE_STATUS) == GL_FALSE ) {
		System.out.println(glGetShaderInfoLog(vshID, glGetShaderi(vshID, GL_INFO_LOG_LENGTH)));
		throw new RuntimeException("Failed to compile vertex shader.");
	}

	createProgram(vshID);

	Util.checkGLError();

	createKernel("kernel void animate(\n" +
	             "        const int WIDTH,\n" +
	             "        const int HEIGHT,\n" +
	             "        const float radius,\n" +
	             "        const int delta,\n" +
	             "        global float4 *balls\n" +
	             ") {\n" +
	             "    unsigned int b = get_global_id(0);\n" +
	             "\n" +
	             "     float4 anim = balls[b];\n" +
	             "     anim.xy = anim.xy + anim.zw * delta;\n" +
	             "     float2 animC = clamp(anim.xy, (float2)radius, (float2)(WIDTH - radius, HEIGHT - radius));\n" +
	             "     if ( anim.x != animC.x ) anim.z = -anim.z;\n" +
	             "     if ( anim.y != animC.y ) anim.w = -anim.w;\n" +
	             "\n" +
	             "     balls[b] = (float4)(animC, anim.zw);\n" +
	             "}");

	updateBallSize();
}
 
开发者ID:apcragg,项目名称:3d-Demo,代码行数:39,代码来源:SpriteShootoutCL.java

示例12: createRunnable

import org.lwjgl.opengl.Util; //导入依赖的package包/类
/**
 * Create a runnable for the renderer. A renderer create a new image to draw
 * into. If cancel() is called, the rendering stops as soon as possible.
 * When finished, set the variable rendering to false.
 * 
 * @return a new runnable
 * @see Runnable
 * @see #cancel()
 * @see #isRendering()
 */
@Override
public final Runnable createRunnable() {
    // this runnable is not dedicated to be launched into a thread.
    // It should be launched by a SyncRenderingManager which calls the run()
    // method as a singular method
    return new Runnable() {
        @Override
        public void run() {
            LayerViewGLPanel vp = LwjglLayerRenderer.this.getLayerViewPanel();
            try {
                // now, we are rendering and it's not finished yet
                LwjglLayerRenderer.this.setRendering(true);
                LwjglLayerRenderer.this.setRendered(false);
                // if the rendering is cancelled: stop
                if (LwjglLayerRenderer.this.isCancelled()) {
                    return;
                }
                // if either the width or the height of the panel is lesser
                // than or equal to 0, stop
                if (Math.min(vp.getWidth(), vp.getHeight()) <= 1) {
                    return;
                }
                // do the actual rendering
                try {

                    LwjglLayerRenderer.this.renderHook(vp.getViewport().getEnvelopeInModelCoordinates());
                    GLTools.glCheckError("LWJGLLayerRenderer::renderHook()");
                } catch (Throwable t) {
                    logger.warn("LwJGL Rendering failed for layer '" + LwjglLayerRenderer.this.getLayer().getName() + "': " + t.getMessage() + " (" + t.getClass().getSimpleName() + ")");
                    logger.warn("GL Status is '" + Util.translateGLErrorString(GL11.glGetError()) + "'");
                    t.printStackTrace();
                    return;
                }
            } finally {
                // we are no more in rendering progress
                LwjglLayerRenderer.this.setRendering(false);
            }
        }
    };
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:51,代码来源:LwjglLayerRenderer.java

示例13: removeShaderFromCard

import org.lwjgl.opengl.Util; //导入依赖的package包/类
public void removeShaderFromCard() {
    GL20.glDeleteShader(shaderIndex);
    shaderIndex = -1;
    Util.checkGLError();
}
 
开发者ID:kravchik,项目名称:senjin,代码行数:6,代码来源:GShader.java

示例14: start

import org.lwjgl.opengl.Util; //导入依赖的package包/类
public void start() throws Exception {

        Display.setDisplayMode(new DisplayMode(400, 400));
        Display.create();

        //shaders
        SpecularF fragmentShader = new SpecularF();
        SpecularV vertexShader = new SpecularV();
        GProgram shaderProgram = GProgram.initFromSrcMainJava(vertexShader, fragmentShader);
        //texture
        SomeTexture texture = new SomeTexture(readImage("jfdi.png"));
        //data
        ReflectionVBO vbo1 = new ReflectionVBO(
                new SpecularVi(v3(-5, -5, 0), v3(-1,-1, 1).normalized(), v2(0, 1)),
                new SpecularVi(v3( 5, -5, 0), v3( 1,-1, 1).normalized(), v2(1, 1)),
                new SpecularVi(v3( 5,  5, 0), v3( 1, 1, 1).normalized(), v2(1, 0)),
                new SpecularVi(v3(-5,  5, 0), v3(-1, 1, 1).normalized(), v2(0, 0)));
        vbo1.upload();

        ShortBuffer indexBuffer = BufferUtils.createShortBuffer(6);
        indexBuffer.put(new short[]{0, 2, 1, 0, 3, 2});
        indexBuffer.rewind();

        while (!Display.isCloseRequested()) {
            Util.checkGLError();
            glClearColor(1, 1, 1, 1);
            glClear(GL_COLOR_BUFFER_BIT);

            //prepare matrices, just raw math, no need of glMatrixMode, glMatrixPush, etc
            Matrix4 camModelViewMatrix = new Matrix4().setIdentity().translate(new Vec3f(0, 0, -12));
            vertexShader.modelViewProjectionMatrix = camModelViewMatrix.multiply(perspective(45.0f, (float) 400 / 400, 1, 1000.0f));
            vertexShader.normalMatrix = camModelViewMatrix.invert().transpose().get33();

            //set uniforms and textures
            fragmentShader.shininess = 100;
            vertexShader.lightDir = new Vec3f(2, 1, 3).normalized();
            shaderProgram.setInput(vbo1);
            texture.setSlot(0);
            texture.enable(0);
            fragmentShader.txt.set(texture);

            shaderProgram.enable();
            glDrawRangeElements(GL_TRIANGLES, 0, indexBuffer.limit(), indexBuffer);

            shaderProgram.disable();
            texture.disable();
            Display.update();
        }

        Display.destroy();
    }
 
开发者ID:kravchik,项目名称:senjin,代码行数:52,代码来源:RawSpecular.java

示例15: onTick

import org.lwjgl.opengl.Util; //导入依赖的package包/类
public void onTick(float dt) {
    Util.checkGLError();
    Display.update();
    checkExit();
}
 
开发者ID:kravchik,项目名称:senjin,代码行数:6,代码来源:SimpleLwjglRoutine.java


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