本文整理汇总了Java中javax.media.opengl.GL2ES2类的典型用法代码示例。如果您正苦于以下问题:Java GL2ES2类的具体用法?Java GL2ES2怎么用?Java GL2ES2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GL2ES2类属于javax.media.opengl包,在下文中一共展示了GL2ES2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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();
}
}
}
示例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();
}
}
}
示例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;
}
示例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.");
}
}
示例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);
}
}
示例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);
}
示例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()
}
示例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);
}
示例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";
}
}
示例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;
}
示例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();
}
示例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);
}
}
示例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.");
}
}