Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Working SDL2 and Fog-Framework
- Method 1: No Renderer, just Screen Surface
- It's Software so probably Slower ?? ?
- */
- SDL_Window *win;
- SDL_Surface *_screen;
- win = SDL_CreateWindow("SDL2 & FOG", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_SHOWN);
- _screen = SDL_GetWindowSurface(win);
- ///.....
- ///Then in your Render()
- void SdlApplication::onRender()
- {
- // Lock surface pixels.
- SDL_LockSurface(_screen);
- // Create Fog::Painter instance mapped to the SDL surface data.
- Fog::Painter p;
- // Setup image buffer for painter.
- Fog::ImageBits buf;
- // This lets Fog work with the Screen Surface
- buf.setData(Fog::SizeI(_screen->w, _screen->h), Fog::IMAGE_FORMAT_XRGB32, _screen->pitch, (reinterpret_cast<uint8_t*>(_screen->pixels)));
- // Call our paint handler.
- if (p.begin(buf) == Fog::ERR_OK) onPaint(p);
- // Never forget to call p.end(). Painting can be asynchronous and
- // SDL_UnlockSurface() can invalidate the surface->pixels pointer.
- p.end();
- // Unlock surface pixels.
- SDL_UnlockSurface(_screen);
- // SDL Update that window!
- SDL_UpdateWindowSurface(win);
- }
- // This is where your Fog Code goes
- void SdlApplication::onPaint(Fog::Painter& p)
- {
- p.setSource(Argb32(0xFFFFFFFF));
- p.fillAll();
- }
Advertisement
Add Comment
Please, Sign In to add comment