Combining SDL and AlphaBlend - referencing buffers
I've now got SDL working, however, I have a big unknown. For over 3 years, I've been using AlphaBlend for all of my drawing and I don't want to change that. I've got the front and back buffers set up and working perfectly fine. Now that I've got SDL going, of which I only need for fullscreen mode, how do I set up SDL to reference the buffers that AlphaBlend uses? This is my basic setup:
Code:
...
// at the top, with the globals
HDC HDCScreen; // pointer for front buffer, for displaying on screen
BITMAPINFOHEADER ScreenBufferInfo;
LPBITMAPINFOHEADER ScreenBufferInfoPointer;
LPVOID ScreenBufferPointer;
unsigned char ScreenBuffer[3145728]; // 1024x768 at 32-bit color
HDC HDCBack; // pointer for back buffer, for drawing into
HBITMAP HBMPBack;
BITMAPINFOHEADER BackBufferInfo;
LPBITMAPINFOHEADER BackBufferInfoPointer;
LPVOID BackBufferPointer;
unsigned char BackBuffer[3145728]; // 1024x768 at 32-bit color
...
// the SDL surfaces
SDL_Surface *SDLScreen; // the front buffer for SDL
SDL_Surface *SDLBack; // the back buffer for SDL
...
// in my initialization function where the buffers are initialized and set up:
HDCScreen = GetDC(WindowHandle); // set the screen buffer DC
ScreenBufferInfoPointer = &ScreenBufferInfo; // set the pointer
ScreenBufferPointer = &ScreenBuffer;
BackBufferInfoPointer = &BackBufferInfo; // set the pointer
BackBufferPointer = &BackBuffer;
HDCBack = CreateCompatibleDC(HDCScreen); // create a compatible DC, of which is to be used for drawing into the back buffer
HBMPBack = CreateCompatibleBitmap(HDCScreen, ScreenWidth, ScreenHeight); // create compatible bitmap, used for drawing into, but not on screen
HDCBitmap = CreateCompatibleDC(HDCScreen); // for AlphaBlend
SelectObject(HDCBack, HBMPBack); // select the created bitmap
...
// initialize SDL
if (SDL_Init(SDL_INIT_VIDEO) != 0) // SDL doesn't initialize
{
// Display error with sprintf and Windows' MessageBox function
}
else
{
// 1024x768 at 32-bit color is widely supported and not an issue
SDLScreen = SDL_SetVideoMode(1024, 768, 32, SDL_FULLSCREEN); // start in full screen
}
// in another function, after all of my AlphaBlend calls:
// how do I reference the pixel data in BackBuffer?
SDL_BlitSurface(SDLBack, NULL, SDLScreen, NULL);
// after the program terminates, don't forget to free resources
SDL_FreeSurface(SDLScreen);
SDL_FreeSurface(SDLBack);
SDL_Quit(); // quit SDL
// DeleteObject numerous times for the several images I have
The part in bold near the bottom is what I don't know - how do I reference the pixel data in BackBuffer?
Edit: The only thing I want to use SDL for is just fullscreen and vsync, nothing more.