Multimedia
  Home arrow Multimedia arrow Page 3 - Animation in OpenGL for Game Programming using SDL
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 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? 
Google.com  
MULTIMEDIA

Animation in OpenGL for Game Programming using SDL
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 10
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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
     

       

    MULTIMEDIA ARTICLES

    - Basic Lighting in OpenGL and SDL Game Progra...
    - 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-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek