本文整理汇总了Java中org.lwjgl.opengl.Pbuffer.makeCurrent方法的典型用法代码示例。如果您正苦于以下问题:Java Pbuffer.makeCurrent方法的具体用法?Java Pbuffer.makeCurrent怎么用?Java Pbuffer.makeCurrent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.opengl.Pbuffer
的用法示例。
在下文中一共展示了Pbuffer.makeCurrent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.lwjgl.opengl.Pbuffer; //导入方法依赖的package包/类
/**
* Initialise the PBuffer that will be used to render to
*
* @throws SlickException
*/
private void init() throws SlickException {
try {
Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());
final RenderTexture rt = new RenderTexture(false, true, false, false, RenderTexture.RENDER_TEXTURE_2D, 0);
pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), rt, null);
// Initialise state of the pbuffer context.
pbuffer.makeCurrent();
initGL();
GL.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
pbuffer.releaseTexImage(Pbuffer.FRONT_LEFT_BUFFER);
image.draw(0,0);
image.setTexture(tex);
Display.makeCurrent();
} catch (Exception e) {
Log.error(e);
throw new SlickException("Failed to create PBuffer for dynamic image. OpenGL driver failure?");
}
}
示例2: init
import org.lwjgl.opengl.Pbuffer; //导入方法依赖的package包/类
/**
* Initialise the PBuffer that will be used to render to
*
* @throws SlickException
*/
private void init() throws SlickException {
try {
Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());
pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), null, null);
// Initialise state of the pbuffer context.
pbuffer.makeCurrent();
initGL();
image.draw(0,0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0,
tex.getTextureWidth(),
tex.getTextureHeight(), 0);
image.setTexture(tex);
Display.makeCurrent();
} catch (Exception e) {
Log.error(e);
throw new SlickException("Failed to create PBuffer for dynamic image. OpenGL driver failure?");
}
}
示例3: getMaximumAntialiasingSamples
import org.lwjgl.opengl.Pbuffer; //导入方法依赖的package包/类
/**
* @return Maxiumum anti-aliasing samples supported. Required to have the LWJGL libraries loaded before calling
*/
public static int getMaximumAntialiasingSamples() {
int result = 0;
try {
Pbuffer pb = new Pbuffer( 10, 10, new PixelFormat( 24, 8, 24, 8, 0 ), null );
pb.makeCurrent();
boolean supported = GLContext.getCapabilities().GL_ARB_multisample;
if ( supported ) {
result = GL11.glGetInteger( GL30.GL_MAX_SAMPLES );
}
pb.destroy();
}
catch( LWJGLException e ) {
//e.printStackTrace();
}
return result;
}
示例4: getMaximumAntialiasingSamples
import org.lwjgl.opengl.Pbuffer; //导入方法依赖的package包/类
/**
* @return Maxiumum anti-aliasing samples supported. Required to have the LWJGL libraries loaded before calling
*/
public static int getMaximumAntialiasingSamples() {
int result = 0;
try {
Pbuffer pb = new Pbuffer( 10, 10, new PixelFormat( 32, 0, 24, 8, 0 ), null );
pb.makeCurrent();
boolean supported = GLContext.getCapabilities().GL_ARB_multisample;
if ( supported ) {
result = GL11.glGetInteger( GL30.GL_MAX_SAMPLES );
}
pb.destroy();
}
catch ( LWJGLException e ) {
//e.printStackTrace();
}
return result;
}
示例5: PbufferRenderer
import org.lwjgl.opengl.Pbuffer; //导入方法依赖的package包/类
PbufferRenderer(int width, int height, PixelFormat format, boolean use_copyteximage, OffscreenRendererFactory factory) throws LWJGLException {
super(width, height, use_copyteximage);
this.factory = factory;
pbuffer = new Pbuffer(width, height, format, null, null);
GLStateStack state_stack = new GLStateStack();
pbuffer.makeCurrent();
GLStateStack.setCurrent(state_stack);
try {
pbuffer.makeCurrent();
Renderer.dumpWindowInfo();
init();
if (!GLUtils.getGLBoolean(GL11.GL_DOUBLEBUFFER)) {
GL11.glReadBuffer(GL11.GL_FRONT);
GL11.glDrawBuffer(GL11.GL_FRONT);
}
} catch (LWJGLException e) {
pbuffer.destroy();
throw e;
}
}
示例6: init
import org.lwjgl.opengl.Pbuffer; //导入方法依赖的package包/类
/**
* Initialise the PBuffer that will be used to render to
*
* @throws SlickException
*/
private void init() throws SlickException {
try {
Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());
final RenderTexture rt = new RenderTexture(false, true, false, false, RenderTexture.RENDER_TEXTURE_2D, 0);
pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), rt, null);
// Initialise state of the pbuffer context.
pbuffer.makeCurrent();
initGL();
GL.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
pbuffer.releaseTexImage(Pbuffer.FRONT_LEFT_BUFFER);
if (image.getTexture()!=null)
image.draw(0,0);
Graphics.setCurrent(this); //this means you need to call flush() after getGraphics()
image.setTexture(tex);
Display.makeCurrent();
} catch (Exception e) {
Log.error(e);
throw new SlickException("Failed to create PBuffer for dynamic image. OpenGL driver failure?");
}
}
示例7: init
import org.lwjgl.opengl.Pbuffer; //导入方法依赖的package包/类
/**
* Initialise the PBuffer that will be used to render to
*
* @throws SlickException
*/
private void init() throws SlickException {
try {
Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());
pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), null, null);
// Initialise state of the pbuffer context.
pbuffer.makeCurrent();
initGL();
if (image.getTexture()!=null) {
image.draw(0,0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0,
tex.getTextureWidth(),
tex.getTextureHeight(), 0);
}
Graphics.setCurrent(this); //this means you need to call flush() after getGraphics
image.setTexture(tex);
Display.makeCurrent();
} catch (Exception e) {
Log.error(e);
throw new SlickException("Failed to create PBuffer for dynamic image. OpenGL driver failure?");
}
}
示例8: initInThread
import org.lwjgl.opengl.Pbuffer; //导入方法依赖的package包/类
protected void initInThread(){
if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0){
logger.severe("Offscreen surfaces are not supported.");
return;
}
pixelFormat = new PixelFormat(settings.getBitsPerPixel(),
0,
settings.getDepthBits(),
settings.getStencilBits(),
settings.getSamples());
width = settings.getWidth();
height = settings.getHeight();
try{
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread thread, Throwable thrown) {
listener.handleError("Uncaught exception thrown in "+thread.toString(), thrown);
}
});
pbuffer = new Pbuffer(width, height, pixelFormat, null, null, createContextAttribs());
pbuffer.makeCurrent();
renderable.set(true);
logger.info("Offscreen buffer created.");
printContextInitInfo();
} catch (LWJGLException ex){
listener.handleError("Failed to create display", ex);
} finally {
// TODO: It is possible to avoid "Failed to find pixel format"
// error here by creating a default display.
}
super.internalCreate();
listener.initialize();
}
示例9: renderImage
import org.lwjgl.opengl.Pbuffer; //导入方法依赖的package包/类
public static BufferedImage renderImage(int width, int height, Runnable renderer) throws LWJGLException, IOException {
synchronized (PBUFFER_LOCK) {
ContextAttribs contextAtrributes = new ContextAttribs(1, 1);
contextAtrributes.withForwardCompatible(true);
Pbuffer pbuffer = new Pbuffer(width, height, new PixelFormat(), null, null, contextAtrributes);
pbuffer.makeCurrent();
if (pbuffer.isBufferLost()) {
pbuffer.destroy();
return null;
}
IntBuffer pixels = ByteBuffer.allocateDirect(width * height * 4).order(ByteOrder.nativeOrder()).asIntBuffer();
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
renderer.run();
glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
bi.setRGB(x, y, pixels.get((height - y - 1) * width + x));
}
}
pbuffer.destroy();
return bi;
}
}
示例10: initInThread
import org.lwjgl.opengl.Pbuffer; //导入方法依赖的package包/类
protected void initInThread(){
if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0){
logger.severe("Offscreen surfaces are not supported.");
return;
}
pixelFormat = new PixelFormat(settings.getBitsPerPixel(),
0,
settings.getDepthBits(),
settings.getStencilBits(),
settings.getSamples());
width = settings.getWidth();
height = settings.getHeight();
try{
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread thread, Throwable thrown) {
listener.handleError("Uncaught exception thrown in "+thread.toString(), thrown);
}
});
//String rendererStr = settings.getString("Renderer");
// if (rendererStr.startsWith("LWJGL-OpenGL3")){
// ContextAttribs attribs;
// if (rendererStr.equals("LWJGL-OpenGL3.1")){
// attribs = new ContextAttribs(3, 1);
// }else{
// attribs = new ContextAttribs(3, 0);
// }
// attribs.withForwardCompatible(true);
// attribs.withDebug(false);
// Display.create(pf, attribs);
// }else{
pbuffer = new Pbuffer(width, height, pixelFormat, null, null, createContextAttribs());
// }
pbuffer.makeCurrent();
renderable.set(true);
logger.info("Offscreen buffer created.");
printContextInitInfo();
} catch (LWJGLException ex){
listener.handleError("Failed to create display", ex);
} finally {
// TODO: It is possible to avoid "Failed to find pixel format"
// error here by creating a default display.
}
super.internalCreate();
listener.initialize();
}