SFML community forums

Help => Window => Topic started by: Henrik.Flink on January 21, 2008, 11:24:08 pm

Title: 2 render windows?
Post by: Henrik.Flink on January 21, 2008, 11:24:08 pm
I think i want to use 2 render windows to blit things at different places in the window, dont even know if it's possible or if there is any other solution? But the thing is that i want 1 window but i want like one render window that blits from lets say (0, 0) - (100, 100) and one that blits from (100,0) - (200,100).
So i can call render on a sprite with coordinates (10,10) on the second rederwindow so its "global" position will be (110,10).

I have faked this so it works well by offesetting the coordinates when i call render but i wonder if there is any better solution?
Title: 2 render windows?
Post by: Laurent on January 22, 2008, 02:33:25 am
There is currently no virtual rendering window in SFML, you have to fake it.

The easiest way is to use views, instead of offseting the sprites each time you draw them.

Then you would still need to do some clipping, to make sure nothing goes outside your virtual window, but that's for the next version (you can implement it using OpenGL scissor rect if you really need it) ;)
Title: 2 render windows?
Post by: Lord Delvin on January 22, 2008, 08:58:42 am
Using the stencilbuffer should be faster. Just draw a quad using the size of the window and set stencil functions to some sane values(if you dont want subwindows compare against 1 and set the function to add) remember to clean stencilbuffer.
Title: 2 render windows?
Post by: Laurent on January 22, 2008, 09:58:51 am
Stencil faster than scissor test ? Are you sure of that ?

Scissor is just an optimized stencil test, without reference value and comparison function. I can't see any reason it could be slower ;)
Title: 2 render windows?
Post by: Henrik.Flink on January 22, 2008, 11:58:06 am
I dont think i will have to cut anuthing cus it's fore i tilebased game so nothing will ever be outside the tile map if it's that you mean...
Title: 2 render windows?
Post by: Henrik.Flink on January 22, 2008, 11:33:38 pm
I was just testing with the views, and the views streches over the whole window which dont really help me att all. I dont think i really get how to do it with the views, i have one view covering the first half of the screen and the other view covering the other half, then i change view just before i do the render call and it seems that it streches over the whole screen which insn't the result i was after(orly?)  :?
Title: 2 render windows?
Post by: Laurent on January 23, 2008, 02:23:44 am
Hum... yes, sorry, it can't work directly with views. Forget what I said for the moment, the easiest solution is still to offset the sprites manually.
Title: 2 render windows?
Post by: l0calh05t on February 04, 2008, 07:34:22 pm
I'm not entirely sure if I understood the problem correctly, but if you want two virtual windows inside a single real window, why don't you simply use glViewport?
Title: 2 render windows?
Post by: Laurent on February 05, 2008, 02:15:40 am
SFML uses its own viewport, so you can't just use a custom one and be able to draw in it with SFML.
Title: 2 render windows?
Post by: l0calh05t on February 05, 2008, 11:15:18 am
Ah, I didn't know that (I mainly use the Window+System packages).