Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: fred on Wed 10/08/2005 11:03:40

Title: rawdrawing on scrollable background from a plugin
Post by: fred on Wed 10/08/2005 11:03:40
Hi, I'm trying to write a plugin in C++ for my game, using the ags-plugin-dll-template.

My reason for wanting to write a plugin is that my game has 1600x1200 pixel scrolling backgrounds (16bit color depth, 800x600 resolution) that need to be dynamically drawn, not every game-loop or so, but when the player enters a new room.

Right now I'm using an ags-function that loops through the 1600x1200 pixels and paints bitmaps of different colored stars at random positions on the black background image, using RawDrawImage() and RawDrawImageTransparent(). This function is called when the player enters a new room, and the stars stay in the background once they've been painted on, just like if a premade bitmap with fixed stars was loaded as background pic.

Now I want somethig a little more complicated then just drawing a bunch of semitransparent bitmaps on top of and beside each other, in other words, i need access to a two-dimensional array containing the pixel information (rgb-values) for the background, so that I can manipulate each pixel manually from the .dll I'm writing, adjusting overlapping stars and creating other weird graphics effects, before the final pic is drawn to the background. But once the background is drawn, it needs to stay fixed for scrolling when the player moves.

In the template dll, there's a call to AGSE_POSTSCREENDRAW, but whatever is drawn here is translated as the player moves around the room, and doesn't stay fixed in the background.

How would I be able to draw on the real room background picture? Do I need to call GetRawBitmapSurface(BITMAP *bmp) ?Ã, 
And what does the warning in the PlugIn API about this function only working with the virtual screen, mean? Isn't there a way to get and manipulate the real background picture?

- Fred
Title: Re: rawdrawing on scrollable background from a plugin
Post by: Pumaman on Wed 10/08/2005 18:48:17
You don't necessarily need to use GetRawBitmapSurface.

You do need to use GetBackgroundScene to get the room background so that you can draw on it. Then, you can either use the functions like BlitBitmap to draw onto it, or you can use GetRawBitmapSurface and do it manually.

QuoteAnd what does the warning in the PlugIn API about this function only working with the virtual screen, mean? Isn't there a way to get and manipulate the real background picture?

The warning is to tell you not to use it with the actual screen bitmap (returned by GetScreen). You can use it with the background returned by GetBackgroundScene, however.