Hi all!
@devs: Please, implement those! Must have for object picking by color without using canvas and formulas for color to number conversion.
Wrappers for glReadPixel, glColor3uiv / glColor4uiv
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Wrappers for glReadPixel, glColor3uiv / glColor4uiv
glReadPixel is slow, take a screenshot instead and read the pixel from that. Slow, you say? Exactly.
As to the glColors, I'm not sure what you're on about.
As to the glColors, I'm not sure what you're on about.
Re: Wrappers for glReadPixel, glColor3uiv / glColor4uiv
I'm talking about reading several pixels near mouse cursor.
And it will be made each frame.
So taking screenshot...
Now I'm using canvas for reading pixels, but it is not supported everywhere, as I heard.
And about glColor3uiv / glColor4uiv. I will prepare and show sample lua file here to explain what I mean. Little later.
And it will be made each frame.
So taking screenshot...
Now I'm using canvas for reading pixels, but it is not supported everywhere, as I heard.
And about glColor3uiv / glColor4uiv. I will prepare and show sample lua file here to explain what I mean. Little later.
Re: Wrappers for glReadPixel, glColor3uiv / glColor4uiv
Isn't glColor3/4uiv just setting the color from an array? That's exactly what lovr.graphics.setColor() does...arampl wrote:I'm talking about reading several pixels near mouse cursor.
And it will be made each frame.
So taking screenshot...
Now I'm using canvas for reading pixels, but it is not supported everywhere, as I heard.
And about glColor3uiv / glColor4uiv. I will prepare and show sample lua file here to explain what I mean. Little later.
Re: Wrappers for glReadPixel, glColor3uiv / glColor4uiv
No. With glColor3uiv / glColor4uiv you can set color as a single unsigned integer value 24/32 bit, not a separate 3 or 4 values RGB or RGBA: setColor(255, 0, 0) opposed to setColor(4356345) or something like this.S0lll0s wrote:Isn't glColor3/4uiv just setting the color from an array? That's exactly what lovr.graphics.setColor() does...arampl wrote:I'm talking about reading several pixels near mouse cursor.
And it will be made each frame.
So taking screenshot...
Now I'm using canvas for reading pixels, but it is not supported everywhere, as I heard.
And about glColor3uiv / glColor4uiv. I will prepare and show sample lua file here to explain what I mean. Little later.
I'll post sample code when translate comments to it, and it will tell you all the details.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Wrappers for glReadPixel, glColor3uiv / glColor4uiv
So
And this is so much more useful because...
Code: Select all
function setColor(r)
return love.graphics.setColor(math.floor(r/16777216), math.floor(r/65536)%256, math.floor(r/256)%256, r%256)
end
Re: Wrappers for glReadPixel, glColor3uiv / glColor4uiv
Look at this, guys.
EDIT: stripped out comments for now...
EDIT: stripped out comments for now...
- Attachments
-
- pick.love
- (3.66 KiB) Downloaded 267 times
Re: Wrappers for glReadPixel, glColor3uiv / glColor4uiv
As of now I'm doing all the stuff with canvas and formulas for converting setColor(r,g,b) to some single value (obect's id).
Imho It will be much cleaner if we can just use setColor(obect id)...
In OpenGL + C it can be done flawlessly...
Imho It will be much cleaner if we can just use setColor(obect id)...
In OpenGL + C it can be done flawlessly...
Re: Wrappers for glReadPixel, glColor3uiv / glColor4uiv
I'm doing exactly something like this and want to get rid of this calculations each frame.bartbes wrote:SoAnd this is so much more useful because...Code: Select all
function setColor(r) return love.graphics.setColor(math.floor(r/16777216), math.floor(r/65536)%256, math.floor(r/256)%256, r%256) end
Re: Wrappers for glReadPixel, glColor3uiv / glColor4uiv
glReadPixels & glColor(single value) will solve so many problems...
This functions is so "base" functions of OpenGL...
Of course I can live without them...
P.S.
This functions is so "base" functions of OpenGL...
Of course I can live without them...
P.S.
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot], Google [Bot] and 12 guests