本文整理汇总了Java中com.googlecode.gwtgl.binding.WebGLShader类的典型用法代码示例。如果您正苦于以下问题:Java WebGLShader类的具体用法?Java WebGLShader怎么用?Java WebGLShader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebGLShader类属于com.googlecode.gwtgl.binding包,在下文中一共展示了WebGLShader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadShader
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
private WebGLShader loadShader(int shaderType, String shaderSource) {
// Create the shader object
WebGLShader shader = gl.createShader(shaderType);
if (shader == null) {
throw new RuntimeException();
}
// Load the shader source
gl.shaderSource(shader, shaderSource);
// Compile the shader
gl.compileShader(shader);
// Check the compile status
boolean compiled = gl.getShaderParameterb(shader, COMPILE_STATUS);
if (!compiled) {
// Something went wrong during compilation; get the error
throw new RuntimeException("Shader compile error: "
+ gl.getShaderInfoLog(shader));
}
return shader;
}
示例2: onModuleLoad
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
public void onModuleLoad() {
Canvas canvas = Canvas.createIfSupported();
canvas.setStyleName("MyCanvas");
canvas.setCoordinateSpaceWidth(400);
canvas.setCoordinateSpaceHeight(400);
RootLayoutPanel.get().add(canvas);
gl = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
gl.viewport(0, 0, 400, 400);
WebGLBuffer vertexBuffer = gl.createBuffer();
gl.bindBuffer(ARRAY_BUFFER, vertexBuffer);
gl.bufferData(ARRAY_BUFFER, Float32Array.create(VERTICES), STATIC_DRAW);
WebGLShader vertexShader = gl.createShader(VERTEX_SHADER);
gl.shaderSource(vertexShader, VERTEX_SHADER_SOURCE);
gl.compileShader(vertexShader);
WebGLShader fragmentShader = gl.createShader(FRAGMENT_SHADER);
gl.shaderSource(fragmentShader, FRAGMENT_SHADER_SOURCE);
gl.compileShader(fragmentShader);
program = gl.createProgram();
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
gl.useProgram(program);
gl.bindBuffer(ARRAY_BUFFER, vertexBuffer);
WebGLUniformLocation texture = gl.getUniformLocation(program, "texture");
gl.uniform1i(texture, 0);
int posAttr = gl.getAttribLocation(program, "position");
gl.vertexAttribPointer(posAttr, 3, FLOAT, false, 5*4, 0);
gl.enableVertexAttribArray(posAttr);
int texAttr = gl.getAttribLocation(program, "texcoord");
gl.vertexAttribPointer(texAttr, 2, FLOAT, false, 5*4, 3*4);
gl.enableVertexAttribArray(texAttr);
for(int i=0; i<TEXTURE_URLS.length; i++) {
loadTexture(TEXTURE_URLS[i], i);
}
}
示例3: getShader
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
private WebGLShader getShader(int type, String source) {
WebGLShader shader = GLES20.createShader(type);
GLES20.shaderSource(shader, source);
GLES20.compileShader(shader);
if (!GLES20.getShaderParameterb(shader, WebGLRenderingContext.COMPILE_STATUS)) {
throw new RuntimeException(GLES20.getShaderInfoLog(shader));
}
return shader;
}
示例4: attachShader
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
public final native void attachShader(WebGLProgram program, WebGLShader shader) /*-{
this.attachShader(program, shader);
}-*/;
示例5: compileShader
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
public final native void compileShader(WebGLShader shader) /*-{
this.compileShader(shader);
}-*/;
示例6: createShader
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
public final native WebGLShader createShader(int type) /*-{
return this.createShader(type);
}-*/;
示例7: deleteShader
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
public final native void deleteShader(WebGLShader shader) /*-{
this.deleteShader(shader);
}-*/;
示例8: detachShader
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
public final native void detachShader(WebGLProgram program, WebGLShader shader) /*-{
this.detachShader(program, shader);
}-*/;
示例9: getAttachedShaders
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
public final native JsArray<WebGLShader> getAttachedShaders(WebGLProgram program) /*-{
return this.getAttachedShaders(program);
}-*/;
示例10: getShaderInfoLog
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
public final native String getShaderInfoLog(WebGLShader shader) /*-{
return this.getShaderInfoLog(shader);
}-*/;
示例11: getShaderSource
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
public final native String getShaderSource(WebGLShader shader) /*-{
return this.getShaderSource(shader);
}-*/;
示例12: isShader
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
public final native boolean isShader(WebGLShader shader) /*-{
return this.isShader(shader);
}-*/;
示例13: shaderSource
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
public final native void shaderSource(WebGLShader shader, String source) /*-{
this.shaderSource(shader, source);
}-*/;
示例14: finishShaderLoad
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
public void finishShaderLoad(Scene scene, Material material) {
StringBuffer vertexShaderStringBuffer = new StringBuffer();
StringBuffer fragmentShaderStringBuffer = new StringBuffer();
// TODO precision
for (String k : shaderDefines.keySet()) {
if (shaderDefines.get(k) == null) {
vertexShaderStringBuffer.append("#define " + k + "\n");
fragmentShaderStringBuffer.append("#define " + k + "\n");
} else {
vertexShaderStringBuffer.append("#define " + k + " " + shaderDefines.get(k) + "\n");
fragmentShaderStringBuffer.append("#define " + k + " " + shaderDefines.get(k) + "\n");
}
}
vertexShaderStringBuffer.append(vertexShaderLoaded);
fragmentShaderStringBuffer.append(fragmentShaderLoaded);
String vertexShaderString = vertexShaderStringBuffer.toString();
String fragmentShaderString = fragmentShaderStringBuffer.toString();
WebGLShader vertexShader = getShader(WebGLRenderingContext.VERTEX_SHADER, vertexShaderString);
WebGLShader fragmentShader = getShader(WebGLRenderingContext.FRAGMENT_SHADER, fragmentShaderString);
webGLProgram = GLES20.createProgram();
GLES20.attachShader(webGLProgram, vertexShader);
GLES20.attachShader(webGLProgram, fragmentShader);
GLES20.linkProgram(webGLProgram);
if (!GLES20.getProgramParameterb(webGLProgram, WebGLRenderingContext.LINK_STATUS)) {
throw new RuntimeException("Could not initialize shaders");
}
GLES20.useProgram(webGLProgram);
onShaderLoaded();
GLES20.deleteShader(vertexShader);
GLES20.deleteShader(fragmentShader);
vertexShaderLoaded = null;
fragmentShaderLoaded = null;
shaderLoaded = true;
}
示例15: getShaderParameterb
import com.googlecode.gwtgl.binding.WebGLShader; //导入依赖的package包/类
/**
* Return the value for the passed pname given the passed shader.
*
* @param pname one of DELETE_STATUS, COMPILE_STATUS
*/
public final native boolean getShaderParameterb(WebGLShader shader, int pname) /*-{
return this.getShaderParameter(shader, pname);
}-*/;