gpt4 book ai didi

com.google.gwt.webgl.client.WebGLRenderingContext类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 16:21:05 24 4
gpt4 key购买 nike

本文整理了Java中com.google.gwt.webgl.client.WebGLRenderingContext类的一些代码示例,展示了WebGLRenderingContext类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebGLRenderingContext类的具体详情如下:
包路径:com.google.gwt.webgl.client.WebGLRenderingContext
类名称:WebGLRenderingContext

WebGLRenderingContext介绍

[英]TODO: Lots more documentation needed here. Taken from the WebGL Draft Spec as of Aug 30, 2010: https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html TODO: Update this to the Feb 11 version.
[中]TODO:这里需要更多文档。摘自2010年8月30日的WebGL规范草案:https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.htmlTODO:将此更新至2月11日版本。

代码示例

代码示例来源:origin: libgdx/libgdx

@Override
public void glActiveTexture (int texture) {
  gl.activeTexture(texture);
}

代码示例来源:origin: libgdx/libgdx

public static WebGLProgram createShaderProgram (WebGLRenderingContext gl, String vertexSource, String fragmentSource) {
  WebGLShader vertexShader = getShader(gl, VERTEX_SHADER, vertexSource);
  WebGLShader fragmentShader = getShader(gl, FRAGMENT_SHADER, fragmentSource);
  WebGLProgram shaderProgram = gl.createProgram();
  gl.attachShader(shaderProgram, fragmentShader);
  gl.attachShader(shaderProgram, vertexShader);
  gl.linkProgram(shaderProgram);
  if (!gl.getProgramParameterb(shaderProgram, LINK_STATUS)) {
    throw new RuntimeException("Could not initialize shaders");
  }
  return shaderProgram;
}

代码示例来源:origin: libgdx/libgdx

@Override
public void glBindBuffer (int target, int buffer) {
  gl.bindBuffer(target, buffers.get(buffer));
}

代码示例来源:origin: threerings/playn

private void drawQuad() {
 // Use the sole shader program.
 gl.useProgram(shaderProgram);
 // Projection matrix.
 WebGLUniformLocation pUniform = gl.getUniformLocation(shaderProgram, "projectionMatrix");
 gl.uniformMatrix4fv(pUniform, false, projectionMatrix);
 // Model View matrix.
 WebGLUniformLocation mvUniform = gl.getUniformLocation(shaderProgram, "modelViewMatrix");
 gl.uniformMatrix4fv(mvUniform, false, modelViewMatrix);
 // Bird texture.
 gl.activeTexture(TEXTURE0);
 gl.uniform1i(gl.getUniformLocation(shaderProgram, "texture"), 0);
 // Vertices (position, texCoord)
 gl.bindBuffer(ARRAY_BUFFER, buffer);
 int vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "vertexPosition");
 gl.vertexAttribPointer(vertexPositionAttribute, 3, FLOAT, false, 0, 0);
 gl.enableVertexAttribArray(vertexPositionAttribute);
 int texCoordAttribute = gl.getAttribLocation(shaderProgram, "texCoord");
 gl.vertexAttribPointer(texCoordAttribute, 2, FLOAT, false, 0, 12 * Float32Array.BYTES_PER_ELEMENT);
 gl.enableVertexAttribArray(texCoordAttribute);
 // Elements.
 gl.bindBuffer(ELEMENT_ARRAY_BUFFER, indexBuffer);
 gl.drawArrays(TRIANGLE_STRIP, 0, 4);
}

代码示例来源:origin: threerings/playn

private WebGLFramebuffer createFramebuffer(int width, int height) {
 WebGLTexture tex = createTexture();
 fbuf = gl.createFramebuffer();
 gl.texImage2D(TEXTURE_2D, 0, RGBA, width, height, 0, RGBA, UNSIGNED_BYTE, null);
 WebGLRenderbuffer rbuf = gl.createRenderbuffer();
 gl.bindRenderbuffer(RENDERBUFFER, rbuf);
 gl.renderbufferStorage(RENDERBUFFER, RGBA4, width, height);
 gl.framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0, TEXTURE_2D, tex, 0);
 gl.framebufferRenderbuffer(FRAMEBUFFER, DEPTH_ATTACHMENT, RENDERBUFFER, rbuf);
 gl.bindTexture(TEXTURE_2D, null);
 gl.bindRenderbuffer(RENDERBUFFER, null);
 gl.bindFramebuffer(FRAMEBUFFER, null);
 return fbuf;
}

代码示例来源:origin: playn/playn

private void drawToFramebuffer() {
 gl.bindFramebuffer(FRAMEBUFFER, fbuf);
 gl.clear(COLOR_BUFFER_BIT | DEPTH_BUFFER_BIT);
 gl.bindTexture(TEXTURE_2D, birdTexture);
 drawQuad();
 gl.bindTexture(TEXTURE_2D, null);
 gl.bindFramebuffer(FRAMEBUFFER, null);
}

代码示例来源:origin: threerings/playn

