Our Properties: Gamasutra GameCareerGuide IndieGames Indie Royale GDC IGF Game Developer Magazine GAO
My Message close
Contents
Understanding and Using OpenGL Texture Objects
 
 
Printer-Friendly VersionPrinter-Friendly Version
 
Latest News
spacer View All spacer
 
February 3, 2012
 
The role of self image in video game play [8]
 
Walmart provides coveted sales data to NPD's retail reports [4]
 
Interview: Seamus Blackley's new team of Atari coin-op superstars aim for iPad [8]
spacer
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
February 3, 2012
 
Slant Six Games
Software Engineer (Audio, UI, Tools, Systems)
 
Trion Worlds
Art Director
 
Blizzard Entertainment
Lead Software Engineer, Platform
 
Blizzard Entertainment
Senior Software Engineer, Server
 
Blizzard Entertainment
Mobile Web Front End Engineer
 
Blizzard Entertainment
Senior Software Engineer, Console -- Graphics Specialist
spacer
Latest Features
spacer View All spacer
 
February 3, 2012
 
arrow Happy Action, Happy Developer: Tim Schafer on Reimagining Double Fine [4]
 
arrow Building an iOS Hit: Phase 1 [7]
 
arrow Postmortem: Appy Entertainment's SpellCraft School of Magic [5]
 
arrow Talking Copycats with Zynga's Design Chief [75]
 
arrow Finnish Experiments, American Nightmare [10]
 
arrow SPONSORED FEATURE: Are Game Development Funds Doing Developers More Harm than Good? [12]
 
arrow Talking the Future of Minecraft
 
arrow Building Games that Run on Poor Mobile Connections [2]
spacer
Latest Blogs
spacer View All     Post     RSS spacer
 
February 3, 2012
 
Examining The Concept of the "Anti-Co-op" Experience [1]
 
Sixteen and a half cents
 
Last of the Seal Pelts: Revenue Doubles After Price Drop [2]
 
Game Biz Loan-sharking? aka Financing.
 
Talent Development for a Social Entertainment Company
spacer
About
spacer Editor-In-Chief/News Director:
Kris Graft
Features Director:
Christian Nutt
Senior Contributing Editor:
Brandon Sheffield
News Editors:
Frank Cifaldi, Tom Curtis, Mike Rose, Eric Caoili, Kris Graft
Editors-At-Large:
Leigh Alexander, Chris Morris
Advertising:
Jennifer Sulik
Recruitment:
Gina Gross
 
Feature Submissions
 
Comment Guidelines
Sponsor
Features
  Understanding and Using OpenGL Texture Objects
by Richard Wright [Programming]
1 comments Share on Twitter Share on Facebook RSS
 
 
July 23, 1999 Article Start Page 1 of 7 Next
 

With the advent of the OpenGL 1.1 specification, texture objects became part of the API. These texture objects have been available for quite some time as extensions to OpenGL 1.0 because of their incredible performance benefits. However, not everyone is aware of what texture objects are and why they are useful. Texture objects can improve your textured rendering performance by more than 10 times using the same hardware. That's a pretty bold claim, and I can demonstrate it with ease.

Typically, you load a texture image from either a disk file or a memory resource, or you generate it procedurally. You then upload the texture to OpenGL with a call to glTexImage2D(). Although I'm using 2D textures for this working example, everything that this article discusses applies equally well to 1D and 3D (OpenGL 1.2 only) textures. A typical scenario would go something like this:


1. Load texture image bits from a disk file.

2. Set the OpenGL texture parameters and environment (filters, border modes, and so on).

3. Call glTexImage2D (for 2D textures) to load the texture into OpenGL.

4. Draw some geometry with texture coordinates.

However, you wouldn't want to perform each of these steps for every frame of an animated scene. Repeatedly accessing a disk file can be pretty expensive, time wise. If you were using a single texture, you might first load the disk file and call glTexImage2D() after creating the rendering context. Then you'd render the geometry or scene while repeatedly changing the viewer's position or the object's orientation (whichever is appropriate). With a run-of-the-mill 3D card with OpenGL acceleration, you would get a reasonably good frame rate and thus a smooth animation.

Now suppose that a given scene contains multiple textured objects, each using one or more textures; or perhaps a single object with multiple textures. For our example, we'll use a spinning cube with a different texture on each face, plus a marble texture for the floor beneath this cube. This scene has a total of seven textures that need to be loaded.

Naturally, we don't want to access the disk seven times for every frame of our animation, as this would slow our rendering considerably. One popular technique is to combine all seven textures into one large texture that gets loaded once. Then, by tweaking the texture coordinates, you can effectively put different portions of the same texture on each side of the cube. The problem with this technique is that texture filtering will often introduce unsightly artifacts along the edges of your polygons. Another practical consideration is that most hardware imposes some limit on the maximum texture size for a single texture. You could quickly exhaust your available texture space without making much of a dent in your actual available texture memory.

So artistically, it's better to keep textures separate. How then do we avoid a texture load every time we need to change textures? A reasonable and intuitive choice would be to use display lists. Each display list would contain a call to glTexture2D() (or 1D or 3D) with the appropriate pointer for the given texture. This approach would save considerable time because it only accesses the disk seven times to read in the textures and does so before the animation loop. Saving seven or more disk accesses per frame seems to be a substantial optimization. Let's see what happens.

 
Article Start Page 1 of 7 Next
 
Comments

appy gurl
profile image
but is load bmp a function available in opengl?


none
 
Comment:
 




UBM Techweb
Game Network
Game Developers Conference | GDC Europe | GDC Online | GDC China | Gamasutra | Game Developer Magazine | Game Advertising Online
Game Career Guide | Independent Games Festival | Indie Royale | IndieGames

Other UBM TechWeb Networks
Business Technology | Business Technology Events | Telecommunications & Communications Providers

Privacy Policy | Terms of Service | Contact Us | Copyright © UBM TechWeb, All Rights Reserved.