Jump to content
  • Advertisement
Sign in to follow this  
ControlDenied

OpenGL Rendering bitmaps

This topic is 5029 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Does anybody know how OpenGL converts real coordinates to pixels? I have some 3D models with points' coordinates lying in the cube -2.5 to 2.5 along each dimension (x,y,z) and I want to find the exact dimensions of the bitmaps so that none of the models get off the bitmap! Thanks for any help

Share this post


Link to post
Share on other sites
Advertisement
Can you be a bit more specific please ? I'm not sure to understand your problem (which may cause the lack of replies).

Share this post


Link to post
Share on other sites
Well, I mean that I think (I'm a beginner so maybe I'm wrong) that there is a standard way that OpenGL treats the real world coordinates while rendering. I have a 3D model in terms of points and triangles with its maximum world coordinate being 2.5. I render the model on the screen and then I catch the pixels in a bitmap. When I use 800x600 windows and bitmaps only a part of the model is visible.

My question is how can I calculate the right number of the dimensions in pixels for my windows / bitmaps so that the whole model is visible. Don't tell me to search the redbook, I've already done it but I did not know where exactly to search so I didn't find the answer. Maybe I should try for 1600x1600 pixels.

I hope I made it clear now.

Share this post


Link to post
Share on other sites
I see. In fact you want to snap a shot of your model rendered in 3D, and for instance save it as an image on disk, right ?

Currently you have :

/
/ |
/ |
+(0,600)------------------------(800,600)+
| / | |
| / | |
| / |
| / | |
| / | |
| / |
| /_ | |
| _ | |
| _ |
| _ | |
| _ | |
| _ |
| _ | |
| _| |
| |
+(0,0)----------------------------(800,0)+


And you want :

+(0,600)------------------------(800,600)+
| / |
| / | |
| / | |
| / | |
| / | |
| / | |
| / | |
| /_ | |
| _ | |
| _ | |
| _ | |
| _ | |
| _ | |
| _| |
| |
+(0,0)----------------------------(800,0)+



If you want an orthographic shot, it's pretty easy : just compute the axis-aligned bounding box of your object (roughly, compute the minimum and maximum X, Y and Z coordinates of your model) and feed them to glOrtho. You can also add some basic math for the model not to look distorted.

If you want a perspective shot it's still possible but more complex.

Share this post


Link to post
Share on other sites
Since a beginner I did not quite know how the whole mechanism of rendering a model works, and I had misunderstood some things like how is the view volume defined, view frustum, the projections... I studied from Real Time Rendering and the RedBook, so I made these things quite clear in my mind. I hope that now I can find the solution.

Thanks for your interest!!!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!