LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-19-2006, 03:31 PM   #1
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Rep: Reputation: 47
what is opengl?


What I know:

opengl is used to render/display 2d/3d
opengl is often accelerated by special video hardware
opengl has a lot of special effects and stuff.


What I need to know:

when working with opengl do you use opengl to hold all the 3d information, such as 3dObject is at x:y:z, move Object from XYZ to xyz, in which case you can check for intersections (collisions) of objects, and all that jazz?

OR

Do you write your own 3d managements engine, your own 3d space manager, and your own 3d objects, then somehow pass that information to opengl when you want ti displayed?
 
Old 02-19-2006, 03:38 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
http://www.opengl.org/resources/tutorials/

Open GL has a lot of primitives and capabilities. As far as I know, collision detection isn't among them. There are many altneratives, including this:

http://nehe.gamedev.net/data/lessons....asp?lesson=30

'Hope that helps .. PSM
 
Old 02-19-2006, 03:45 PM   #3
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled

opengl is used to render/display 2d/3d

hmm tempted to say yes to render, but ill say no (due to the way you have said it, but it all depends on what you mean)and no also for displaying. this is the job of another api such as sdl,glut,freeglut,windows..
opengl is often accelerated by special video hardware
yes

opengl has a lot of special effects and stuff.

what are you calling a special effect? if you mean its has lights then yes, if you mean it has a particle system then no.


What I need to know:
when working with opengl do you use opengl to hold all the 3d information, such as 3dObject is at x:y:z, move Object from XYZ to xyz, in which case you can check for intersections (collisions) of objects, and all that jazz?

hmmm what do you mean hold of the 3d info? normally you would create structures for objects, these structures have update, adjust position, draw func etc. Opengl does have fast transformations and rotations so that you can move "objects"; but it does not have any collision detection and all that "jazz" (whats music got to do with this lol).


Do you write your own 3d managements engine, your own 3d space manager, and your own 3d objects, then somehow pass that information to opengl when you want ti displayed?

All correct besides the passing to opengl, as I said at the top this is the responsilbilty of the api you are using to display to screen.

Last edited by dmail; 02-19-2006 at 03:47 PM.
 
Old 02-19-2006, 04:03 PM   #4
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Original Poster
Rep: Reputation: 47
This is all helpful. bascially I really wanted to write my own 3d space management system, then some point later down the road actually worry about displaying it in a form other than text coordinates. But at one point later I will want to have the objects actually displayed in 3d on the screen.

What I am gonna write:

A class that holds 3d objects and lets you manipulate them, it will also allow you to check if objects intersect, or would intersect if moved a specific distance in a specific direction. rotation will also be here.

A class that holds a 3d objects, vertices, surfaces, motion.

a class that contains the 3d manipulator, it will take care of gravity/collision detecting, etc.

At the end: Have the last class I just specified call the proper library stuff to display the 3d information to the screen

now, am I correct in assuming I only need to use opengl (or other library that uses opengl) in that last class that 'puts the information on screen'
 
Old 02-19-2006, 04:11 PM   #5
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Without sounding condescending have you ever done anything like this before? This is no small task.

Last edited by dmail; 02-19-2006 at 04:12 PM.
 
Old 02-19-2006, 05:05 PM   #6
Lazy Foo'
Member
 
Registered: Dec 2005
Location: LA
Distribution: SuSE 9.3 Pro
Posts: 32

Rep: Reputation: 15
OpenGL isn't a begginers API.

Hell look what it takes just to load an image:

Code:
////////////////////////////////////////////////
void TexQuad::load_image( std::string filename )
////////////////////////////////////////////////
{    
    //The loaded surface
    SDL_Surface *LoadedImage = NULL; 

    //The texture surface
    SDL_Surface *TextureImage = NULL; 
    
    //The format
    SDL_PixelFormat format;
        
    //Set format
    format.palette = NULL;
    format.BitsPerPixel = 32;
    format.BytesPerPixel = 4;
        
    //Set mask
    #if SDL_BYTEORDER == SDL_BIG_ENDIAN
    format.Rmask = 0xFF000000;
    format.Gmask = 0x00FF0000;
    format.Bmask = 0x0000FF00;
    format.Amask = 0x000000FF;
    #else
    format.Rmask = 0x000000FF;
    format.Gmask = 0x0000FF00;
    format.Bmask = 0x00FF0000;
    format.Amask = 0xFF000000;
    #endif
        
    //Set shift
    format.Rshift = 8; format.Gshift = 8; format.Bshift = 8; format.Ashift = 8;
        
    //Set loss
    format.Rloss = 0; format.Gloss = 0; format.Bloss = 0; format.Aloss = 0;
        
    //Load image
    LoadedImage = IMG_Load( filename.c_str() );
    
    //If the image loaded fine
    if( LoadedImage != NULL )
    {
        //Get image dimensions
        imgW = LoadedImage->w;
        imgH = LoadedImage->h;
        
        //Find 2^n width
        textW = 1;
        while( textW < imgW )
        {
            textW *= 2;    
        }
        
        //Find 2^n height
        textH = 1;
        while( textH < imgH )
        {
            textH *= 2;    
        }
        
        //Create 2^n surface
        TextureImage = SDL_CreateRGBSurface( SDL_SWSURFACE, (int)textW, (int)textH, format.BitsPerPixel, format.Rmask, format.Gmask, format.Bmask, format.Amask );
            
        //Blit our image to 2^n surface
        SDL_BlitSurface( LoadedImage, NULL, TextureImage, NULL );
            
        //Get rid of old surface
        SDL_FreeSurface( LoadedImage );
    }
    
    //If the image converted fine
    if( TextureImage != NULL )
    {  
        //Get the dimensions of the texture
        textW = TextureImage->w;
        textH = TextureImage->h;
            
        //Generate texture
        glGenTextures( 1, &texture );

        //Use newly made texture
        glBindTexture( GL_TEXTURE_2D, texture );
        
        //Create texture from loaded surface
        glTexImage2D( GL_TEXTURE_2D, 0, 4, TextureImage->w, TextureImage->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, TextureImage->pixels );
	    
        //Set filtering
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
	    
        //Get rid of temp surface
        SDL_FreeSurface( TextureImage );
    }
}
 
