Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Copy texture onto another texture  (Read 5987 times)

0 Members and 1 Guest are viewing this topic.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Copy texture onto another texture
« on: October 09, 2012, 10:41:45 pm »
As far as I could see not much were written in the forum about this and the assignment/copy constructor seems to turn the texture to an image before creating a new texture. I am just wondering if there is a reason why you are not using directly the copy functions for textures provided by OpenGL? As far as I can see they exist in very old versions of OpenGL as well so it should be compatible.

While we are at it can't you create a update function like you have for images but for textures instead? Where you can copy a rect from one texture to another without going trough render textures? Would make things more simple.

Do you need a usecase? I want to generate some textures at runtime and currently I have to go trough sprites and render textures to get that. Works so far but later I can't move that data to a texture efficiently without having to make it into an image first which I will need.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Copy texture onto another texture
« Reply #1 on: October 09, 2012, 10:46:19 pm »
Which OpenGL functions do you refer to? As far as I know, there's no function to copy a texture to another texture.
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: Copy texture onto another texture
« Reply #2 on: October 09, 2012, 10:51:02 pm »
http://www.opengl.org/sdk/docs/man/xhtml/glCopyTexImage2D.xml

glCopyTexImage2D copies the texels from the buffer bound at the GL_READ_BUFFER buffer right? So if you bind the source texture buffer to that slot it should be possible to copy the textures over right?

I only did a quick google on it when I was trying to solve my problem so I might be wrong. Found some forums that said "It is impossible and you need a fullscreen quad" etc. etc. But reading the documentation I don't see any reason why it would be impossible?

Though what you want is probably the Sub version so you can copy only parts of the texture.
« Last Edit: October 09, 2012, 10:54:30 pm by Groogy »
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Copy texture onto another texture
« Reply #3 on: October 09, 2012, 10:56:19 pm »
GL_READ_BUFFER refers to the color and auxiliary buffers, not textures.
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: Copy texture onto another texture
« Reply #4 on: October 09, 2012, 11:05:09 pm »
Yeah I noticed but there are auxiliary buffers you could use I guess. But those doesn't seem to be fully supported on mobile hardware.(Really old graphics card have 4 buffers but mobile cards seems to have none)

So if I want to do a copy from a rendertexture to another texture for safe keeping I guess I'll have to either render it or do a copy trough system-memory pixels :(
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Copy texture onto another texture
« Reply #5 on: October 10, 2012, 08:06:06 am »
Yep, sorry. If there was a more direct solution, I'd use it.
Laurent Gomila - SFML developer