How can I make this happen

Hi, I just registered today and new to OpenGL. I have to write a radar display repeater using BCB4 under Windows NT. The radar will have to display two things first the radar echo and second a symbol on top of the echo.

I’ve done the echo part which got updated every time theres an echo data comming from the serial port. The echo is drawn at z-coordinate 0.5 and the symbol is drawn at z-coordinate 0.3. I use glOrtho to make the symbol sits on top of the echo object.

My problem is how can I delete only the echo or only the symbol. Any help would be very much appreciated.

Cheers,
Azrin

…delete??
You mean “not render”!
Simply, have a boolean flag for each object (1 for echo, 1 for symbol), and draw the objects for which the flag is enabled.
So to “delete”: set appropriate flag to false, clear buffers and render the scene again.

Not just an OpenGL specific question, though.
(Or am I missing the point?)

Not sure how you update your screen, if at all… But if you have some kind of loop going on you can call glClear first and then draw either the echo or the symbol or both.

Originally posted by AndersO:
Not sure how you update your screen, if at all… But if you have some kind of loop going on you can call glClear first and then draw either the echo or the symbol or both.

Ok… maybe I have not put the question correctly . So let me rephrase my question.

My radar is divided into 360 sectors where each sector representing 1 degree of the total 360 degress of the radar sweep.

Each sectors is further divided into 256 segments.

I built a list of 256 quads to represent each segment of data. Starting from the center of the radar till the end of its radius. (Hope you can imagine how a radar display looks like )

When an echo data arrives, I will check its sector number. If the number is let say 25, I will glrotatef(25-90,0,0,-1.0) to draw at the correct azimuth clock-wise.

Then I’ll check each data and change the color of each list corresponding to the data, e.g if data==1, change color to green an so on and start to glCallList from 1 to 256.

Now If if glClear all previous sector plots will be cleared off. A radar display should maintain the plot of a sector until the next data for that sector arrives.

That is why I need to only clear the symbol only which is located in front of the echo.

I hope you can understand me this time. Please…someone help me

Well, it sounds like there’s two ways of doing it. The gentlemen above gave you the easiest way of doing it.

Keeping track of each symbol and echo in a state flag (array maybe?) is by far the easiest way to do this, and every time a piece of information changes, you update the entire screen. Clean, efficient, and real-time.

The second way, at least as I can see which seems to be the way you want to do it, you use a textured primitive (quad) carrying your symbol and another on to of it carrying your echo. If you want the ‘object’ (loosely - the symbol, or the echo, or both) to disappear, you would just draw a black (or whatever background color) quad over the top of the ‘object’ at that location. This would have very negative effects, however. First, you’d constantly be adding polys to your scene, so in the long run it would get really slow. Second, if you have some sort of grid pattern or background pattern, and your ‘object’ lies over the top of a segement or similar, then trying to draw a black poly over the top would begin to erase and corrupt your grid.

I’d opt for the first method, as described by the others that posted. There is no way to ‘delete’ an object in OpenGL from a scene once it has been rendered, unless you rerender the scene again without (thereby ‘deleting’) the object. ->Leads to state flags for your objects.

Long winded, but that should answer your question.

Siwko

Siwoko : You are mistaken. You can draw forever and never clear the buffer, and the only time it takes is to draw the NEW primitives…

Personally I would draw a big black poly over the whole scene with a low alpha, that would make the radar fade out over time.
Or you could just draw a non-alpha-blended black poly over each sector just before you drew it to erase it…

Originally posted by Kaeto:
[b]Siwoko : You are mistaken. You can draw forever and never clear the buffer, and the only time it takes is to draw the NEW primitives…

Personally I would draw a big black poly over the whole scene with a low alpha, that would make the radar fade out over time.
Or you could just draw a non-alpha-blended black poly over each sector just before you drew it to erase it…[/b]

That is what I’m current doing. draw a black poly if the data that represent that poly is a null. Your idea of using a low alpha poly to make the radar fade over time is a brilliant one. Will it have any difference in terms of performance?.

A glClear should always be faster than a glRect.
Alpha blending is always slower than no alpha blending, because of the necessary read-modify-write cycle needed on the video ram.

Nevertheless, on the newer boards (TNT2 and newer) the fillrate should be good enough in all cases.

To separate different drawing layers from each other can be done in some ways.

The most elegant is an overlay buffer. That means IF your grafics board supports OpenGL overlays, you can draw the radar in the main plane and the symbols in an overlay plane. No consumer graphics boards has an OpenGL overlay plane, expensive CAD boards have sometimes.

Another method would be to separate the drawings in different color buffers, like drawing the radar in the green channel and the symbols in the red or/and blue.
You can select the color channel with glColorMask().
I would use the blue for the radar and red-green = yellow for the symbols, that gives nice contrast and even peoble with red-green handicap can read it.

Another method would be to keep a backing storage of the radar screen to erase the symbols with small rectangles of the underlying plane. See glReadPixels, glDrawPixels, glCopyPixels (usage may have a huge performance hit).
Also have a look at the GL_KTX_buffer_region extension for nice performing backing storage.

I haven’t seen the necessity to use the z-buffer for your case.

Originally posted by Relic:
[b]The most elegant is an overlay buffer. That means IF your grafics board supports OpenGL overlays, you can draw the radar in the main plane and the symbols in an overlay plane. No consumer graphics boards has an OpenGL overlay plane, expensive CAD boards have sometimes.

Another method would be to separate the drawings in different color buffers, like drawing the radar in the green channel and the symbols in the red or/and blue.
You can select the color channel with glColorMask().
I would use the blue for the radar and red-green = yellow for the symbols, that gives nice contrast and even peoble with red-green handicap can read it.
[/b]

Using OpenGL overlay buffers sounds good. Do you know any off-the-shelf display adapter that supports that?.

In the mean time, I’ll try the glColorMask method. I’m not really sure how to use that but I’ll check in the help file.

Cheers,
Azrin

I think that using my method should run fine, assuming the scene isn’t too complicated (it’s a radar, how can it be :stuck_out_tongue: ) and the gfx card is anything modern… A TNT2 @ like 800X600 should pump out a good 40+ FPS at least (that’s a guess, based on the card’s fillrate), but possibly more (I’m just pulling those numbers out of you-know-where )

Originally posted by Kaeto:
I think that using my method should run fine, )

Yes, Currently I’m using a method similir to yours. But my display is quite complicated . There are alot of elements to show. The echo, the symbology, the infos of each tracked echo and a lot other stuffs. That is why I’, looking a better way to draw those elements and to only remove elements that are needed to be moved.

Then you’re probably best of clearing the screen every frame and keeping track of what needs to be drawn…

Originally posted by Kaeto:
Then you’re probably best of clearing the screen every frame and keeping track of what needs to be drawn…

I’ve tried clearing the screen and redrawing them again but it costs me the performance. Anyway, so far the best solution is using glColorMask. Thank you to everyone who had help me to solve the problem .

See ya all in my next question

Cheers & Have a nice day
Azrin