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

Author Topic: Some newby questions !  (Read 2669 times)

0 Members and 3 Guests are viewing this topic.

anna_linkpy

  • Newbie
  • *
  • Posts: 4
    • View Profile
Some newby questions !
« on: July 16, 2015, 09:29:29 pm »
Helloooooo thereeeee ! :D

So, I'm not really a newby, but I never wanted to use SFML for doing what I want to do. And here comes my questions :

I/ About sf::Sprite :
sf::Sprite sprite = // ... //

// ... Code code code ... //

// Drawing part
sprite.setTextureRect (// ... //);
window.draw (sprite);
sprite.setTextureRect (// ... //);
sprite.setPosition (// ... //);
window.draw (sprite);


If I have got a texture atlas, this code will works or not ?

II/ No sprite batch for optimized drawing ?

III/ It was a retoric question ! But, How can I optimize map drawing ?

Thanks for your answers ! :3

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Some newby questions !
« Reply #1 on: July 16, 2015, 09:43:19 pm »
If I have got a texture atlas, this code will works or not ?
Have you considered trying? You could answer your own question in 5minutes.

 
II/ No sprite batch for optimized drawing ?

III/ It was a retoric question ! But, How can I optimize map drawing ?
Look into sf::VertexArray. But make sure you have an actual performance problem first.

anna_linkpy

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Some newby questions !
« Reply #2 on: July 16, 2015, 09:52:06 pm »
Sorry, I'm a Löve2D user, so I'm used to LuaJIT and it's speed (with my projet, I checked every "draw" call, and even with this my render was slow : 102FPS... Or it was pretty fast if we consider my actual PC :o ).

I will try and go look for VertexBuffer.

PS: I don't do this for a performance problem, I'm just maniac and I want my game to be fast and enjoyable on very old PC ^^

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Some newby questions !
« Reply #3 on: July 16, 2015, 09:53:53 pm »
You're over-optimizing. Don't bother at the moment, no matter the final goal. You should optimize when you have issue. 102 FPS is more than sufficient. At that amount, it doesn't really matter.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Some newby questions !
« Reply #4 on: July 16, 2015, 10:04:45 pm »
I'd go as far as saying that if you currently do 102fps, then set a sane framerate limit (like 60) and save some CPU time/power. There's no point wasting cycles rendering a bunch of redundant frames that won't even make any visual difference to the player.
Optimizing for (or at least rendering) more fps beyond what the user can actually notice is a waste of time (and energy) in most cases (IMHO).
« Last Edit: July 16, 2015, 10:11:58 pm by Jesper Juhl »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Some newby questions !
« Reply #5 on: July 16, 2015, 10:31:27 pm »
I will try and go look for VertexBuffer.
I said sf::VertexArray, not VertexBuffer.
« Last Edit: July 16, 2015, 10:33:20 pm by Jesper Juhl »

anna_linkpy

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Some newby questions !
« Reply #6 on: July 18, 2015, 12:18:38 pm »
Yes, it's VertexArray, not VertexBuffer sorry ^^'

But, I look at the API... I see that VertexArray class doesn't have texturing method... How can I use texture with this class ?

shadowmouse

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
Re: Some newby questions !
« Reply #7 on: July 18, 2015, 03:12:39 pm »
Have a look at the vertex array tutorial. It's usually better to start with the tutorial for things like this and then check the API docs for syntax. http://www.sfml-dev.org/tutorials/2.3/graphics-vertex-array.php

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Some newby questions !
« Reply #8 on: July 18, 2015, 04:15:56 pm »
Vertex arrays do allow texturing. They are mainly just a collection of vertices, each with position, colour, and texture co-ordinates. The tutorial that shadowmouse linked should get you started (or be enough as it's plenty of information for most cases) even has a section on texturing!
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

anna_linkpy

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Some newby questions !
« Reply #9 on: July 18, 2015, 04:52:02 pm »
Okayyyyy ! So awesome !

When I looked at the API, I didn't see any function for drawing a VertexArray with a texture ! Now I can start my project ! Thanks a lot !  :D

 

anything