View Full Version : Read pixel color at world coords
Do you guys know of a way to read a pixel color in for example space position (10,10)??
What do you mean by space position? If you mean screencoordinates you just use glReadPixels.
You use it like this:
glReadPixels(10, 10, 1, 1, GL_RGB, GL_FLOAT, pixel);
Now pixel contains the RGB value for the pixel (10, 10) in viewportcoordinates.
Viewportcoordinates is not equal to windowcoordinates.
viewport x-axis is the same as window x-axis.
viewport y-axis is going from bottom to top, window y-axis is going from top to bottom.
In other words:
viewport_x_pos = window_x_pos
viewport_y_pos = window_height - window_y_pos
thanks for the answer, but i mean, world coordinates.
If i draw a vertex at(1,1,1), if it's possible to know the color of the pixel at that world coordinate?
08-30-2000, 06:19 AM
Doesn't make a lot of sense - pixels don't live in "world coordinates". Pixels result from the projection of the 3D world onto a 2D image.
I'm guessing you want to transform your point by the projection matrix to get viewport coords, then follow Bob's post.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.