a little optimization

This commit is contained in:
gazer 2016-01-29 11:03:39 +03:00
parent de42d281b6
commit c2edca6d7b
2 changed files with 9 additions and 12 deletions

View File

@ -46,10 +46,8 @@ class GLDrawBuf : DrawBuf, GLConfigCallback {
@property Scene scene() { return _scene; }
this(int dx, int dy, bool framebuffer = false) {
_dx = dx;
_dy = dy;
resize(dx, dy);
_framebuffer = framebuffer;
resetClipping();
}
/// returns current width
@ -65,7 +63,6 @@ class GLDrawBuf : DrawBuf, GLConfigCallback {
/// reserved for hardware-accelerated drawing - begins drawing batch
override void beforeDrawing() {
resetClipping();
_alpha = 0;
if (_scene !is null) {
_scene.reset();

View File

@ -422,12 +422,13 @@ class SDLWindow : Window {
float b = ((_backgroundColor >> 0) & 255) / 255.0f;
glClearColor(r, g, b, a);
glClear(GL_COLOR_BUFFER_BIT);
GLDrawBuf buf = new GLDrawBuf(_dx, _dy, false);
buf.beforeDrawing();
onDraw(buf);
buf.afterDrawing();
if (!_drawbuf)
_drawbuf = new GLDrawBuf(_dx, _dy);
_drawbuf.resize(_dx, _dy);
_drawbuf.beforeDrawing();
onDraw(_drawbuf);
_drawbuf.afterDrawing();
SDL_GL_SwapWindow(_win);
destroy(buf);
}
} else {
// Select the color for drawing.
@ -441,10 +442,9 @@ class SDLWindow : Window {
if (!_drawbuf)
_drawbuf = new ColorDrawBuf(_dx, _dy);
_drawbuf.resize(_dx, _dy);
_drawbuf.resetClipping();
_drawbuf.fill(_backgroundColor);
onDraw(_drawbuf);
draw(_drawbuf);
draw(cast(ColorDrawBuf)_drawbuf);
// Up until now everything was drawn behind the scenes.
// This will show the new, red contents of the window.
@ -452,7 +452,7 @@ class SDLWindow : Window {
}
}
ColorDrawBuf _drawbuf;
DrawBuf _drawbuf;
//bool _exposeSent;
void processExpose() {