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

Java GL2ES2类代码示例

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

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



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

示例1: ShaderProgram

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
public ShaderProgram(GL2ES2 gl, String vertex, String fragment) {
    this.gl = gl;

    if (gl.isGL3core()) {
        logger.info("GL3 core detected: explicit add #version 130 to shaders");

        vertex = "#version 130\n" + vertex;
        fragment = "#version 130\n" + fragment;
    }

    vertShader = createAndCompileShader(GL2ES2.GL_VERTEX_SHADER, vertex);
    fragShader = createAndCompileShader(GL2ES2.GL_FRAGMENT_SHADER, fragment);

    shaderProgram = gl.glCreateProgram();

    gl.glAttachShader(shaderProgram, vertShader);
    gl.glAttachShader(shaderProgram, fragShader);

    gl.glLinkProgram(shaderProgram);
}
 
开发者ID:perses-games,项目名称:jogl-triangle-color,代码行数:21,代码来源:ShaderProgram.java


示例2: createAndCompileShader

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
private int createAndCompileShader(int type, String shaderString) {
    int shader = gl.glCreateShader(type);

    String[] vlines = new String[]{shaderString};
    int[] vlengths = new int[]{vlines[0].length()};

    gl.glShaderSource(shader, vlines.length, vlines, vlengths, 0);
    gl.glCompileShader(shader);

    int[] compiled = new int[1];
    gl.glGetShaderiv(shader, GL2ES2.GL_COMPILE_STATUS, compiled, 0);

    if (compiled[0] == 0) {
        int[] logLength = new int[1];
        gl.glGetShaderiv(shader, GL2ES2.GL_INFO_LOG_LENGTH, logLength, 0);

        byte[] log = new byte[logLength[0]];
        gl.glGetShaderInfoLog(shader, logLength[0], (int[]) null, 0, log, 0);

        throw new IllegalStateException("Error compiling the shader: " + new String(log));
    }

    return shader;
}
 
开发者ID:perses-games,项目名称:jogl-triangle-color,代码行数:25,代码来源:ShaderProgram.java


