Results 1 to 5 of 5

Thread: Animated Sprites

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Posts
    7

    Animated Sprites

    Hi,

    I just started to developon iPhone, so I'm discovering OpenGL

    I want to create animated sprites using glTexImage2D.
    What's the best way for this purpose ?
    - use glTexSubImage2D ?
    - create an array of textures ?

    By the way, where can I find an code sample demonstrating how to use glTexSubImage2D ?

    Thanks,
    Xavier

  2. #2
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: Animated Sprites

    Ideally you should use a single texture that contains all animation frames for the sprite(s). E.g. if you have 16 animation frames for a 32x32 sprite, arrange them side-by-side in a 512x32 texture. When you want to animate the sprite simply set the texture coordinates to select the right subrectangle from the texture. Also if you have several animated sprites try to place as many of them as possible in the same texture so you can draw all of them with a single draw call.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  3. #3
    Junior Member
    Join Date
    Jul 2008
    Posts
    7

    Re: Animated Sprites

    Using glTexSubImage2D is thus the good idea ?
    Or there is another way to set the texture coordinates ?

  4. #4
    Senior Member
    Join Date
    May 2006
    Posts
    353

    Re: Animated Sprites

    Quote Originally Posted by Xavier
    Using glTexSubImage2D is thus the good idea ?
    Or there is another way to set the texture coordinates ?
    glTexSubImage2D updates the texture image data itself, not the coordinates. And using it may be slow. In general you should upload all image data needed in the foreseeable future at initialisation time, e.g. level load time.

    You set the texture coordinates with glTexCoordPointer.
    Georg Kolling, Imagination Technologies
    Please ask questions specific to PowerVR hardware or SDKs on the PowerVR Insider Forum
    DevTech@imgtec.com | http://www.powervrinsider.com

  5. #5
    Junior Member
    Join Date
    Jul 2008
    Posts
    7

    Re: Animated Sprites

    I finally managed to draw my animated textures, thanks for your answers.

Similar Threads

  1. How to make eyes and mouth in a image animated and display
    By mathewi9 in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 03-29-2013, 06:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •