1

I am building a simple game rendering method. I have a static images like map background that isn't really changing at all . I am just using like 30% of the whole screen for changing graphics. And I don't feel like it is necessary to render all that stuff over and over again if it isn't changing..

on internet I found something about passive rendering - You draw what you need and wait... until something updates .. after that you update it and again wait. Looks like a great method for this situation . But now ... I have a render method like that :

public class X extends Canvas{
//some method 
  this.createBufferStrategy(3);
//....
public void render(){
   BufferStrategy buffer = this.getBufferStrategy();
   Graphics g = buffer.getDrawGraphics();
   //Draws black background...
   g.setColor(Color.BLACK);
   g.fillRect(.... 
   for(... //cycles every object and calls their render methods... 
}

This is unable to maintain draw and wait method...becouse the background is redrawn every 1/30 of second so If you don't have anything to draw, you get black canvas with nothing on it.. so you have to always redraw everything each update...If I don't draw the background , buffer start to blink like hell... so I have to have something to cover that stuff up.

I searched on internet and found nothing much about other solutions for this rendering type.. Tuns of stuff for active rendering but nothing for that Draw and wait method..

I think it's impossible to do that with BufferStrategy. Is there something else to serve for this ? Also is there other source for Graphics g ? On internet was something about calling it directyl from Canvas but I didn't get it running for this. Or am I thinking about it from wrong angle?

Kara
  • 6,115
  • 16
  • 50
  • 57

1 Answers1

2

You're confusing passive rendering with partial updates. In "passive rendering" you can redraw everything, but you don't do it 30fps. you only do it when something moves. In "partial rendering", you only draw on the part of the canvas that changed.

The two can be put together, so that you only draw what changes, and only when it changes. That's the ideal case.

But passive rendering doesn't work if something is always moving, and partial updates don't work if the whole background is updating constantly.

AwokeKnowing
  • 7,728
  • 9
  • 36
  • 47