示例3: printCompileLog

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
private void printCompileLog(int shader) {
	int[] infoLen = new int[1];
	IntBuffer infoBuffer = IntBuffer.wrap(infoLen);

	gl2es2.glGetShaderiv(shader, GL2ES2.GL_INFO_LOG_LENGTH, infoBuffer);

	if (infoLen[0] > 1) {
		byte[] infoLog = new byte[infoLen[0]];
		ByteBuffer infoLogBuffer = ByteBuffer.wrap(infoLog);

		gl2es2.glGetShaderInfoLog(shader, infoLen[0], null, infoLogBuffer);
		
		try {
			System.out.println("Error compiling shader: " + new String(infoLog, "UTF_8"));
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:galaxy-workstation,项目名称:AircraftDemo,代码行数:20,代码来源:ShaderImpl.java


示例4: printLinkLog

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
private void printLinkLog(int programObject) {
	int[] infoLen = new int[1];
	IntBuffer infoBuffer = IntBuffer.wrap(infoLen);

	gl2es2.glGetProgramiv(programObject, GL2ES2.GL_INFO_LOG_LENGTH, infoBuffer);

	if (infoLen[0] > 1) {
		byte[] infoLog = new byte[infoLen[0]];
		ByteBuffer infoLogBuffer = ByteBuffer.wrap(infoLog);

		gl2es2.glGetProgramInfoLog(programObject, infoLen[0], null, infoLogBuffer);
		
		try {
			System.out.println("Error compiling shader: " + new String(infoLog, "UTF_8"));
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:galaxy-workstation,项目名称:AircraftDemo,代码行数:20,代码来源:ShaderImpl.java


示例5: compileShader

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
private int compileShader(int type, String shaderText) {

		int shader = gl2es2.glCreateShader(type);
		String[] dummy = new String[1];
		dummy[0] = shaderText;

		gl2es2.glShaderSource(shader, 1, dummy, null);
		gl2es2.glCompileShader(shader);

		int[] ret = new int[1];
		IntBuffer retBuffer = IntBuffer.wrap(ret);
		gl2es2.glGetShaderiv(shader, GL2ES2.GL_COMPILE_STATUS, retBuffer);
		if (0 == retBuffer.get(0)) {
			printCompileLog(shader);
			gl2es2.glDeleteShader(shader);
			shader = 0;
		}

		return shader;
	}
 
开发者ID:galaxy-workstation,项目名称:AircraftDemo,代码行数:21,代码来源:ShaderImpl.java


示例6: convertFormat

import javax.media.opengl.GL2ES2; //导入依赖的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


示例7: convertVertexFormat

import javax.media.opengl.GL2ES2; //导入依赖的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


示例8: apply

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
@Override
   public void apply(GL2ES2 gl, double bufferStartTimeSeconds) {
SamplePlaybackEvent.Factory origin = (SamplePlaybackEvent.Factory)getOrigin();
final float factoryVolume = (float)origin.getVolume();
if( factoryVolume < getLowVolumeThreshold() )
    return;
origin.getPanU().set((float)getPan()[0]*factoryVolume, (float)getPan()[1]*factoryVolume);
final SoundSystem ss           = Features.get(getOrigin().getTR(),SoundSystemFeature.class);
final double bufferSizeSeconds = ss.getBufferSizeSeconds(),
             startTimeInBuffers=((getStartRealtimeSeconds()-bufferStartTimeSeconds)/(double)bufferSizeSeconds)*2-1,
             lengthPerRow      = getSoundTexture().getLengthPerRowSeconds();
final int    lengthInSegments  = (int)(getSoundTexture().getNumRows()) * 2; //Times two because of the turn
origin.getNumRowsU().set((float)getSoundTexture().getNumRows());//XXX Kludge to get around int limitations in ES 2
origin.getStartU().set((float)startTimeInBuffers);
origin.getLengthPerRowU()
 .set((float)((2/playbackRatio)*(lengthPerRow/bufferSizeSeconds)));
getSoundTexture().getGLTexture().bindToTextureUnit(0, gl);
gl.glDrawArrays(GL2ES2.GL_LINE_STRIP, 0, lengthInSegments+1);
   }
 
开发者ID:jtrfp,项目名称:terminal-recall,代码行数:20,代码来源:SamplePlaybackEvent.java


示例9: apply

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
@Override
   public void apply(GL2ES2 gl, final double bufferStartTimeSeconds) {// Non-blocking.
if(lastApply!=null)
    if(!lastApply.isDone())
	return;
if(loop || firstRun.get())
  if(bufferStartTimeSeconds > nextLoopTimeSeconds-SETUP_PADDING_SECS)
     lastApply = getOrigin().getTR().getThreadManager().submitToThreadPool(new Callable<Void>(){
     @Override
     public Void call() throws Exception {
	// Set the song up
	mod.apply(MusicPlaybackEvent.this.nextLoopTimeSeconds,MusicPlaybackEvent.this,
		((Factory)getOrigin()).getModStereoWidth());
	MusicPlaybackEvent.this.nextLoopTimeSeconds+=mod.getSongLengthInRealtimeSeconds();
	firstRun.set(false);
	return null;
     }//end call()
    });//end submit()
   }
 
开发者ID:jtrfp,项目名称:terminal-recall,代码行数:20,代码来源:MusicPlaybackEvent.java


示例10: getShaderInfoLog

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
@Override
public String getShaderInfoLog(int shader) {
  int[] val = { 0 };
  gl2.glGetShaderiv(shader, GL2ES2.GL_INFO_LOG_LENGTH, val, 0);
  int length = val[0];

  byte[] log = new byte[length];
  gl2.glGetShaderInfoLog(shader, length, val, 0, log, 0);
  return new String(log);
}
 
开发者ID:d2fn,项目名称:passage,代码行数:11,代码来源:PJOGL.java


示例11: getProgramInfoLog

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
@Override
public String getProgramInfoLog(int program) {
  int[] val = { 0 };
  gl2.glGetShaderiv(program, GL2ES2.GL_INFO_LOG_LENGTH, val, 0);
  int length = val[0];

  if (0 < length) {
    byte[] log = new byte[length];
    gl2.glGetProgramInfoLog(program, length, val, 0, log, 0);
    return new String(log);
  } else {
    return "Unknow error";
  }
}
 
开发者ID:d2fn,项目名称:passage,代码行数:15,代码来源:PJOGL.java


示例12: linkShader

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
private int linkShader(int vertexShader, int fragmentShader) {
	int programObject = 0;
	
	if (vertexShader > 0 && fragmentShader > 0) {
		programObject = gl2es2.glCreateProgram();
		if (programObject > 0) {
			gl2es2.glAttachShader(programObject, vertexShader);
			gl2es2.glAttachShader(programObject, fragmentShader);
			
			gl2es2.glLinkProgram(programObject);
			
			int[] ret = new int[1];
			IntBuffer retBuffer = IntBuffer.wrap(ret);
			gl2es2.glGetProgramiv(programObject, GL2ES2.GL_LINK_STATUS, retBuffer);
			if (0 == retBuffer.get(0)) {
				printLinkLog(programObject);
				gl2es2.glDeleteProgram(programObject);
				programObject = 0;
			}

			gl2es2.glDeleteShader(vertexShader);
			gl2es2.glDeleteShader(fragmentShader);
		}
	}
	
	return programObject;
}
 
开发者ID:galaxy-workstation,项目名称:AircraftDemo,代码行数:28,代码来源:ShaderImpl.java


示例13: display

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
@Override
public void display(GLAutoDrawable drawable) {
	// // TODO Auto-generated method stub
	GL2ES2 gl = drawable.getGL().getGL2ES2();

	gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	gl.glClear(GL.GL_COLOR_BUFFER_BIT);
	//
	// float c = 1.0f;
	// float s = 0.5f;
	//
	// // draw a triangle filling the window
	// gl.glBegin(GL.GL_TRIANGLES);
	// gl.glColor3f(1, 0, 0);
	// gl.glVertex2d(-c, -c);
	// gl.glColor3f(0, 1, 0);
	// gl.glVertex2d(0, c);
	// gl.glColor3f(0, 0, 1);
	// gl.glVertex2d(s, -s);
	// gl.glEnd();

	renderable.ortho2D(0.0f, 0.0f, Constant.RADIO, 1.0f);
	renderable.loadIdentity();
	renderable.scale(0.1f, 0.1f, 1.0f);
	renderable.translate(0.25f, 0.25f, 0.0f);
	renderable.render();
}
 
开发者ID:galaxy-workstation,项目名称:AircraftDemo,代码行数:28,代码来源:ShaderTest.java


示例14: convertTextureFormat

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
public static int convertTextureFormat(Format fmt) {
    switch (fmt) {
        case Alpha16:
        case Alpha8:
            return GL.GL_ALPHA;
        case Luminance8Alpha8:
        case Luminance16Alpha16:
            return GL.GL_LUMINANCE_ALPHA;
        case Luminance8:
        case Luminance16:
            return GL.GL_LUMINANCE;
        case RGB10:
        case RGB16:
        case BGR8:
        case RGB8:
        case RGB565:
            return GL.GL_RGB;
        case RGB5A1:
        case RGBA16:
        case RGBA8:
            return GL.GL_RGBA;
        case Depth:
            return GL2ES2.GL_DEPTH_COMPONENT;
        default:
            throw new UnsupportedOperationException("Unrecognized format: " + fmt);
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:28,代码来源:TextureUtil.java


示例15: convertShaderType

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
public int convertShaderType(ShaderType type) {
    switch (type) {
        case Fragment:
            return GL2ES2.GL_FRAGMENT_SHADER;
        case Vertex:
            return GL2ES2.GL_VERTEX_SHADER;
            // case Geometry:
            // return ARBGeometryShader4.GL_GEOMETRY_SHADER_ARB;
        default:
            throw new RuntimeException("Unrecognized shader type.");
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:13,代码来源:JoglRenderer.java


示例16: isShaderValid

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
@Override
protected boolean isShaderValid(Shader shader) {
    GL gl = GLContext.getCurrentGL();
    gl.getGL2().glValidateProgram(shader.getId());
    gl.getGL2().glGetProgramiv(shader.getId(), GL2ES2.GL_VALIDATE_STATUS, intBuf1);
    return intBuf1.get(0) == GL.GL_TRUE;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:8,代码来源:JoglRenderer.java


示例17: convertUsage

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
private int convertUsage(Usage usage) {
    switch (usage) {
        case Static:
            return GL.GL_STATIC_DRAW;
        case Dynamic:
            return GL.GL_DYNAMIC_DRAW;
        case Stream:
            return GL2ES2.GL_STREAM_DRAW;
        default:
            throw new RuntimeException("Unknown usage type: " + usage);
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:13,代码来源:JoglRenderer.java


示例18: compile

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
public void compile() {
	final GL2ES2 gl = GLContext.getCurrentGL().getGL2ES2();
	state = new ShaderState();
	state.setVerbose(true);
	final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader", "shader/bin",
			"block", true);
	final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader",
			"shader/bin", "block", true);
	final ShaderProgram sp0 = new ShaderProgram();
	sp0.add(gl, vp0, System.err);
	sp0.add(gl, fp0, System.err);
	state.attachShaderProgram(gl, sp0, true);
}
 
开发者ID:olamedia,项目名称:assets,代码行数:14,代码来源:Shader.java


示例19: readGLAudioBuffer

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
private void readGLAudioBuffer(GPU gpu, ByteBuffer audioByteBuffer, GLTexture renderTexture){
// Read and export previous results to sound card.
final GL2ES2 gl = gpu.getGl();
gpu.defaultFrameBuffers();
renderTexture.bind().readPixels(PixelReadOrder.RG, PixelReadDataType.FLOAT,
	audioByteBuffer).unbind();// RG_INTEGER throws INVALID_OPERATION!?
   }
 
开发者ID:jtrfp,项目名称:terminal-recall,代码行数:8,代码来源:SoundSystemKernel.java


示例20: generateRenderTarget

import javax.media.opengl.GL2ES2; //导入依赖的package包/类
private void generateRenderTarget( ) {
//Playback texture
getThreadManager().submitToGL(new Callable<Void>(){
    @Override
    public Void call() throws Exception {
	final GPU gpu = getGpu();
	//// Generate Texture
	gpu.defaultProgram();
	gpu.defaultTIU();
	gpu.defaultTexture();
	gpu.defaultFrameBuffers();
	final GLTexture newTexture = playbackTexture = gpu
		.newTexture()
		.bind()
		.setMagFilter(GL2ES2.GL_NEAREST)
		.setMinFilter(GL2ES2.GL_NEAREST)
		.setWrapS(GL2ES2.GL_CLAMP_TO_EDGE)
		.setWrapT(GL2ES2.GL_CLAMP_TO_EDGE)
		.setDebugName("playbackTexture")
		.setExpectedMinValue(-1, -1, -1, -1)
		.setExpectedMaxValue(1, 1, 1, 1)
		.setPreferredUpdateIntervalMillis(100)
		.setImage(GL2ES2.GL_RG32F, getBufferSizeFrames(),
			NUM_BUFFER_ROWS, GL2ES2.GL_RGBA, GL2ES2.GL_FLOAT,
			null);
	//// Generate Framebuffer
	gpu.defaultTexture();
	gpu.defaultTIU();
	playbackFrameBuffer = gpu
		.newFrameBuffer()
		.bindToDraw()
		.attachDrawTexture(newTexture,
			GL2ES2.GL_COLOR_ATTACHMENT0);
	return null;//FIXME: Should this reset to default texture/TIU afterward to improve performance?
    }}).get();
   }
 
开发者ID:jtrfp,项目名称:terminal-recall,代码行数:37,代码来源:SoundSystemKernel.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ScrollHandlerFX类代码示例发布时间:2022-05-22
下一篇:
Java IdUnusedException类代码示例发布时间: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