getting pixels from a texture
Is there any way to get a pixel from a texture object? Say I want to determine the color of pixel (10,10) from my texture.
---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Sure, store the buffer you pass to glTexImage2D and look it up yourself 
Seriously, if you want to know fast, that's the way to go. If you use client storage as well, keeping the buffer around doesn't cost you anything.
There is a glGetTexImage, but it's probably dog-slow.

Seriously, if you want to know fast, that's the way to go. If you use client storage as well, keeping the buffer around doesn't cost you anything.
There is a glGetTexImage, but it's probably dog-slow.
I agree with OSC. Though I usually don't look up the texture values, I can keep the original buffer in my texture class. Since textures in moderately sized games don't take up too much, it is acceptable, memory vise, imo.
- D.G
- D.G
Curious is to why you need to know the value? I am going to be doing the samething soon once I finish my shootem up and work on a RTS top down view. I am going to need to know the value of each textures pixel so I can check to see if the weapon that was fired has run aground.
Quote:Originally posted by Mars_999
Curious is to why you need to know the value? I am going to be doing the samething soon once I finish my shootem up and work on a RTS top down view. I am going to need to know the value of each textures pixel so I can check to see if the weapon that was fired has run aground.
I don't quite get what you want to do...
Quote:Originally posted by DoooG
I don't quite get what you want to do...
I need to know the value of each pixel on the screen in grayscale to determine whether or not the weapon has run into a hill, trees whatever the case is. So I need the tileset and a grayscale of that tileset and need to check each pixel on that grayscale to see what value it is. Hope that clears that up?
Quote:Originally posted by Mars_999
I need to know the value of each pixel on the screen in grayscale to determine whether or not the weapon has run into a hill, trees whatever the case is. So I need the tileset and a grayscale of that tileset and need to check each pixel on that grayscale to see what value it is. Hope that clears that up?
I see, but that seems to have nothing to do with the actual texture, its just a map.
- D.G
Quote:Originally posted by DoooG
I see, but that seems to have nothing to do with the actual texture, its just a map.
- D.G
well a gray scale of the acutal textures that are being used is somewhat part of the texture? Just not color.
I'm no GL wiz but your texture map and your height map are going to be different.
assuming for the moment 0 black is deepest hole in the ground and 255 white is highest point, simply converting textures to greyscale will result in a freakish world of highs and lows.
You can find out how this looks in Realm Wars by importing greyscale height maps to
change the terrain. Amazing what 256 shades of grey can do.
I don't think you want to be reading the color range of the playfield constantly.
That seems like a slow way of doing things and in color you have 32767 colors to contend with.
You want to read a greyscale heightmap into an array in advance or when the terrain changes.
the X,Y of this array should translate to your play field...say 256 x 256 sectors for an equally pixel dimensioned image.
This way you can lay down a 512x512 texture on top of your mesh and give
it more detail without worrying about detail changing heights and such.
So the question is how do you read an image into an array and check against it.
Can't be too hard, its the fundamentals of old school BASIC graphics and collision detection:
poke 19242,240 // put character into memory
if Peek (19242)=240 then ... // get character at memor
wish I could help more than that.
Hope I illustrated the problem a little for the folks who can help.
assuming for the moment 0 black is deepest hole in the ground and 255 white is highest point, simply converting textures to greyscale will result in a freakish world of highs and lows.
You can find out how this looks in Realm Wars by importing greyscale height maps to
change the terrain. Amazing what 256 shades of grey can do.
I don't think you want to be reading the color range of the playfield constantly.
That seems like a slow way of doing things and in color you have 32767 colors to contend with.
You want to read a greyscale heightmap into an array in advance or when the terrain changes.
the X,Y of this array should translate to your play field...say 256 x 256 sectors for an equally pixel dimensioned image.
This way you can lay down a 512x512 texture on top of your mesh and give
it more detail without worrying about detail changing heights and such.
So the question is how do you read an image into an array and check against it.
Can't be too hard, its the fundamentals of old school BASIC graphics and collision detection:
poke 19242,240 // put character into memory
if Peek (19242)=240 then ... // get character at memor
wish I could help more than that.
Hope I illustrated the problem a little for the folks who can help.
I plan on using gray scale for a height map? I am confused on what your saying? Delta Force uses gray scale also if I remember right to determine height? Yes I would take the textured map a (X,Y) map and have a grayscale value read into an 2D array to compare values with. I hope what I planned on doing is what your saying griffin?
Yep thats it.
Earlier it sounded like...you were going to use the texture as the basis of height.
Which sounds like color and all. Confusing terms.
This has to be pretty common stuff.
I found this but its late here...no time for reading
http://www.flipcode.com/tutorials/tut_proctext.shtml
Here's a terrain tutorial for mac
http://www.robot-frog.com/3d/hills/heightmaps.html
i searched "heightmap tutorial" in google...
the truth is out there.
Earlier it sounded like...you were going to use the texture as the basis of height.
Which sounds like color and all. Confusing terms.
This has to be pretty common stuff.
I found this but its late here...no time for reading
http://www.flipcode.com/tutorials/tut_proctext.shtml
Here's a terrain tutorial for mac
http://www.robot-frog.com/3d/hills/heightmaps.html
i searched "heightmap tutorial" in google...
the truth is out there.
Quote:Originally posted by griffin239
Yep thats it.
Earlier it sounded like...you were going to use the texture as the basis of height.
Which sounds like color and all. Confusing terms.
This has to be pretty common stuff.
I found this but its late here...no time for reading
http://www.flipcode.com/tutorials/tut_proctext.shtml
Here's a terrain tutorial for mac
http://www.robot-frog.com/3d/hills/heightmaps.html
i searched "heightmap tutorial" in google...
the truth is out there.
Oh dear GOD your seach will be logged into the google super database and keep on record forever!! Yeah as soon as I found out google logs everything I switched to yahoo! My luck they keep track of me their also. Oh well back to google if thats the case. :?:
Who cares if they know what you're typing in?
Quote:Originally posted by Mars_999Um... doesn't Yahoo use google to do its' searches?
Yeah as soon as I found out google logs everything I switched to yahoo!

And I hate to tell you, but every single site you visit logs the visit, except for some particularly security related sites.
"He who breaks a thing to find out what it is, has left the path of wisdom."
- Gandalf the Gray-Hat
Bring Alistair Cooke's America to DVD!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Best way to readback float pixels? | kelvin | 8 | 4,116 |
Feb 27, 2008 10:23 PM Last Post: kelvin |
|
| Getting to an NSWindow's pixels | ThemsAllTook | 4 | 4,653 |
Jun 5, 2007 08:05 PM Last Post: sammyjojo |
|
| SDL Parachute Deployed when accessing surface->pixels | BobbyWatson | 8 | 5,063 |
Jan 23, 2005 06:30 PM Last Post: MattDiamond |
|