private void initVertexBuffer() {
 buffer = gl.createBuffer();
 gl.bindBuffer(ARRAY_BUFFER, buffer);
 gl.bufferData(ARRAY_BUFFER, (12 + 8) * Float32Array.BYTES_PER_ELEMENT, STATIC_DRAW);
   42/2f,42/2f,z,
 };
 gl.bufferSubData(ARRAY_BUFFER, 0, ArrayUtils.createFloat32Array(positions));
   1.0f, 0.0f,
 };
 gl.bufferSubData(ARRAY_BUFFER, 12 * Float32Array.BYTES_PER_ELEMENT, ArrayUtils.createFloat32Array(texCoords));
 indexBuffer = gl.createBuffer();
 gl.bindBuffer(ELEMENT_ARRAY_BUFFER, indexBuffer);
 gl.bufferData(ELEMENT_ARRAY_BUFFER, ArrayUtils.createInt32Array(indices), STREAM_DRAW);

代码示例来源:origin: threerings/playn

private void init() {
 gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f);
 gl.enable(TEXTURE_2D);
 gl.enable(BLEND);
 gl.blendFunc(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);

代码示例来源:origin: threerings/playn

@Override
 public void glDrawElements(int mode, int count, int type, Buffer indices) {
  prepareDraw();
  if (boundElementArrayBuffer != elementBuffer) {
   gl.bindBuffer(ELEMENT_ARRAY_BUFFER, elementBuffer);
   boundElementArrayBuffer = elementBuffer;
  }
  gl.bufferData(ELEMENT_ARRAY_BUFFER, getTypedArray(indices, type, count * getTypeSize(type)),
         STREAM_DRAW);
//    if ("ModelPart".equals(debugInfo)) {
//      HtmlPlatform.log.info("drawElements f. ModelPart; count: " + count);
//    }
  gl.drawElements(mode, count, type, 0);
 }

代码示例来源:origin: com.googlecode.playn/playn-webgl

private WebGLTexture createTexture() {
 WebGLTexture tex = gl.createTexture();
 gl.bindTexture(TEXTURE_2D, tex);
 gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, LINEAR);
 gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, LINEAR);
 gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
 gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
 return tex;
}

代码示例来源:origin: threerings/playn

@Override
 public void onEvent(NativeEvent e) {
  // Load image data into the texture object once it's loaded.
  gl.bindTexture(TEXTURE_2D, tex);
  gl.texImage2D(TEXTURE_2D, 0, RGBA, RGBA, UNSIGNED_BYTE, img);
  gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, LINEAR);
  gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, LINEAR);
  gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
  gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
  gl.bindTexture(TEXTURE_2D, null);
 }
});

代码示例来源:origin: threerings/playn

@Override
public void glBufferData(int target, int byteSize, Buffer data, int usage) {
 if (target == GL_ARRAY_BUFFER) {
  if (requestedArrayBuffer != boundArrayBuffer) {
   gl.bindBuffer(target, requestedArrayBuffer);
   boundArrayBuffer = requestedArrayBuffer;
  }
 } else if (target == GL_ELEMENT_ARRAY_BUFFER) {
  if (requestedElementArrayBuffer != boundElementArrayBuffer) {
   gl.bindBuffer(target, requestedElementArrayBuffer);
   boundElementArrayBuffer = requestedElementArrayBuffer;
  }
 }
 gl.bufferData(target, getTypedArray(data, GL_BYTE, byteSize), usage);
}

代码示例来源:origin: io.playn/playn-html

@Override
public void glDrawElements(int mode, int count, int type, int indices) {
 prepareDraw();
 if (requestedElementArrayBuffer != boundElementArrayBuffer) {
  gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, requestedElementArrayBuffer);
  boundElementArrayBuffer = requestedElementArrayBuffer;
 }
 gl.drawElements(mode, count, type, indices);
}

代码示例来源:origin: threerings/playn

@Override
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized,
                 int stride, int ptr) {
 useNioBuffer &= ~(1 << indx);
 if (boundArrayBuffer != requestedArrayBuffer) {
  gl.bindBuffer(GL_ARRAY_BUFFER, requestedArrayBuffer);
  boundArrayBuffer = requestedArrayBuffer;
 }
 gl.vertexAttribPointer(indx, size, type, normalized, stride, ptr);
}

代码示例来源:origin: libgdx/libgdx

@Override
public void glAttachShader (int program, int shader) {
  WebGLProgram glProgram = programs.get(program);
  WebGLShader glShader = shaders.get(shader);
  gl.attachShader(glProgram, glShader);
}

代码示例来源:origin: libgdx/libgdx

@Override
public void glBindRenderbuffer (int target, int renderbuffer) {
  gl.bindRenderbuffer(target, renderBuffers.get(renderbuffer));
}

代码示例来源:origin: libgdx/libgdx

@Override
public void glClearColor (float red, float green, float blue, float alpha) {
  gl.clearColor(red, green, blue, alpha);
}

代码示例来源:origin: libgdx/libgdx

@Override
public void glBlendFunc (int sfactor, int dfactor) {
  gl.blendFunc(sfactor, dfactor);
}

代码示例来源:origin: libgdx/libgdx

@Override
public void glClear (int mask) {
  gl.clear(mask);
}

代码示例来源:origin: libgdx/libgdx

@Override
public void glBindFramebuffer (int target, int framebuffer) {
  gl.bindFramebuffer(target, frameBuffers.get(framebuffer));
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com