Old 02-19-2006, 09:45 PM   #7
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Original Poster
Rep: Reputation: 47
I have never done anything involving display or opengl or 3d as far as showing an image goes. However I have written small simple primative 3d managers. IK do not know the proper term, I have not taken classes or studied or read books on 3d, however I have written something that held objects in 3d space relative to a center point, could let me move and rotate those objects, and calculate distances betweent he closest points on each object. I have also programmed rhudimentary 3d object classes that held data for a 3d object including points and surfaces (all triangles). I did it once in java, then again in c++. However both those projects then stopped because I had no idea how to actualyl show the information on screen other than having it give the location of each point after a rotation or move and then verifying the new location against my hand calculations.

my problem is purely on the showing it on the screen side, not the programming the inner workings. I have almost no UI or GUI eperience except java awt, html and a LOAD of text interface. But I love data structures, algorythms, and the likes. I usually have a friend or contact program any advanced interface tot he backends I write.
 
Old 02-20-2006, 10:11 AM   #8
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
dictum ne agas -- do not do a thing already done

A cursory search through the Internet will reveal that this has indeed been done before.
 
Old 02-20-2006, 02:17 PM   #9
exodist
Senior Member
 
Registered: Aug 2003
Location: Portland, Oregon
Distribution: Arch
Posts: 1,374

Original Poster
Rep: Reputation: 47
I think that while your statement
Quote:
dictum ne agas -- do not do a thing already done
is nice when you are trying to produce something, or get something done quickly. It is also nice because it lets you go directly to the end result.

However! I find that it can also be dangerous, for instance you did not ask me WHY I am doing this... I am not doing this for production purposes, I am doing this because I want to learn how, and figure it out, I want the challange, I am not worried about failing. Using someone elses would be a waste of my time because I am not necissarily gonna use it for something. How can I learn about the inner workings of a 3d engine if I use someone elses.. and btw, what would I use it for?

I bore easily, if I were going to try to learn by reading the code to another project I would stop after a couple lines from sheer boredom, I need to DO.

Also while it is a waste of time to keep re-inventing the wheel, it is also dangerous to overspecialise, if we only have 1 then a single event could take it out. Or a better example... Windows, if we did not do what was already done we would be stuck with windows, we already had a gui os, but no, someone wanted something else and bam we have linux, bsd, skyos, etc.

Now similar is happening with kde vs gnome, everyone says end one project and focus on another, I disagree! While there are definate benefits to focusing on one, I would hate to have only one to choose from, it woudl be as though one of my freedoms has been torn away.

I am not saying we should re-invent everything 100 time, I see the benefits of re-using what has been done. However I recommend you find out why someone is doing something over before critisising them. I am doing it in this case to learn how it is done. If you were say paying me to do something then your money would of course give you the right to demand I do not spend time re-iventing everything. but on my own time do not even think of telling me how to do things.

I asked a simple question, for my own purposes, do not critisize my for your conclusion of what I am doing based on a short message.

BTW, I use enlightenment and windowmaker, kde and gnome are both far to binding, I do not want to do things their way!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
opengl? berrance Linux - Software 5 11-22-2004 11:05 AM
Overwrite Mesa OpenGL with ATI OpenGL Carl-Fredrik Slackware 12 10-01-2004 03:33 PM
OpenGL Artamir Linux - Newbie 3 04-07-2004 06:12 PM
Changing from MESA OpenGL to ATI OpenGL tillyoubreakit Linux - Hardware 19 10-07-2003 07:32 PM
OpenGL is needed by plib-1.7.0- but i have opengl ! qwijibow Linux - Newbie 0 08-05-2003 07:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration