Multimedia
  Home arrow Multimedia arrow Page 3 - Animation in OpenGL for Game Programmi...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
OLM
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MULTIMEDIA

Animation in OpenGL for Game Programming using SDL
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2007-08-28

    Table of Contents:
  • Animation in OpenGL for Game Programming using SDL
  • The Basics Continued: Coordinate Spaces
  • Animation APIs in OpenGL
  • Animation: a Basic Example

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    The Web Buyer's Guide is your best source for white papers on a wide range of IT products and services. This Week's Featured White Papers: Protecting Web Applications from Attack and Misuse by Citrix Systems

    Animation in OpenGL for Game Programming using SDL - Animation APIs in OpenGL
    (Page 3 of 4 )

    In OpenGL there are two functions that correspond to rotation and translation. They are:

    • glRotate*()
    • glTranslate*()

    The * indicates that there is more than one form of the function. In the case of the above functions there are two -- one with decimal parameters having d instead of * and the float version having f instead of *. Let's get down to details:

    glRotate*() is a function that rotates an object at the angle specified around specified axes. It terms of a matrix it "computes a matrix that performs a counterclockwise rotation of angle degrees about the vector from the origin through the point (x, y, z)." For the time being it is sufficient to understand that the rotation takes place according to the degrees specified for the axis given. The parameters are the angle through which the object has to be rotated and all the axes. The axes around which the rotation is to take place are given a value of 1 and others are given a 0. For example, if an object has to be rotated 10 degrees around the y-axis, then the statement would be

    glRotatef(10.0f,0,1,0);

    One important point about glRotate*() is that it follows the right-hand coordinate space rule; hence if the axis points towards the user, then the rotation would be counter-clockwise.

    glTranslate*() moves the object to the point specified by (x, y, z) passed as parameters, from the current coordinates. In terms of a matrix, "The current matrix is multiplied by this translation matrix, with the product replacing the current matrix." The distance to be moved is either positive or negative according to the parameters passed. For example, to move an object 2 units along the x-axis, the statement would be

    glTranslatef(1.0f,0.0f,0.0f);

    By setting the value of the x, y or z parameter to the required number of units, the object can be moved that many units parallel to the axis having a value greater or smaller than 0.

    Though the above APIs form the basis of animation, they cannot animate an object by themselves. It is here that logic comes into picture. Let's see how to achieve it in the next section.

    More Multimedia Articles
    More By A.P.Rajshekhar


       · In this article I have discussed about using OpenGL API for animation using SDL for...
     

       

    MULTIMEDIA ARTICLES

    - Working with Colors in OpenGL for Game Progr...
    - Animation in OpenGL for Game Programming usi...
    - Game Programming with SDL: Getting Started w...
    - Using OpenGL with SDL for Game Programming
    - Learning Sound for Game Programming using SDL
    - Game Programming using SDL: Raw Graphics and...
    - Game Programming using SDL: Getting Started
    - Network Radio With Icecast
    - Learning To SMILe




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway