The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_PollEvent() with an offscreen render target
Andreas Falkenhahn
Guest

Hi,

is SDL_PollEvent() only supposed to be used with the window being the current
render target?

I've noticed that in case an offscreen texture is the current render target
SDL_PollEvent() can do quite some strange things to the renderer. For example,
if the user resizes the window while an offscreen texture is the current
render target, the window's viewport dimensions will *not* be adapted automatically.
Instead, SDL probably adapts some parameters concerning the offscreen rendering
to the texture but IMHO it doesn't really make sense to take updated window
dimensions and apply them to the offscreen texture... they should be applied to
the window instead.

This behaviour can cause quite some confusion because in that case you'd have
to call SDL_RenderSetViewport() manually although this is normally done automatically
by the event handler on window resize.

I am attaching a small demo program which shows the issue. You can see that
the viewport coordinates aren't adapted correctly in case SDL_PollEvent() is
called while an offscreen texture is selected as the render target (SDL_RenderCopy
in line 101 is supposed to scale the offscreen texture to the window dimensions
but it doesn't do it because the viewport coordinates haven't been updated.)

If SDL_PollEvent() can't deal with render targets other than the window I
think this should be mentioned both in the docs of SDL_PollEvent() and SDL_SetRenderTarget().

--
Best regards,
Andreas Falkenhahn mailto:
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_PollEvent() with an offscreen render target
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
Can you try with the latest SDL snapshot? I fixed something that could cause this a few weeks ago:http://www.libsdl.org/tmp/SDL-2.0.zip

Thanks!



On Fri, Aug 15, 2014 at 6:39 AM, Andreas Falkenhahn wrote:
Quote:
Hi,

is SDL_PollEvent() only supposed to be used with the window being the current
render target?

I've noticed that in case an offscreen texture is the current render target
SDL_PollEvent() can do quite some strange things to the renderer. For example,
if the user resizes the window while an offscreen texture is the current
render target, the window's viewport dimensions will *not* be adapted automatically.
Instead, SDL probably adapts some parameters concerning the offscreen rendering
to the texture but IMHO it doesn't really make sense to take updated window
dimensions and apply them to the offscreen texture... they should be applied to
the window instead.

This behaviour can cause quite some confusion because in that case you'd have
to call SDL_RenderSetViewport() manually although this is normally done automatically
by the event handler on window resize.

I am attaching a small demo program which shows the issue. You can see that
the viewport coordinates aren't adapted correctly in case SDL_PollEvent() is
called while an offscreen texture is selected as the render target (SDL_RenderCopy
in line 101 is supposed to scale the offscreen texture to the window dimensions
but it doesn't do it because the viewport coordinates haven't been updated.)

If SDL_PollEvent() can't deal with render targets other than the window I
think this should be mentioned both in the docs of SDL_PollEvent() and SDL_SetRenderTarget().

--
Best regards,
 Andreas Falkenhahn                          mailto:
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL_PollEvent() with an offscreen render target
Andreas Falkenhahn
Guest

On 16.08.2014 at 21:40 Sam Lantinga wrote:

Quote:
Can you try with the latest SDL snapshot? I fixed something that could cause this a few weeks ago:
http://www.libsdl.org/tmp/SDL-2.0.zip

I can try but CMakeLists.txt needs to be fixed first. This is what I get:

CMake Error at CMakeLists.txt:1246 (add_library):
Cannot find source file:

d:/temp/SDL2-2.0.3-9063/src/joystick/windows/SDL_dxjoystick.c

Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx

--
Best regards,
Andreas Falkenhahn mailto:

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_PollEvent() with an offscreen render target
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
I think this fixes it, can you try it?https://hg.libsdl.org/SDL/rev/98d13a381299



This fix is in the latest snapshot now.



On Sat, Aug 16, 2014 at 2:42 PM, Andreas Falkenhahn wrote:
Quote:
On 16.08.2014 at 21:40 Sam Lantinga wrote:

Quote:
Can you try with the latest SDL snapshot? I fixed something that could cause this a few weeks ago:
http://www.libsdl.org/tmp/SDL-2.0.zip


