xRalf
asked on
pixel operations
Hi,
can you advise me how to code this in C++ (opengl)?
1) I need to find out how many pixels are on the screen (what's the resolution)
2) I need to find out 3D coordinate of every pixel
3) I need to find out how to draw pixels of various colors on the screen.
// my pseudocode.
// I simplified it. This pseudocode looks a little strange. But if I know how to code this, I can continue with other things.
//Somewhere in the 3D space there is some 3D object. I want to determine the color of every pixel. This color is depending on the //distance between the pixelCoordinate and the point on the 3d object. (this two points have the same z coordinate).
determineTheNumberOfPixels ;
for each pixel do {
if (distance() == infinity) pixelColor = black;
if (distance() > 20 ) pixelColor = red;
else pixelColor = blue;
} endfor
DrawPixelsOnTheScreen;
distance() returns the distance I described above, you don't have to concern with it. (black box for you, which do the correct thing).
thanks everybody for help
can you advise me how to code this in C++ (opengl)?
1) I need to find out how many pixels are on the screen (what's the resolution)
2) I need to find out 3D coordinate of every pixel
3) I need to find out how to draw pixels of various colors on the screen.
// my pseudocode.
// I simplified it. This pseudocode looks a little strange. But if I know how to code this, I can continue with other things.
//Somewhere in the 3D space there is some 3D object. I want to determine the color of every pixel. This color is depending on the //distance between the pixelCoordinate and the point on the 3d object. (this two points have the same z coordinate).
determineTheNumberOfPixels
for each pixel do {
if (distance() == infinity) pixelColor = black;
if (distance() > 20 ) pixelColor = red;
else pixelColor = blue;
} endfor
DrawPixelsOnTheScreen;
distance() returns the distance I described above, you don't have to concern with it. (black box for you, which do the correct thing).
thanks everybody for help
ASKER
Sorry, I forgot to note that I'm programming in Unix
Have you tried using something like: XGetGeometry ? For parameter information type: 'man XGetGeometry'
corey
corey
ASKER
I found library Open Producer. (I want my program to be platform independent.) But I can't figure out how to code my pseudocode.
Well. probably the best way to do cross-platform development with OpenGL is to use a library like Qt or something that does the window creation for you.
As for part 2 and 3 of your question, do you have any sort of engine at all? You cannot just get 3D coordinates of random pixels without a 3D scene and engine running.
corey
As for part 2 and 3 of your question, do you have any sort of engine at all? You cannot just get 3D coordinates of random pixels without a 3D scene and engine running.
corey
ASKER
I'm using the osg library (www.openscenegraph.org). There's a function osgDB::readNodeFile(const std::string& str) where str is a file file.osg in which is defined the 3d scene.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For the moment, just the resolution question. This is determined outside of openGL by using the Win32 call http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsystemmetrics.asp ["GetSystemMetrics"]
corey