Advertisement

Object picking Kills framerate?

Started by July 12, 2003 11:29 PM
31 comments, last by skow 21 years, 7 months ago
So does this manual aproatch run more efficantly?

If so, if you ahve time could you explain that mehod a little more?

Where do i get objects, and is draw() the function that draws all the stuff?

Sorry im easily confused

[edited by - skow on July 14, 2003 11:06:43 AM]
sure is that efficient, its just drawing your scene again, the very same way as you did before..

yes, draw is where all gets drawn.. just like in your draw-routine everything gets drawn. with one difference: this time, for every object you want to be individually clickable, you give another color. for simplicity, you choose the index of the object, if you have them in some array/container stored. that way you can find it directly by reading the clicked color, and using that as an index.


you draw the very same frame you did yet before you clicked, just without textures and anything, but just with colors wich represent object-id''s.

and just don''t swap buffers in the end, as you don''t want to see that image.

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

Advertisement
Ohh it can tell via the colors, gotcha.

Instead of that loop could you jsut do your draw function that takes a bool parameter: selectb

Then in the draw function..

if ( selectb == false)
draw normaly

if ( selectb == true)
disable textures, lighting etc.
Make a counter for each object drawn, increase after each object.
For each object drawn do a glColor3ubv(&counter).
At the end do the pixel check to find the color clicked on.

Would that work? Just making sure I fully understand the concept correctly.

Thanks for the help Dave.
yes..

just for your info.. instead of WHAT loop?

you still do the loop, increasing your counter for every object! :D thats what my loop did. drawing each object with an unique id/color..

:D

but yes, you got it..

should work..


just be sure to be in 32bit colormode, and disable everything!

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

yes..

just for your info.. instead of WHAT loop?

you still do the loop, increasing your counter for every object! :D thats what my loop did. drawing each object with an unique id/color..

:D

but yes, you got it..

should work..


just be sure to be in 32bit colormode, and disable everything!

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

Interesting solution.

But this still requires your scene to be rendered twice, though its without texturing,lighting, etc...

What method do games like RTS use?

Is there a faster way?
Advertisement
it does only require one additional frame per CLICK! that means when ever you click, you have say 99 instead of 100 fps!

really.. that does hurt performance THAT MUCH!! :D

most use ray-sphere tests, i suppose.. at least for clicking on the units.. you don''t need and possibly bether don''t have perpixel clicking there.. as users don''t really want to need to click exactly to select a unit..

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

I havnt gotten time to use it yet, but im sure it has to be a hell of a lot better than the damn glselect.
quote:
Original post by skow
I havnt gotten time to use it yet, but im sure it has to be a hell of a lot better than the damn glselect.



Actually I think that it isn''t... From MSDN:
Rendering Modes:

GL_RENDER
Render mode. Primitives are rasterized, producing pixel fragments, which are written into the frame buffer. This is the normal mode and also the default mode.

GL_SELECT
Selection mode. No pixel fragments are produced, and no change to the frame buffer contents is made. Instead, a record of the names of primitives that would have been drawn if the render mode was GL_RENDER is returned in a select buffer, which must be created (see glSelectBuffer) before selection mode is entered

ie. "drawing" to "selection buffer" it should be signifently faster.


I have an older video card, but I don''t see a noticable drop in FPS (~2 FPS lost) when I using selection -- and that''s with openGL rendering each frame for display and selection.

This topic is closed to new replies.

Advertisement