I can try but CMakeLists.txt needs to be fixed first. This is what I get:

CMake Error at CMakeLists.txt:1246 (add_library):
  Cannot find source file:

    d:/temp/SDL2-2.0.3-9063/src/joystick/windows/SDL_dxjoystick.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx

--
Best regards,
 Andreas Falkenhahn                            mailto:

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL_PollEvent() with an offscreen render target
Andreas Falkenhahn
Guest

CMake works fine now but it stops compiling at SDL_directsound.c:

d:\temp\sdl2-2.0.3-9073\src\audio\directsound\SDL_directsound.h(36) : error C2016: C requires that a struct or union has at least one member
d:\temp\sdl2-2.0.3-9073\src\audio\directsound\SDL_directsound.h(36) : error C2061: syntax error : identifier 'LPDIRECTSOUND'
d:\temp\sdl2-2.0.3-9073\src\audio\directsound\SDL_directsound.h(37) : error C2061: syntax error : identifier 'mixbuf'
d:\temp\sdl2-2.0.3-9073\src\audio\directsound\SDL_directsound.h(37) : error C2059: syntax error : ';'
d:\temp\sdl2-2.0.3-9073\src\audio\directsound\SDL_directsound.h(42) : error C2059: syntax error : '}'
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(39) : error C2143: syntax error : missing ')' before '*'
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(39) : error C2081: 'LPDIRECTSOUND' : name in formal parameter list illegal
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(39) : error C2143: syntax error : missing '{' before '*'
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(39) : error C2059: syntax error : ','
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(39) : error C2059: syntax error : ')'
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(42) : error C2061: syntax error : identifier 'pDirectSoundCreate8'
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(42) : error C2059: syntax error : ';'
....followed by many more errors....

On 17.08.2014 at 00:20 Sam Lantinga wrote:

Quote:
I think this fixes it, can you try it?
https://hg.libsdl.org/SDL/rev/98d13a381299



Quote:
This fix is in the latest snapshot now.


Quote:
On Sat, Aug 16, 2014 at 2:42 PM, Andreas Falkenhahn wrote:

On 16.08.2014 at 21:40 Sam Lantinga wrote:

Quote:
Can you try with the latest SDL snapshot? I fixed something that could cause this a few weeks ago:
http://www.libsdl.org/tmp/SDL-2.0.zip

I can try but CMakeLists.txt needs to be fixed first. This is what I get:

CMake Error at CMakeLists.txt:1246 (add_library):
Cannot find source file:

d:/temp/SDL2-2.0.3-9063/src/joystick/windows/SDL_dxjoystick.c

Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
.hxx .in .txx


Quote:
--
Best regards,
Andreas Falkenhahn mailto:

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




--
Best regards,
Andreas Falkenhahn mailto:

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_PollEvent() with an offscreen render target
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
I don't have that build environment, so you'll have to debug it yourself. If you're stuck, try just disabling audio for the test.


On Sat, Aug 16, 2014 at 3:31 PM, Andreas Falkenhahn wrote:
Quote:
CMake works fine now but it stops compiling at SDL_directsound.c:

d:\temp\sdl2-2.0.3-9073\src\audio\directsound\SDL_directsound.h(36) : error C2016: C requires that a struct or union has at least one member
d:\temp\sdl2-2.0.3-9073\src\audio\directsound\SDL_directsound.h(36) : error C2061: syntax error : identifier 'LPDIRECTSOUND'
d:\temp\sdl2-2.0.3-9073\src\audio\directsound\SDL_directsound.h(37) : error C2061: syntax error : identifier 'mixbuf'
d:\temp\sdl2-2.0.3-9073\src\audio\directsound\SDL_directsound.h(37) : error C2059: syntax error : ';'
d:\temp\sdl2-2.0.3-9073\src\audio\directsound\SDL_directsound.h(42) : error C2059: syntax error : '}'
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(39) : error C2143: syntax error : missing ')' before '*'
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(39) : error C2081: 'LPDIRECTSOUND' : name in formal parameter list illegal
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(39) : error C2143: syntax error : missing '{' before '*'
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(39) : error C2059: syntax error : ','
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(39) : error C2059: syntax error : ')'
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(42) : error C2061: syntax error : identifier 'pDirectSoundCreate8'
d:\temp\SDL2-2.0.3-9073\src\audio\directsound\SDL_directsound.c(42) : error C2059: syntax error : ';'
....followed by many more errors....

