How do i do that if i want to blit: lets say a window which is a picture.
The window will be over the mouse because its further down the code,
but if i set the mouse blit after that it blits forever, you know when it blits over and over again, and when i move the mouse there is blits all over the place.
Please help me out here. Peace
			
			
									
									
						The mouse allways ontop?
Moderators: Shine, Insert_witty_name
- 
				haxx_blaster
 - Posts: 13
 - Joined: Fri Jan 20, 2006 4:21 pm
 
You will generally have to redraw everything each cycle, even stuff that hasn't changed. If you bear that in mind, you should solve your problem.
Lee
eg:
			
			
									
									
						Lee
eg:
Code: Select all
while true do
   
   clearScreen()
   drawBackground()
   drawWindows()
   drawMouse()
   flip()
end- 
				haxx_blaster
 - Posts: 13
 - Joined: Fri Jan 20, 2006 4:21 pm
 
Another way would be to cache the drawing of things that don't change.
So, say you have a background, and a bunch of windows to draw. You only really want to redraw windows that have changed, so you could draw each window to an image, and keep a reference to each image prior to blitting the images to the screen.
Something like this (pseudo code):
Hopefully that will give you an idea.
Have a look at the bits of render code where you're doing the most complex calculations and see if the final image is cacheable.
For example, in the project I'm working on, I have an instructions screen which displays as long as the L button is held down. There's a fair bit of code which generates the instructions screen, but I only need execute it once, because I blit the instructions to an image, and then all I have to do each cycle is blit the final instructions image to the screen.
Lee
			
			
									
									
						So, say you have a background, and a bunch of windows to draw. You only really want to redraw windows that have changed, so you could draw each window to an image, and keep a reference to each image prior to blitting the images to the screen.
Something like this (pseudo code):
Code: Select all
function redraw()
   backBuffer:clear()
   for eachWindow
      if eachWindow has changed
         eachWindow.windowImage = generateWindowImage()
      end 
      backBuffer:blit(eachWindow.windowImage)
   end
   
   drawMouse(backBuffer)
  
   --Finally blit the backbuffer to the screen
   screen:blit(backBuffer)
Have a look at the bits of render code where you're doing the most complex calculations and see if the final image is cacheable.
For example, in the project I'm working on, I have an instructions screen which displays as long as the L button is held down. There's a fair bit of code which generates the instructions screen, but I only need execute it once, because I blit the instructions to an image, and then all I have to do each cycle is blit the final instructions image to the screen.
Lee
- 
				haxx_blaster
 - Posts: 13
 - Joined: Fri Jan 20, 2006 4:21 pm