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

Author Topic: A question about textures and drawing  (Read 2730 times)

0 Members and 1 Guest are viewing this topic.

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
A question about textures and drawing
« on: June 13, 2014, 04:20:37 pm »
Hello.
I am wondering how to setup my sprites sheet for objects, tiles, and units...
Id personally put it in one big texture, but i was wondering If there are two draw calls with same texture, one after another, does it copy the texture again intro the gpu, or does it know not to copy texture again?

And if i wanted to find out something as this, would i read about GPUs, OpenGL or what?
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: A question about textures and drawing
« Reply #1 on: June 13, 2014, 04:22:02 pm »
The texture is already uploaded to the GPU when you create it. But if you make two draw calls with the same texture, you save one texture switch on the GPU, which is expensive.
Laurent Gomila - SFML developer

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Re: A question about textures and drawing
« Reply #2 on: June 13, 2014, 05:39:29 pm »
EDIT:: I drawn conclusion you meant, there is no switch performed.

The texture is already uploaded to the GPU when you create it. But if you make two draw calls with the same texture, you save one texture switch on the GPU, which is expensive.
I am still unsure of the answer :D.

Code: [Select]
sf::Texture tex;
sf::RenderWindow & win;
sf::VertexArray verArr1;
sf::VertexArray verArr2;
sf::RenderStates renSta;

//Load texture
//... add vertices to both verArr
verArr1.setPrimitiveType(sf::Quads);
renSta.texture = &tex;


win.draw(verArr1, renSta);//Draw 1
win.draw(verArr2, renSta);//Draw 2
In draw 1, the texture switch will occur, its the first draw call i ever made.
My question is: Is the Draw 2, gonna perform a texture switch as well?
« Last Edit: June 13, 2014, 05:44:15 pm by BaneTrapper »
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

Jonki

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: A question about textures and drawing
« Reply #3 on: June 13, 2014, 06:29:38 pm »
My question is: Is the Draw 2, gonna perform a texture switch as well?

No, it's not going to.
« Last Edit: June 13, 2014, 06:50:58 pm by Jonki »
dafuq did I just write?

BaneTrapper

  • Full Member
  • ***
  • Posts: 213
  • Do you even see this, i dont need it.
    • View Profile
    • Email
Re: A question about textures and drawing
« Reply #4 on: June 13, 2014, 09:57:56 pm »
BaneTrapperDev@hotmail.com Programing, Coding
Projects: Not in development(unfinished/playable):
http://en.sfml-dev.org/forums/index.php?topic=11073.msg76266#msg76266
UP and in Development: The Wanderer - Lost in time
http://en.sfml-dev.org/forums/index.php?topic=14563.0

 

anything