On 17.08.2014 at 00:20 Sam Lantinga wrote:

Quote:
I think this fixes it, can you try it?
https://hg.libsdl.org/SDL/rev/98d13a381299



Quote:
This fix is in the latest snapshot now.


Quote:
On Sat, Aug 16, 2014 at 2:42 PM, Andreas Falkenhahn wrote:

On 16.08.2014 at 21:40 Sam Lantinga wrote:

 >> Can you try with the latest SDL snapshot? I fixed something that could cause this a few weeks ago:
 >> http://www.libsdl.org/tmp/SDL-2.0.zip
Quote:

  I can try but CMakeLists.txt needs to be fixed first. This is what I get:

  CMake Error at CMakeLists.txt:1246 (add_library):
    Cannot find source file:

      d:/temp/SDL2-2.0.3-9063/src/joystick/windows/SDL_dxjoystick.c

    Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
    .hxx .in .txx


Quote:
  --
  Best regards,
   Andreas Falkenhahn                            mailto:

  _______________________________________________
  SDL mailing list
 
  http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org




--
Best regards,
 Andreas Falkenhahn                            mailto:

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL_PollEvent() with an offscreen render target
Andreas Falkenhahn
Guest

On 17.08.2014 at 03:52 Sam Lantinga wrote:

Quote:
I don't have that build environment, so you'll have to debug it
yourself.

Well, it's just Windows SDK, Direct X SDK, Visual C, CMake and a shell. Nothing special,
really. The latest release SDL 2.0.3 builds fine on my setup. It's just the snapshot
that doesn't build so this should be fixed in the CVS.

It seems that HAVE_DSOUND_H and HAVE_DINPUT_H aren't defined leading to dsound.h and
dinput.h not getting included. After defining these constants, it compiles fine.

Back on topic: The issue I reported isn't gone with 2.0.3-9073. It behaves in exactly
the same way. Please try the very small demo program I sent in my first mail on this
topic. It is very easily reproducable as it happens every time. SDL will never adapt
the viewport dimensions on window resize in case an offscreen texture is the current
render target.

--
Best regards,
Andreas Falkenhahn mailto:

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_PollEvent() with an offscreen render target
Robotic-Brain
Guest

Your sample code gives missing symbol errors for Get(R/G/B)Value.

After defining them to some macros (no idea how they are intended to
work), i could confirm it on Mac OS 10.6 with SDL 2.0.3 and the latest
HG snapshot (9086:22232029f074)

Am 17.08.2014 21:03, schrieb Andreas Falkenhahn:
Quote:
On 17.08.2014 at 03:52 Sam Lantinga wrote:

Quote:
I don't have that build environment, so you'll have to debug it
yourself.

Well, it's just Windows SDK, Direct X SDK, Visual C, CMake and a
shell. Nothing special,
really. The latest release SDL 2.0.3 builds fine on my setup. It's
just the snapshot
that doesn't build so this should be fixed in the CVS.

It seems that HAVE_DSOUND_H and HAVE_DINPUT_H aren't defined leading
to dsound.h and
dinput.h not getting included. After defining these constants, it
compiles fine.

Back on topic: The issue I reported isn't gone with 2.0.3-9073. It
behaves in exactly
the same way. Please try the very small demo program I sent in my
first mail on this
topic. It is very easily reproducable as it happens every time. SDL
will never adapt
the viewport dimensions on window resize in case an offscreen texture
is the current
render target.

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_PollEvent() with an offscreen render target
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
Is DXSDK_DIR set in the environment? It seems like this ought to work:
    set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
    check_include_file(d3d9.h HAVE_D3D_H)
    check_include_file(d3d11_1.h HAVE_D3D11_H)
    check_include_file(ddraw.h HAVE_DDRAW_H)
    check_include_file(dsound.h HAVE_DSOUND_H)
    check_include_file(dinput.h HAVE_DINPUT_H)



