Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


gl function for "returning" a polygon point surface colour?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 run_g   Members   -  Reputation: 212

Like
0Likes
Like

Posted 07 January 2013 - 10:38 AM

This might seem simple but i just cant find the answer:- in opengl es (fixed function) lets say u texture map a bitmap to a regular polygon- so the bitmap is now stretched and thus relative position of the color points on the rectangle is different from original bitmap- is there is a way ... I mean a gl. function that- if given the x,y coord on the rectangle surface relative to say the top left rectangle coord as a parameter- will return the colour of that point?
Thanks in advance
PLEASE i hope someone can help on this... I'm kind-of stuck. many thanks

Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 14027

Like
1Likes
Like

Posted 09 January 2013 - 11:09 PM

There is no function for that and hacking it would be more difficult than just manually grabbing the color.
Why don’t you just read the bitmap data at that point? A box filter is also trivial to implement if you need to account for blending of colors.

There is a way of hacking it out of OpenGL ES but it is too terribly slow, extremely hackish, and even more complex to actually implement, so I would not be doing you a service by explaining it.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 run_g   Members   -  Reputation: 212

Like
0Likes
Like

Posted 10 January 2013 - 12:24 AM

Thanks for ans Spiro. Reading the bitmap color even after texture mapping continues to reference to the unstretched bitmap. And so deosn't give correct values if u are trying to recover grid positions, remember only opengl knows the bitmap is stretched - the bitmap getPixel() still references original bm. Its ironic there is no simple solutions

#4 frob   Moderators   -  Reputation: 22285

Like
0Likes
Like

Posted 10 January 2013 - 01:25 PM

OpenGL is generally an output-only system.  

 

Reading back from it is almost always so slow that it isn't worth the effort.

 

 

If your app is already pushing performance limits then L Spiro's suggestion is going to be the best.  You're looking at 30-50 lines of code and it probably won't tank performance.

 

If you have cycles to spare I can think of several ways to do it, including the naive technique of just rendering to a texture and grabbing the pixel.


Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.


#5 L. Spiro   Crossbones+   -  Reputation: 14027

Like
0Likes
Like

Posted 10 January 2013 - 01:41 PM

continues to reference to the unstretched bitmap.
So does OpenGL ES.

The point is that OpenGL ES does a few matrix transforms and then possibly (optionally) some interpolations to get the final color.
All of these things are things you can do on your own in software, again by reading directly from the texture. You make it seem as if OpenGL ES references something other than the original texture.

As frob and I mentioned, it can be hacked together via only OpenGL ES commands, but not only is that such a ridiculous hack, it also makes no benefit to your understanding of what is happening inside the OpenGL ES pipeline.
I am not saying that understanding everything inside the OpenGL ES pipeline is super-important, but in this case it is not only better for your overall understanding, but also simpler, faster, and easier to implement.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#6 run_g   Members   -  Reputation: 212

Like
0Likes
Like

Posted 10 January 2013 - 02:55 PM

If you have cycles to spare I can think of several ways to do it, including the naive technique of just rendering to a texture and grabbing the pixel.
At this stage solution has priory over performance, so i am very much ready to try your solution. One can still learn alot even if its hack code. Many thanks

Wud appreciate if you could post the solution (or link if its too large), thanks

Edited by run_g, 10 January 2013 - 07:03 PM.


#7 L. Spiro   Crossbones+   -  Reputation: 14027

Like
0Likes
Like

Posted 13 January 2013 - 01:24 PM

Create a 1×1 render target, create an orthogonal projection matrix that will make the point whose color you want to grab land on that 1×1 dot, render, use glReadPixels() to get the color from the render target.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS