本文整理汇总了Java中javax.media.opengl.GLContext.getCurrentGL方法的典型用法代码示例。如果您正苦于以下问题:Java GLContext.getCurrentGL方法的具体用法?Java GLContext.getCurrentGL怎么用?Java GLContext.getCurrentGL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.opengl.GLContext
的用法示例。
在下文中一共展示了GLContext.getCurrentGL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteShader
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
public void deleteShader(Shader shader) {
if (glslVer != -1) {
if (shader.getId() == -1) {
logger.warning("Shader is not uploaded to GPU, cannot delete.");
return;
}
GL gl = GLContext.getCurrentGL();
for (ShaderSource source : shader.getSources()) {
if (source.getId() != -1) {
gl.getGL2().glDetachShader(shader.getId(), source.getId());
// the next part is done by the GLObjectManager automatically
// glDeleteShader(source.getId());
}
}
// kill all references so sources can be collected
// if needed.
shader.resetSources();
gl.getGL2().glDeleteProgram(shader.getId());
statistics.onDeleteShader();
}
}
示例2: updateFrameBufferAttachment
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
@Override
public void updateFrameBufferAttachment(FrameBuffer fb, RenderBuffer rb) {
boolean needAttach;
if (rb.getTexture() == null) {
// if it hasn't been created yet, then attach is required.
needAttach = rb.getId() == -1;
updateRenderBuffer(fb, rb);
}
else {
needAttach = false;
updateRenderTexture(fb, rb);
}
if (needAttach) {
GL gl = GLContext.getCurrentGL();
gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, convertAttachmentSlot(rb.getSlot()),
GL.GL_RENDERBUFFER, rb.getId());
}
}
示例3: updateDisplayList
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
private void updateDisplayList(Mesh mesh) {
GL gl = GLContext.getCurrentGL();
if (mesh.getId() != -1) {
// delete list first
gl.getGL2().glDeleteLists(mesh.getId(), mesh.getId());
mesh.setId(-1);
}
// create new display list
// first set state to NULL
applyRenderState(RenderState.NULL);
// disable lighting
setLighting(null);
int id = gl.getGL2().glGenLists(1);
mesh.setId(id);
gl.getGL2().glNewList(id, GL2.GL_COMPILE);
renderMeshDefault(mesh, 0, 1);
gl.getGL2().glEndList();
}
示例4: readFrameBuffer
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf) {
GL gl = GLContext.getCurrentGL();
if (fb != null) {
RenderBuffer rb = fb.getColorBuffer();
if (rb == null) {
throw new IllegalArgumentException("Specified framebuffer"
+ " does not have a colorbuffer");
}
setFrameBuffer(fb);
if (context.boundReadBuf != rb.getSlot()) {
gl.getGL2().glReadBuffer(GL.GL_COLOR_ATTACHMENT0 + rb.getSlot());
context.boundReadBuf = rb.getSlot();
}
}
else {
setFrameBuffer(null);
}
gl.glReadPixels(vpX, vpY, vpW, vpH, GL2GL3.GL_BGRA, GL.GL_UNSIGNED_BYTE, byteBuf);
}
示例5: isShaderValid
import javax.media.opengl.GLContext; //导入方法依赖的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;
}
示例6: blitFramebuffer
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
@Override
protected void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0,
int dstY0, int dstX1, int dstY1, int mask, int filter) {
GL gl = GLContext.getCurrentGL();
gl.getGL2().glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask,
filter);
}
示例7: updateRenderTexture
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
public void updateRenderTexture(FrameBuffer fb, RenderBuffer rb) {
GL gl = GLContext.getCurrentGL();
Texture tex = rb.getTexture();
if (tex.isUpdateNeeded()) {
updateTextureData(tex);
}
gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, convertAttachmentSlot(rb.getSlot()),
convertTextureType(tex.getType()), tex.getId(), 0);
}
示例8: updateRenderBuffer
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
private void updateRenderBuffer(FrameBuffer fb, RenderBuffer rb) {
GL gl = GLContext.getCurrentGL();
int id = rb.getId();
if (id == -1) {
gl.glGenRenderbuffers(1, intBuf1);
id = intBuf1.get(0);
rb.setId(id);
}
if (context.boundRB != id) {
gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, id);
context.boundRB = id;
}
if (fb.getWidth() > maxRBSize || fb.getHeight() > maxRBSize) {
throw new UnsupportedOperationException("Resolution " + fb.getWidth() + ":"
+ fb.getHeight() + " is not supported.");
}
if (fb.getSamples() > 0 && renderbufferStorageMultisample) {
int samples = fb.getSamples();
if (maxFBOSamples < samples) {
samples = maxFBOSamples;
}
gl.getGL2()
.glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, samples,
TextureUtil.convertTextureFormat(rb.getFormat()), fb.getWidth(),
fb.getHeight());
}
else {
gl.glRenderbufferStorage(GL.GL_RENDERBUFFER,
TextureUtil.convertTextureFormat(rb.getFormat()), fb.getWidth(), fb.getHeight());
}
}
示例9: checkTexturingUsed
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
private void checkTexturingUsed() {
IDList textureList = context.textureIndexList;
GL gl = GLContext.getCurrentGL();
// old mesh used texturing, new mesh doesn't use it
// should actually go through entire oldLen and
// disable texturing for each unit.. but that's for later.
if (textureList.oldLen > 0 && textureList.newLen == 0) {
gl.glDisable(GL.GL_TEXTURE_2D);
}
}
示例10: updateBufferData
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
public void updateBufferData(VertexBuffer vb) {
GL gl = GLContext.getCurrentGL();
int bufId = vb.getId();
if (bufId == -1) {
// create buffer
gl.glGenBuffers(1, intBuf1);
bufId = intBuf1.get(0);
vb.setId(bufId);
objManager.registerForCleanup(vb);
}
int target;
if (vb.getBufferType() == VertexBuffer.Type.Index) {
target = GL.GL_ELEMENT_ARRAY_BUFFER;
if (context.boundElementArrayVBO != bufId) {
gl.glBindBuffer(target, bufId);
context.boundElementArrayVBO = bufId;
}
}
else {
target = GL.GL_ARRAY_BUFFER;
if (context.boundArrayVBO != bufId) {
gl.glBindBuffer(target, bufId);
context.boundArrayVBO = bufId;
}
}
int usage = convertUsage(vb.getUsage());
Buffer data = vb.getData();
data.rewind();
gl.glBufferData(target, data.capacity() * vb.getFormat().getComponentSize(), data, usage);
vb.clearUpdateNeeded();
}
示例11: setLighting
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
public void setLighting(LightList list) {
if (glslVer == -1) {
GL gl = GLContext.getCurrentGL();
if (list == null || list.size() == 0) {
// turn off lighting
gl.glDisable(GLLightingFunc.GL_LIGHTING);
return;
}
gl.glEnable(GLLightingFunc.GL_LIGHTING);
gl.getGL2().glShadeModel(GLLightingFunc.GL_SMOOTH);
float[] temp = new float[4];
// reset model view to specify
// light positions in world space
// instead of model space
// gl.glPushMatrix();
// gl.glLoadIdentity();
for (int i = 0; i < list.size() + 1; i++) {
int lightId = GLLightingFunc.GL_LIGHT0 + i;
if (list.size() <= i) {
// goes beyond the num lights we need
// disable it
gl.glDisable(lightId);
break;
}
Light l = list.get(i);
if (!l.isEnabled()) {
gl.glDisable(lightId);
continue;
}
ColorRGBA color = l.getColor();
color.toArray(temp);
gl.glEnable(lightId);
gl.getGL2().glLightfv(lightId, GLLightingFunc.GL_DIFFUSE, temp, 0);
gl.getGL2().glLightfv(lightId, GLLightingFunc.GL_SPECULAR, temp, 0);
ColorRGBA.Black.toArray(temp);
gl.getGL2().glLightfv(lightId, GLLightingFunc.GL_AMBIENT, temp, 0);
switch (l.getType()) {
case Directional:
DirectionalLight dl = (DirectionalLight) l;
dl.getDirection().toArray(temp);
temp[3] = 0f; // marks to GL its a directional light
gl.getGL2().glLightfv(lightId, GLLightingFunc.GL_POSITION, temp, 0);
break;
case Point:
PointLight pl = (PointLight) l;
pl.getPosition().toArray(temp);
temp[3] = 1f; // marks to GL its a point light
gl.getGL2().glLightfv(lightId, GLLightingFunc.GL_POSITION, temp, 0);
break;
}
}
// restore modelview to original value
// gl.glPopMatrix();
}
}
示例12: genFramebufferId
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
@Override
protected int genFramebufferId() {
GL gl = GLContext.getCurrentGL();
gl.glGenFramebuffers(1, intBuf1);
return intBuf1.get(0);
}
示例13: bindElementArrayBuffer
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
@Override
protected void bindElementArrayBuffer(int buffer) {
GL gl = GLContext.getCurrentGL();
gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, buffer);
}
示例14: bindFramebuffer
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
@Override
protected void bindFramebuffer(int framebuffer) {
GL gl = GLContext.getCurrentGL();
gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, framebuffer);
}
示例15: bindDrawFramebuffer
import javax.media.opengl.GLContext; //导入方法依赖的package包/类
@Override
protected void bindDrawFramebuffer(int framebuffer) {
GL gl = GLContext.getCurrentGL();
gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, framebuffer);
}