So far, here's how the painting works:
1) Check if the panel has an active SDL_Surface object
// can't draw if the screen doesn't exist yet2) Lock the SDL_Surface. This thing is thread-safe!
if (!m_Screen) {
return;
}
// lock the surface if necessary
if (SDL_MUSTLOCK(m_Screen)) {
if (SDL_LockSurface(m_Screen) > 0) {
return;
}
}
3) Create an in-memory bitmap (a wxImage) based on a SDL_Surface's memory. Once you got the image, you create a wxBitmap based on the wxImage. I really hope this isn't double-memory copying and that the wxImage uses the actual memory.
// create a bitmap from our pixel data4) Now that we created the bitmap, we can safely unlock the SDL_Surface.
wxBitmap bmp(wxImage(m_Screen->w, m_Screen->;h,
static_cast{unsigned char *}(m_Screen->pixels), true));
(NOTE: I use braces instead of less than and greater than because the code
is altered by blogger's html tidying routines)
// unlock the screen5) The painting is done with standard techniques:
if (SDL_MUSTLOCK(m_Screen)) {
SDL_UnlockSurface(m_Screen);
}
// paint the screen
wxBufferedPaintDC dc(this, bmp);
For our purposes, the SDL_Surface can be a software bitmap without 3D acceleration, residing in the computer's RAM. In other words, it's a plain and simple memory buffer.
And I had to load a full-fledged multimedia library for a simple in-memory bitmap!?!? C'mon!! But hey, it works :D
Here's the screenshot (note: the little color lines actually vary in real-time, it's cool).

Sweet, isn't it? Too bad I'll have to change the code back to keep working on this.
But from this we can incorporate the VideoOutputDevice class so we can actually display clips and images. This will be a major breakthrough in our editor.
No comments:
Post a Comment