getting pixels from a texture

Member
Posts: 469
Joined: 2002.10
Post: #1
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. Huh

---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Sure, store the buffer you pass to glTexImage2D and look it up yourself Smile

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.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #3
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
Quote this message in a reply
Mars_999
Unregistered
 
Post: #4
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 this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #5
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 this message in a reply
Mars_999
Unregistered
 
Post: #6
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 this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #7
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 this message in a reply
Mars_999
Unregistered
 
Post: #8
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. Rasp
Quote this message in a reply
griffin239
Unregistered
 
Post: #9
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.
Quote this message in a reply
Mars_999
Unregistered
 
Post: #10
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?
Quote this message in a reply
griffin239
Unregistered
 
Post: #11
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.
Quote this message in a reply
Mars_999
Unregistered
 
Post: #12
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. :?:
Quote this message in a reply
Member
Posts: 164
Joined: 2002.04
Post: #13
Who cares if they know what you're typing in?
Quote this message in a reply
Member
Posts: 145
Joined: 2002.06
Post: #14
Quote:Originally posted by Mars_999
Yeah as soon as I found out google logs everything I switched to yahoo!
Um... doesn't Yahoo use google to do its' searches? Smile

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!
Quote this message in a reply
Mars_999
Unregistered
 
Post: #15
YOu both seem to miss the sarcasm in my post?:sorry:
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Best way to readback float pixels? kelvin 8 5,347 Feb 27, 2008 10:23 PM
Last Post: kelvin
  Getting to an NSWindow's pixels ThemsAllTook 4 5,418 Jun 5, 2007 08:05 PM
Last Post: sammyjojo
  SDL Parachute Deployed when accessing surface->pixels BobbyWatson 8 5,651 Jan 23, 2005 06:30 PM
Last Post: MattDiamond