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

Author Topic: sf::Texture and OpenGL  (Read 6892 times)

0 Members and 1 Guest are viewing this topic.

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
sf::Texture and OpenGL
« Reply #15 on: December 01, 2011, 03:22:42 am »
Do you know how you would use a sf::Texture with openGL?
The only way I can think of is converting it to a sf::Image and then
Code: [Select]
// Give the image to OpenGL
    glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, TextureResourceManager::textureResourceManager.getFile("./Data/Pedro.png").GetWidth(), TextureResourceManager::textureResourceManager.getFile("./Data/Pedro.png").GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE,TextureResourceManager::textureResourceManager.getFile("./Data/Pedro.png").CopyToImage().GetPixelsPtr() );
 

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Texture and OpenGL
« Reply #16 on: December 01, 2011, 07:44:16 am »
Isn't it what we talked about in the previous page? :roll:
Laurent Gomila - SFML developer

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
sf::Texture and OpenGL
« Reply #17 on: December 01, 2011, 08:12:25 pm »
Yea but you mentioned that it wasnt good to call sf::Texture.getImage() each frame as it takes quite a bit of resources to swap from GPU to CPU, so I was wondering how you use the sf::Texture straight away

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Texture and OpenGL
« Reply #18 on: December 01, 2011, 10:41:00 pm »
But why do you start with a texture? If all you want is to use the pixel data of an image file, load it directly as a sf::Image. And why does it have to happen each frame? The source is an image file, it doesn't change every frame, does it?
Laurent Gomila - SFML developer

Richy19

  • Full Member
  • ***
  • Posts: 190
    • View Profile
sf::Texture and OpenGL
« Reply #19 on: December 01, 2011, 10:44:59 pm »
no, but if I used renderTextures then they would

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Texture and OpenGL
« Reply #20 on: December 01, 2011, 10:49:16 pm »
If you used sf::RenderTexture it would be another problem, with another solution.
Laurent Gomila - SFML developer

DFPercush

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: sf::Texture and OpenGL
« Reply #21 on: May 30, 2012, 12:51:41 am »
Hate to resurrect a dead thread, but I don't think anyone ever explicitly said this: The OpenGL coordinate system, if no transformations are applied besides the identity matrix, puts the origin at the bottom left of the screen, when dealing with vertices, and at the bottom left of an image when dealing with textures. The positive Y axis points up in the plane of the screen/image, and the Z axis points out of the screen toward the viewer, meaning openGL is a right handed coordinate system. Of course, one can reverse any of these with a transformation matrix which simply negates the desired axis.