Author Topic: blitting problem in rtt  (Read 2044 times)

Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
blitting problem in rtt
« on: August 31, 2016, 09:31:02 am »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: blitting problem in rtt
« Reply #1 on: August 31, 2016, 10:00:11 am »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: blitting problem in rtt
« Reply #2 on: August 31, 2016, 10:06:08 am »
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:

Code: [Select]
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();
}
}


Offline MichaelJPCT

  • float
  • ****
  • Posts: 264
    • View Profile
Re: blitting problem in rtt
« Reply #3 on: August 31, 2016, 06:48:52 pm »
thanks , it works.