Okay so first, a little background about my project...
I have an MSVC solution containing two separate projects:
- Tile Editor ("OnionEditor")
- Tile Engine ("OnionEngine")
... And in OnionEngine, I have the following objects:
- TileSheet (Responsible for loading an image and defining the SDL_Rects of a each individual tile)
- 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:
- Full-scale, hardware-accelerated textures of each individual layer (to somehow be scaled down and copied into a separate renderer)
- Scaled-down, hardware-accelerated copies of each individual layer (to render into each individual layer thumbnail view)
- 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.