use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class FilterPostProcessor method initialize.
public void initialize(RenderManager rm, ViewPort vp) {
renderManager = rm;
renderer = rm.getRenderer();
viewPort = vp;
fsQuad = new Picture("filter full screen quad");
fsQuad.setWidth(1);
fsQuad.setHeight(1);
if (fbFormat == Format.RGB111110F && !renderer.getCaps().contains(Caps.PackedFloatTexture)) {
fbFormat = Format.RGB8;
}
Camera cam = vp.getCamera();
//save view port diensions
left = cam.getViewPortLeft();
right = cam.getViewPortRight();
top = cam.getViewPortTop();
bottom = cam.getViewPortBottom();
originalWidth = cam.getWidth();
originalHeight = cam.getHeight();
//first call to reshape
reshape(vp, cam.getWidth(), cam.getHeight());
}
use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class FilterPostProcessor method postFrame.
public void postFrame(FrameBuffer out) {
FrameBuffer sceneBuffer = renderFrameBuffer;
if (renderFrameBufferMS != null && !renderer.getCaps().contains(Caps.OpenGL32)) {
renderer.copyFrameBuffer(renderFrameBufferMS, renderFrameBuffer, true);
} else if (renderFrameBufferMS != null) {
sceneBuffer = renderFrameBufferMS;
}
renderFilterChain(renderer, sceneBuffer);
renderer.setFrameBuffer(outputBuffer);
//viewport can be null if no filters are enabled
if (viewPort != null) {
renderManager.setCamera(viewPort.getCamera(), false);
}
}
use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class HDRRenderer method reshape.
public void reshape(ViewPort vp, int w, int h) {
if (mainSceneFB != null) {
renderer.deleteFrameBuffer(mainSceneFB);
}
mainSceneFB = new FrameBuffer(w, h, 1);
mainScene = new Texture2D(w, h, bufFormat);
mainSceneFB.setDepthBuffer(Format.Depth);
mainSceneFB.setColorTexture(mainScene);
mainScene.setMagFilter(fbMagFilter);
mainScene.setMinFilter(fbMinFilter);
if (msFB != null) {
renderer.deleteFrameBuffer(msFB);
}
tone.setTexture("Texture", mainScene);
Collection<Caps> caps = renderer.getCaps();
if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample)) {
msFB = new FrameBuffer(w, h, numSamples);
msFB.setDepthBuffer(Format.Depth);
msFB.setColorBuffer(bufFormat);
vp.setOutputFrameBuffer(msFB);
} else {
if (numSamples > 1)
logger.warning("FBO multisampling not supported on this GPU, request ignored.");
vp.setOutputFrameBuffer(mainSceneFB);
}
createLumShaders();
}
use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class AwtPanel method attachTo.
public void attachTo(boolean overrideMainFramebuffer, ViewPort... vps) {
if (viewPorts.size() > 0) {
for (ViewPort vp : viewPorts) {
vp.setOutputFrameBuffer(null);
}
viewPorts.get(viewPorts.size() - 1).removeProcessor(this);
}
viewPorts.addAll(Arrays.asList(vps));
viewPorts.get(viewPorts.size() - 1).addProcessor(this);
this.attachAsMain = overrideMainFramebuffer;
}
use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.
the class AwtPanel method reshapeInThread.
private void reshapeInThread(int width, int height) {
byteBuf = BufferUtils.ensureLargeEnough(byteBuf, width * height * 4);
intBuf = byteBuf.asIntBuffer();
if (fb != null) {
fb.dispose();
fb = null;
}
fb = new FrameBuffer(width, height, 1);
fb.setDepthBuffer(Format.Depth);
fb.setColorBuffer(Format.RGB8);
fb.setSrgb(srgb);
if (attachAsMain) {
rm.getRenderer().setMainFrameBufferOverride(fb);
}
synchronized (lock) {
img = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
}
// synchronized (lock){
// img = (BufferedImage) getGraphicsConfiguration().createCompatibleImage(width, height);
// }
AffineTransform tx = AffineTransform.getScaleInstance(1, -1);
tx.translate(0, -img.getHeight());
transformOp = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
for (ViewPort vp : viewPorts) {
if (!attachAsMain) {
vp.setOutputFrameBuffer(fb);
}
vp.getCamera().resize(width, height, true);
// Main framebuffer should use RenderManager.notifyReshape().
for (SceneProcessor sp : vp.getProcessors()) {
sp.reshape(vp, width, height);
}
}
}
Aggregations