4

So I'm making an engine which can use directx10,11 and opengl.

So far everything worked well. It can render an image in opengl and directx correctly and both look the same.

Now I added rendertargets. Within DirectX it works very well and there is no problem so far. But using OpenGL the texture which I draw before is upside down and on the bottom right of the rendertarget.

  Screenshot

Do you guys have an idea what the problem is? And why does it work without the rendertarget correctly?

If needed I can send some code. I just need to sort it first.

Andon M. Coleman
  • 42,359
  • 2
  • 81
  • 106
PuRe
  • 179
  • 2
  • 13
  • BTW, what's the motivation for using Direct3D 10? There's really no good reason to use Direct3D 10 these days since all supported platforms that support D3D10 also support D3D11, and outdated systems with only the D3D10.x Runtime do not support [Feature Level 9.x](http://blogs.msdn.com/b/chuckw/archive/2012/06/20/direct3d-feature-levels.aspx) which makes broad hardware support possible with Direct3D 11. Plus the availability of [support libraries](http://blogs.msdn.com/b/chuckw/archive/2013/08/21/living-without-d3dx.aspx) for Direct3D 10 is negligible compared to Direct3D 11. – Chuck Walbourn Oct 23 '14 at 19:28

2 Answers2

6

OpenGL places the default origin of textures and thereby rendertargets in the bottom left. DirectX in the upper left. If you make the same assumptions about pixel layout it looks like the image is flipped. You can compensate this by applying a -1 scale on the projection matrix y-axis.

That the OpenGL image looks stretches is probably due to a wrong viewport being set when rendering to the FBO. Make sure that the viewport set with glViewport, when rendering to the FBO matches the dimensions and the target area in the render target.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
1

set the glviewport correctly, which resulted in the rendertarget only being upside down but in the correct position. now I just changed the UV.y within the vertex shader to be -UV.y and its fixed.

PuRe
  • 179
  • 2
  • 13