On Sun, Aug 17, 2014 at 12:03 PM, Andreas Falkenhahn wrote:
Quote:
On 17.08.2014 at 03:52 Sam Lantinga wrote:

Quote:
I don't have that build environment, so you'll have to debug it
yourself.


Well, it's just Windows SDK, Direct X SDK, Visual C, CMake and a shell. Nothing special,
really. The latest release SDL 2.0.3 builds fine on my setup. It's just the snapshot
that doesn't build so this should be fixed in the CVS.

It seems that HAVE_DSOUND_H and HAVE_DINPUT_H aren't defined leading to dsound.h and
dinput.h not getting included. After defining these constants, it compiles fine.

Back on topic: The issue I reported isn't gone with 2.0.3-9073. It behaves in exactly
the same way. Please try the very small demo program I sent in my first mail on this
topic. It is very easily reproducable as it happens every time. SDL will never adapt
the viewport dimensions on window resize in case an offscreen texture is the current
render target.

--
Best regards,
 Andreas Falkenhahn                            mailto:

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL_PollEvent() with an offscreen render target
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
This is fixed, thanks!https://hg.libsdl.org/SDL/rev/a8cbb653aea4




On Fri, Aug 15, 2014 at 6:39 AM, Andreas Falkenhahn wrote:
Quote:
Hi,

is SDL_PollEvent() only supposed to be used with the window being the current
render target?

I've noticed that in case an offscreen texture is the current render target
SDL_PollEvent() can do quite some strange things to the renderer. For example,
if the user resizes the window while an offscreen texture is the current
render target, the window's viewport dimensions will *not* be adapted automatically.
Instead, SDL probably adapts some parameters concerning the offscreen rendering
to the texture but IMHO it doesn't really make sense to take updated window
dimensions and apply them to the offscreen texture... they should be applied to
the window instead.

This behaviour can cause quite some confusion because in that case you'd have
to call SDL_RenderSetViewport() manually although this is normally done automatically
by the event handler on window resize.

I am attaching a small demo program which shows the issue. You can see that
the viewport coordinates aren't adapted correctly in case SDL_PollEvent() is
called while an offscreen texture is selected as the render target (SDL_RenderCopy
in line 101 is supposed to scale the offscreen texture to the window dimensions
but it doesn't do it because the viewport coordinates haven't been updated.)

If SDL_PollEvent() can't deal with render targets other than the window I
think this should be mentioned both in the docs of SDL_PollEvent() and SDL_SetRenderTarget().

--
Best regards,
 Andreas Falkenhahn                          mailto:
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL_PollEvent() with an offscreen render target
Andreas Falkenhahn
Guest

On 17.08.2014 at 22:52 Sam Lantinga wrote:

Quote:
Is DXSDK_DIR set in the environment? It seems like this ought to work:

Yes, it is there:

PS C:\Users\andreas> echo $env:DXSDK_DIR
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\

And as I said, there are no such building problems with the official 2.0.3
from libsdl.org. It only happens with the work snapshot.

--
Best regards,
Andreas Falkenhahn mailto:

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_PollEvent() with an offscreen render target
Andreas Falkenhahn
Guest

Thanks. Have you seen my other mail titled "Refresh trouble with SDL_WINDOWEVENT_EXPOSED"?
This could also be a bug. And there's also a very short test case attached Wink

On 17.08.2014 at 23:35 Sam Lantinga wrote:

Quote:
This is fixed, thanks!
https://hg.libsdl.org/SDL/rev/a8cbb653aea4



Quote:
On Fri, Aug 15, 2014 at 6:39 AM, Andreas Falkenhahn wrote:

Hi,

is SDL_PollEvent() only supposed to be used with the window being the current
render target?

