Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

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

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Rectangle   Members   


Posted 25 June 2014 - 07:24 AM



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, 25 June 2014 - 07:57 AM.

#2 Rectangle   Members   


Posted 27 June 2014 - 02:53 AM

Meh. Guess I'll just try my hand at SFML and see if it has better support for this sort of thing.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.