Page 1 of 1

Transparent Sprite Persistance Problem!!

Posted: Wed Jun 14, 2006 9:31 pm
by kinjal
I am writing a program to plot a graph of some values in an array. For this I have created two sprites, one contains a grid while the other is used for plotting the data points. I have used two sprites to increase the speed of plotting as I dont have to draw grid everytime the plot loop is executed.

Now the problem is that in the transparent sprite, the old poltted data persists even after the new data is plotted creating a mess on the screen. How do I clear old plotted data?

Here is my code

Code: Select all

Procedure DisplayData()
  Define x.w
  Define old_y1.w, new_y1.w
  Define old_y2.w, new_y2.w
  Define new_sprite.l  

  StartDrawing(SpriteOutput(1)) ;Starts Drawing on the sprite
  Box(0,0,512,320,$000000) 
  
  old_y1 = 128
  old_y2 = 128

  DrawingMode(#PB_2DDrawing_Transparent) ; sets Text background transparent
  For x=0 To 511 
   
    new_y1 = Read_buff(x)
    new_y2 = Read_buff(x+512)
    
    LineXY(x-1, old_y1, x, new_y1,#Red)
    LineXY(x-1, old_y2, x, new_y2,#Green)
    
    old_y1 = new_y1
    old_y2 = new_y2
  Next 
  
  StopDrawing() ;Stops drawing on the sprite
  FlipBuffers() 
  DisplayTransparentSprite(1,0,0) ; display the sprite
 EndProcedure
The grid sprite is displayed once when the program starts.

Any solution?

Posted: Thu Jun 15, 2006 1:07 am
by netmaestro

Code: Select all

  StopDrawing() ;Stops drawing on the sprite 
  ClearScreen(#Black)
  DisplayTransparentSprite(1,0,0) ; display the sprite 
  FlipBuffers() 
EndProcedure

Posted: Thu Jun 15, 2006 6:36 pm
by kinjal
NO that does not work!

If I use ClearScreen(#Black) the background sprite which displays grid becomes invisible! I dont want to redraw the grid every time I plot the points.

Posted: Fri Jun 16, 2006 5:48 pm
by kinjal
No one? :(

Posted: Fri Jun 16, 2006 6:30 pm
by Kale
kinjal wrote:NO that does not work!

If I use ClearScreen(#Black) the background sprite which displays grid becomes invisible! I dont want to redraw the grid every time I plot the points.
I think your gonna have to redraw the grid each time. :wink:

Posted: Fri Jun 16, 2006 7:01 pm
by kinjal
But I guess it takes a considerable amount of time! Isn't there any other way?

Posted: Fri Jun 16, 2006 7:44 pm
by Kale
kinjal wrote:But I guess it takes a considerable amount of time! Isn't there any other way?
Try it, if it's just one sprite then it will be very very quick.

Posted: Sat Jun 17, 2006 6:53 am
by kinjal
Can you tell me one thing...which of these two methods will be faster?

1. I draw grid and points on same sprite. Grid drawing consitst of two loops which goes from 0 to 512 in steps of 32 and draws lines which needs to be executed whenever points are plotted.

2. The other method is using 2 sprites. I draw grid on one sprite during startup then every time I plot the points I display both the sprites using DisplaySprite(....) and DisplayTransparentSprite(...) methods.

Posted: Sat Jun 17, 2006 6:57 am
by netmaestro
#2 makes more sense.