Draw selection line on object

I have a lot of objects on my scene. How i can draw selection line around object and when i select another object remove it without rendering all scene. Can i only redraw selection lines with the help logic operations may be? Any tips?


I don’t know how the gurus at this board would do it(I am definately not a guru) but I can tell you how I did it.

I have an editor where the user can select various portions of a Model. I chose to highlight it by changing the entire objects color, but if you wish to outline it, that will also work similarily.

Basically, for quick and dirty ‘line drawing’, set your polygon mode to line like this-


Then you will probably want to enable Polygon Offset so that the lines you draw don’t fight with the Polygons already drawn.


where factor is used to specify the variable depth offset for each polygon based on its angle to the viwer, and units is the amount of depth to offset. Try 1,1 for starters.

Then draw your selected object again.

You will need to redraw the model if the user changes selection unless your model remains stationary. Then you may be able to read the pixels from the frame buffer and store them, redrawing that information and then rendering as above. The problem is that unless you also store your Depth buffer, you will have odd results.

That’s my 2 cents. :stuck_out_tongue:

Honestly, I think I’d probably just redraw the scene with the selection lines around the new object. Unless you have a LOT of objects, or a very slow card you aren’t even going to notice a hit in performance by doing that. Trying to do a glReadPixels and glWritePixels will probably give you a performance hit as they can be pretty slow.

you wanna do “rubberbanding”
see the faq section 14 http://www.frii.com/~martz/oglfaq/

Thanx guys for your help, but i have non static model and a lot of objects (its about 12.000.000 triangles and about 12.000.000 lines). Its working so slow and i can’t allow myself to redraw scene around the selection object and especially all scene

Also selection object always change his position on account of rotation moving and zooming. thats way i can’t use glReadPixels and glWritePixels

I can’t use simple redraw lines with different color, becouse i use a smooth shadow model that’s use color interpolation and i can’t know color of line in some points of its drawed.

I think use the color logic. But i need select line with custom colors not only inverse of existent in scene. Can i did it somehow? Thanx any help

you might wnat to consider using glScissor, so you have to render only the part of your scene, in which you want to remove the selection lines.