blitting problem in rtt

Started by MichaelJPCT, August 31, 2016, 09:31:02 AM

Previous topic - Next topic

MichaelJPCT

i found if i draw object3d in rtt (with World,Camera), then blitting in rtt had wrong size - much larger.
my rtt texture size is 128x32.

EgonOlsen

Yes, that's a know issue. You can workaround it by adjusting the blitting coordinates. I've some code lying around that does this. I actually wanted to add it to the core, but something prevented me from doing so...can't remember what it was though. I should really rework the blitting...anyway, I'll dig up the code and post it here.

EgonOlsen

Here you go...it's from my game Naroth and it's actually targeted to font rendering, but that doesn't matter. The math stay the same, so it should help:


package com.threed.jpct.games.gui.glfont;

import com.threed.jpct.FrameBuffer;
import com.threed.jpct.Texture;

/**
*
* @author EgonOlsen
*
*/
public class RenderTargetModifier implements CoordinateModifier {

private Texture target = null;

public RenderTargetModifier(Texture texture) {
target = texture;
}

@Override
public int convertX(FrameBuffer buffer, int x) {
return (int) ((float) x * ((float) buffer.getWidth() / (float) target.getWidth()));
}

@Override
public int convertY(FrameBuffer buffer, int y) {
return (int) ((float) y * ((float) buffer.getHeight() / (float) target.getHeight()));
}

@Override
public int getHeight() {
return target.getHeight();
}
}


MichaelJPCT