Hello all,
I'm looking for advice/comments for a canvas class I created.
Back story: I was playing a game on my phone and during the game you could zoom in/out and could wrap the viewing portion. I thought about creating a class that could do the same.
Here is the result:
There is also a function to convert mouse display coordinates to corresponding position of canvas.
Example:
void dGameView::draw( ALLEGRO_DISPLAY *display ) { this->mCanvas->beginDrawing(); // TODO: do all drawing here this->mCanvas->flipToDisplay( display ); }
The advice I'm looking for is if there are any optimizations that I could do to speed things up.
Any particular reason you don't use the graphics card to do your transformations?
https://www.allegro.cc/manual/5/transformations.html
And this for the mouse: http://alleg.sourceforge.net/a5docs/refman/transformations.html#al_transform_coordinates
I was reading this article about resolution independence. It said that "using a stretched buffer" ... "is preferred if your game is using a lot of bitmaps."
Still trying to wrap my head about the whole resolution independence idea.
I wonder where that conclusion came from.
If you use transformations, everything you draw is sent to the graphics card, then the graphics card multiplies the view matrix by your transformation matrix to figure out where the fragments will be in screen space.
Using a stretched buffer I would fear would drive a game closer to being fill limited. Graphics cards have a limit to the number of pixels they can fill. So first you 'fill' your buffer, then you blit that, effectivly doing tripple buffering amd filling a lot more pixels.
Using a stretched buffer I would fear would drive a game closer to being fill limited. Graphics cards have a limit to the number of pixels they can fill. So first you 'fill' your buffer, then you blit that, effectivly doing tripple buffering amd filling a lot more pixels.
Allegro 5 uses geometry and tex coords to stretch bitmaps to the display or textures (most bitmaps) afaik. So I don't think it's much different than using transforms.