Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7405291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:22:55+00:00 2026-05-29T05:22:55+00:00

I’m trying to develop a simple 2D fighting game using OpenGL, and I’m stuck

  • 0

I’m trying to develop a simple 2D fighting game using OpenGL, and I’m stuck on characters animation. The basic idea is to have a quad made of two triangles, and change the texture of this quad every frame or so. I’m using a sprite sheet to store the frames, and now I’m trying to find the most convenient way to cycle through them. The vertices coordinates and texture coordinates are stored in a vertex buffer object in the GPU memory, using the GL_STATIC_DRAW parameter.

The first idea was to load the sprite sheet using an external library such as SOIL in a single OpenGL texture (glGenTextures(1, &texture);), and then change the texture coordinates of the quad passed to the vertex shader every frame, so that if the animation was four frames long, I’d change the texture’s S coord to 0.0, 0.25, 0.5 and 0.75 and back to 0.0. But that means that I have to change my VBO quite often, and I thought that it could be quite expensive.

Another idea is to allocate an array of textures using glGenTextures(nFrames, &textureArray[0]); and then store a single frame for each array positionm and use glBindTexture(GL_TEXTURE_2D, textureArray[currFrame]); to apply different textures without having to change my VBO. But since I don’t want to split the sprite sheet into several images, I can’t think of any way to accomplish this using libraries such as SOIL.

What is the most convenient way to proceed in this case? I didn’t provide any code because first I’d like to evaluate several possibilities.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:22:55+00:00Added an answer on May 29, 2026 at 5:22 am

    I think that I would do it the same way as you described first. Change the coordinates in the texture to show the portion you are interested in. I’m not sure how expensive that would be, but changing the VBO (using a shader) should be extremely effective and not expensive at all. Taking the rule about “optimize late” into consideration, it would be extremely easy to redo it at a later time as well. If you’ve done it in a well designed way that is.

    But I do think it’s faster to change the S coords of the texture than to swap between several different textures.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.