Jump to content
  • Advertisement
Sign in to follow this  

Photoshop-style "Layer View" panel using SDL and C++/MFC?

This topic is 1484 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



Okay so first, a little background about my project...

I have an MSVC solution containing two separate projects:

  1. Tile Editor ("OnionEditor")
  2. Tile Engine ("OnionEngine")

... And in OnionEngine, I have the following objects:

  1. TileSheet (Responsible for loading an image and defining the SDL_Rects of a each individual tile)
  2. TileLayer (Responsible for keeping track of tile data: image index, XY coords, row count, column count, etc)

In OnionEditor, I have a "main" editor view which subclasses CView, and another class which subclasses CDockablePane and is responsible for displaying thumbnail views of each individual tile layer. In OnionEngine, each TileSheet object is (simply put) an SDL_Texture, created using the SDL_Renderer from the main editor view, and containing an array of SDL_Rects which are designed to cover the area of each individual tile within the loaded texture, allowing a simple SDL_RenderCopy to the main view (by using a tile index to specify the source rect to render). By pre-assigning an array of tile indices to a TileLayer object, and using a simple for loop to iterate over each one, this becomes very efficient for rendering individual tile layers using  a single hardware-accelerated texture for each TileSheet...




And now comes the tricky part... In my main editor view, I've setup a render loop which uses it's own SDL_Window and SDL_Renderer.

In the CLayerView object, I create new classes (each of which subclass CWnd) containing their own SDL_Window and SDL_Renderer, and are responsible for displaying scaled-down versions for each individual tile layer. The issue here, other than a possible performance hit, is that SDL requires a texture to be associated with only one renderer upon creation, and seemingly cannot be displayed using another renderer. I have tried using render targets, which work reasonably, but still provide me with no way to get that rendered output into another view; Creating a texture with SDL_TEXTUREACCESS_TARGET doesn't allow texture locking, and creating a texture with SDL_TEXTUREACCESS_STREAMING doesn't allow the use of SDL_SetRenderTarget...


Even trickier, I need some way to render each individual layer separate from eachother into their own offscreen surfaces, as well as composite each of those into the main editor view, without causing the view to flicker from multiple calls to SDL_RenderClear and SDL_RenderCopy... Which would basically mean that I need to use render targets anyway, right?




So I suppose the real question here is 50% design, and 50% technical...

What can I do to achieve the following:

  1. Full-scale, hardware-accelerated textures of each individual layer (to somehow be scaled down and copied into a separate renderer)
  2. Scaled-down, hardware-accelerated copies of each individual layer (to render into each individual layer thumbnail view)
  3. Composited texture of each full-scale layer (to render into the main editor view)

... Or am I just dreaming that this is even remotely possible? I'll be willing to take whatever I can get here.

Hell, I've even tried just using simple CDC and CBitmap objects at strategic moments, but failed to separate the layers without flickering the editor view. Please help! Thanks...

Edited by Rectangle

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!