I've noticed that in case an offscreen texture is the current render target
SDL_PollEvent() can do quite some strange things to the renderer. For example,
if the user resizes the window while an offscreen texture is the current
render target, the window's viewport dimensions will *not* be adapted automatically.
Instead, SDL probably adapts some parameters concerning the offscreen rendering
to the texture but IMHO it doesn't really make sense to take updated window
dimensions and apply them to the offscreen texture... they should be applied to
the window instead.

This behaviour can cause quite some confusion because in that case you'd have
to call SDL_RenderSetViewport() manually although this is normally done automatically
by the event handler on window resize.

I am attaching a small demo program which shows the issue. You can see that
the viewport coordinates aren't adapted correctly in case SDL_PollEvent() is
called while an offscreen texture is selected as the render target (SDL_RenderCopy
in line 101 is supposed to scale the offscreen texture to the window dimensions
but it doesn't do it because the viewport coordinates haven't been updated.)

If SDL_PollEvent() can't deal with render targets other than the window I
think this should be mentioned both in the docs of SDL_PollEvent() and SDL_SetRenderTarget().

--
Best regards,
Andreas Falkenhahn mailto:
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





--
Best regards,
Andreas Falkenhahn mailto:

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_PollEvent() with an offscreen render target
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
Can you report it as a bug in bugzilla so it doesn't get lost in e-mail?

Thanks!



On Mon, Aug 18, 2014 at 1:47 PM, Andreas Falkenhahn wrote:
Quote:
Thanks. Have you seen my other mail titled "Refresh trouble with SDL_WINDOWEVENT_EXPOSED"?
This could also be a bug. And there's also a very short test case attached Wink

On 17.08.2014 at 23:35 Sam Lantinga wrote:

Quote:
This is fixed, thanks!
https://hg.libsdl.org/SDL/rev/a8cbb653aea4



Quote:
On Fri, Aug 15, 2014 at 6:39 AM, Andreas Falkenhahn wrote:

Hi,

  is SDL_PollEvent() only supposed to be used with the window being the current
  render target?

  I've noticed that in case an offscreen texture is the current render target
  SDL_PollEvent() can do quite some strange things to the renderer. For example,
  if the user resizes the window while an offscreen texture is the current
  render target, the window's viewport dimensions will *not* be adapted automatically.
  Instead, SDL probably adapts some parameters concerning the offscreen rendering
  to the texture but IMHO it doesn't really make sense to take updated window
  dimensions and apply them to the offscreen texture... they should be applied to
  the window instead.

  This behaviour can cause quite some confusion because in that case you'd have
  to call SDL_RenderSetViewport() manually although this is normally done automatically
  by the event handler on window resize.

  I am attaching a small demo program which shows the issue. You can see that
  the viewport coordinates aren't adapted correctly in case SDL_PollEvent() is
  called while an offscreen texture is selected as the render target (SDL_RenderCopy
  in line 101 is supposed to scale the offscreen texture to the window dimensions
  but it doesn't do it because the viewport coordinates haven't been updated.)

  If SDL_PollEvent() can't deal with render targets other than the window I
  think this should be mentioned both in the docs of SDL_PollEvent() and SDL_SetRenderTarget().

  --
  Best regards,
   Andreas Falkenhahn                          mailto:
_______________________________________________
  SDL mailing list
 
  http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org





--
Best regards,
 Andreas Falkenhahn                            mailto:

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL_PollEvent() with an offscreen render target
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
I'm not sure why this wouldn't work. Can you debug it in your environment?


On Mon, Aug 18, 2014 at 1:46 PM, Andreas Falkenhahn wrote:
Quote:
On 17.08.2014 at 22:52 Sam Lantinga wrote:

Quote:
Is DXSDK_DIR set in the environment? It seems like this ought to work:


Yes, it is there:

PS C:\Users\andreas> echo $env:DXSDK_DIR
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\

And as I said, there are no such building problems with the official 2.0.3
from libsdl.org. It only happens with the work snapshot.

--
Best regards,
 Andreas Falkenhahn                            mailto:

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org