Jump to content

  • Log In with Google      Sign In   
  • Create Account


Sprite, Texture, image and bitmap. confused

  • You cannot reply to this topic
7 replies to this topic

#1 Sarkurd   Members   -  Reputation: 154

Like
0Likes
Like

Posted 11 June 2014 - 01:42 PM

Hi

I started to make game but i really don't understand whats Sprite, Texture,  and bitmap images vs normal png and jpeg images

sorry but i really don't know :D

 

 

Thanks

 



Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 11877

Like
0Likes
Like

Posted 11 June 2014 - 01:50 PM

I suspect the exact definitions depend on the context. Where did you read about these things? Was it when learning SFML?



#3 Sarkurd   Members   -  Reputation: 154

Like
0Likes
Like

Posted 11 June 2014 - 01:57 PM

I suspect the exact definitions depend on the context. Where did you read about these things? Was it when learning SFML?

yes i'm about to learn SFML



#4 Misantes   Members   -  Reputation: 414

Like
1Likes
Like

Posted 11 June 2014 - 01:59 PM

If you're using SFML,  you need to load a texture, then bind it to a sprite. A texture can be many formats, among them the jpeg and png formats you mentioned. Formats all vary, but there are important differences, but the most likely important difference for you is that a .png file can hold transparency information (so, if you don't want your sprite to look like a square or rectangle, you'll possibly use a png format). So, in simple terms,  you load a texture and stick it onto a sprite. The sprite will be an object you create.

 

So, think of the different formats as ways of storing the information of the "picture" that you want to use. They all store different information (such as transparancy) and store it in different ways. with SFML you don't need to be concerned with the way it stores the  information at this point, but be aware of what information it can store.

 

the SFML site has some pretty simple but also really useful tutorials on this.

 

http://www.sfml-dev.org/tutorials/2.1/graphics-sprite.php

 

and if that's feeling a bit abstract still, this video will walk you through it step by step:

 

https://www.youtube.com/watch?v=WFts4-62F6U


Edited by Misantes, 11 June 2014 - 02:07 PM.


#5 Álvaro   Crossbones+   -  Reputation: 11877

Like
1Likes
Like

Posted 11 June 2014 - 02:16 PM

I don't quite like Misantes's answer because it isn't precise enough, although perhaps you don't need more precision at this point. A texture is an object in memory that contains an image. You will typically read the image data from a file, and that's where the different formats come in. But the format is just a convention of how an image is represented in a file: Once you have loaded that image into a texture, it doesn't even make sense to talk about what format the texture uses.

 

I like the recommendation of using the PNG format for images that describe sprites, because of the availability of a transparency channel and because it doesn't use lossy compression, so you won't get funky compression artifacts.

 

I was also going to post a link to this SFML tutorial page: http://www.sfml-dev.org/tutorials/2.1/graphics-sprite.php

 

 

 



#6 Sarkurd   Members   -  Reputation: 154

Like
0Likes
Like

Posted 11 June 2014 - 02:21 PM

Thank you guys



#7 Misantes   Members   -  Reputation: 414

Like
1Likes
Like

Posted 11 June 2014 - 02:31 PM

@Alvaro,

 

You're totally right :) I just didn't want to overload him/her with too much technicality as it can be a bit confusing for a beginner (I know half the answers I get to questions on here tend to go over my head :P). But, your explanation definitely touches on some important points I glossed over, that if learned incorrectly at the start can cause problems later on in the learning process. Especially, that of the texture being an object in memory to be accessed later. Which, is important to note that you can use the same texture for multiple sprites.



#8 Kaptein   Prime Members   -  Reputation: 1844

Like
1Likes
Like

Posted 11 June 2014 - 02:32 PM

A sprite is whatever you want it to be, typically an image or part of an image shown on the screen. Bitmap is a term for a stored (binary) image. It could be on disk, stored as bits or in memory. When you load a PNG file its decompressed and stored in memory as a bitmap. From there you can store it on the GPU as a texture. A texture can be used when drawing. If you treat parts of a texture as a sprite, you have a spritesheet - there are many sprites on it.

 

Here's an example:

http://www.fabiobiondi.com/blog/wp-content/uploads/2012/08/runningGrant.png

 

As you can see, the texture coordinates you use when drawing is important: They define which portion of the spritesheet you are drawing from.

Imagine you assigned boundries around one of the characters shown in the spritesheet, and we will call that a frame. The boundries for a specific frame is defined by you, by specifying texture coordinates. You can animate the character by changing frames back and forth.

 

Here's an example of frames being changed over time, which makes a running animation:

http://www.pixeljoint.com/files/icons/full/sol_run_sprite_0.gif

 

As you can see, the frames boundries aren't optimal, but that doesn't really matter here because the character in the animation is completely visible.







PARTNERS