Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (546)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  2d Animation with VBO's  (Read 854 times)
0 Members and 1 Guest are viewing this topic.
Offline Devereux

Junior Newbie





« Posted 2013-10-02 19:10:04 »

Okay So I am not quite sure how to go about this.
I want to be able to create a sort of animation system where a sprite changes texture.

I am thinking it could be done if you reloaded the texture into opengl and store in a vbo everytime you change frame, but that would be horribly inefficient.

I'm not really sure how to go about this..
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #1 - Posted 2013-10-02 19:53:34 »

Dont make the sprite change texture, use an texture atlas merging all frames into one image.
changing the frame of the animation will be the fastest with shaders.
Offline Devereux

Junior Newbie





« Reply #2 - Posted 2013-10-03 06:10:07 »

I'm not very familiar with texture atlas's
I don't have a shader either, All the examples of shaders have been for 3d games. My game is only 2d.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #3 - Posted 2013-10-03 08:26:24 »

its the same thing, but without the z.

the 3 main options you have are:
- rebuild vbo each frame (using texture atlas, setting diffrent textcoords).
- bind diffrent texture each frame (just bind the texture of the current frame).
- use texture atlas with shaders, so you dont need to update the data each frame.
Offline Devereux

Junior Newbie





« Reply #4 - Posted 2013-10-03 16:44:27 »

Could you please explain texture atlas'.
I don't understand textures well enough to know how to implement them.
Offline opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #5 - Posted 2013-10-03 16:56:31 »

A texture atlas is just a big image that is split into smaller images. So, you could have a tile spritesheet that is, say, 512x512 pixels, and then you jut draw your textures in 16x16 little squares, for instance. Then you just create a bufferedimage and loop through the atlas and to pick a texture, you get the coordinates of the texture you need and then read the rgb data in that square. To get the texture you want, loop from coordinate x to x + width and y to y + height, and get the rgb values of each pixel.

The whole point of spritesheets is to reduce the number of images loaded. With a texture atlas, you only need to load the atlas and then you're done unless you need a different atlas.

Offline Devereux

Junior Newbie





« Reply #6 - Posted 2013-10-03 19:37:21 »

So would I store each subimage in a seperate bytebuffer, and then just store the bytebuffers and bind them everytime that subimage is used?
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #7 - Posted 2013-10-03 19:45:47 »

No, its just one image like this:


then instead of setting textcoord to 0f and 1f, you set the textcoord to "(1f / atlassize) * x" and "(1f / atlassize) * width".
Offline opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #8 - Posted 2013-10-03 19:52:58 »

Yeah, I guess you could do it that way, although I dont think loading an image would be that expensive. I guess if you constantly change textures you should store them. But if you're just changing them every couple minutes or never, its not worth the effort. Just make sure to sort your bind calls so you only bind each texture once!

Offline Devereux

Junior Newbie





« Reply #9 - Posted 2013-10-03 23:05:32 »

Alright thankyou Smiley
I'll look into it a bit
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (20 views)
2014-08-19 09:29:53

Tekkerue (21 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (55 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (28 views)
2014-08-08 02:01:56

Norakomi (35 views)
2014-08-06 19:49:38

BurntPizza (65 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!