张巧平 | 21 May 15:01 2015
Picon

Re: about SDL_CreateWindowFrom

<!-- .hmmessage P { margin:0px; padding:0px } body.hmmessage { font-size: 12pt; font-family:微软雅黑 } -->
dears
I'm developing a video player On Windows,using sdl2+ffmpeg with the 2D API using the Direct3D.
If i use SDL_CreateWindow to create a playing window everything is ok.
but if i
use SDL_CreateWindowFrom to create a playing window,when resize window,the video static.
> Date: Wed, 20 May 2015 16:50:19 -0700
> From: ewmailing <at> gmail.com
> To: sdl <at> lists.libsdl.org
> Subject: Re: [SDL] about SDL_CreateWindowFrom
>
> On 5/20/15, 张巧平 <hackzqp <at> hotmail.com> wrote:
> > dear mrtatoad
> > windows 7 system.
> > I used SDL_SetWindowSize to set window size.but Bug still
>
>
> Are you doing actual video (e.g. movies), or do you mean your
> textures? If movies, how are you getting them?
>
> Are you using the SDL 2D API, or do you have your own OpenGL context
> (or maybe Direct3D context)?
>
> On Windows, particularly with the 2D API using the Direct3D backend,
> textures can get lost/destroyed on window resizes or fullscreen
> toggles. The workaround is to completely reload your textures on
> window resize events.
>
> -Eric
> --
> Beginning iPhone Games Development
> http://playcontrol.net/iphonegamebook/
> _______________________________________________
> SDL mailing list
> SDL <at> lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
张巧平 | 20 May 06:21 2015
Picon

about SDL_CreateWindowFrom

dears
I use SDL_CreateWindowFrom to create window.
It can play video Normally. but if resize the window,the video will static.
Why?how can i fix this bug?
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Travis McKinney | 18 May 08:19 2015
Picon

Re: Trouble with LockTexture & TextureStreaming

Rewritten to use SDL_UpdateTexture, same issues.
http://pastebin.com/zQaKPvzP

On 17 May 2015 at 22:36, Travis McKinney <movonarvic <at> gmail.com> wrote:
==29360== LEAK SUMMARY:
==29360==    definitely lost: 468 bytes in 9 blocks
==29360==    indirectly lost: 3,840,944 bytes in 7 blocks
==29360==      possibly lost: 837,397 bytes in 6,336 blocks
==29360==    still reachable: 1,534,901 bytes in 1,876 blocks

On 17 May 2015 at 21:43, Travis McKinney <movonarvic <at> gmail.com> wrote:
http://pastebin.com/K8vfbdQB

                        //SDL_LockSurface(surf);
                        SDL_LockTexture
                        (   
                            tex,
                            NULL,
                            &tex_pixels,
                            &tex_pitch
                        );

/*                        path.line_to(b.x, b.y);

                        ras.add_path(stroke);   
                        rscan.color(agg::rgba8(200, 150, 50, 255));
                        agg::render_scanlines(ras, scanline, rscan);
    */                   
//                        SDL_UnlockSurface(surf);
                        SDL_UnlockTexture(tex);
                        tex_pixels = NULL;
                        tex_pitch = -1;
                        SDL_RenderCopy
                        (
                            ren,
                            tex,
                            NULL,
                            NULL
                        );
                        SDL_RenderPresent(ren);
                        a=b;

On 17 May 2015 at 21:41, Travis McKinney <movonarvic <at> gmail.com> wrote:
That makes sense. I got rid of the SDL_Surface and replaced it with void *tex_pixels and int tex_pitch. Unfortunately I'm getting the same performance as before.
Downloading valgrind now. Interested to see what it comes up with, because I'm completely out of ideas.

On 17 May 2015 at 21:00, Jonathan Dearborn <grimfang4 <at> gmail.com> wrote:
I get the feeling that bad memory things are happening here.  That's the first thing you should be thinking when the program causes weird problems or fails to respond to signals.

You should not be mixing the memory locations of the surface and the texture, which is what I see.  SDL_LockSurface() says that you want to modify the surf->pixels by hand.  SDL_LockTexture() says that you want a new pointer to the texture pixels.  It looks like you overwrite the surface's pixel pointer with a pointer to the texture's temporary pixels (not to mention the surface's pitch).

Once you start unlocking those objects, you're in weird territory.  For example, the surface and texture pitches might not match, so when the surface is accessed (now with a different pitch than it was created with), you're liable to run right off the end of the allocated pixels.  Also, the surface's pixels have been leaked and are no longer accessible.  You'll be trying to access the texture's temporary pixel data, which might have been deallocated already.

If you're on Linux, try running it through valgrind and you'll probably get some verification of this.

I think what you should be doing is either using SDL_UpdateTexture() or copying the data (e.g. with memcpy) instead of replacing the pointers to the memory.

If you're getting along alright without SDL_GetWindowSurface(), then I suggest you don't bother using it.  Going from direct texture updates to shadow surfaces is a step backward.

Jonny D



On Sun, May 17, 2015 at 11:26 PM, Travis McKinney <movonarvic <at> gmail.com> wrote:
I broke it again. Added code into the event loop to check for mouse motion & button press then draw a line. Works great using SDL_RenderDrawLine but hangs up using SDL_Lock/Unlock texture approach.
The behavior is odd. It's slow but does draw a line, so it seems mousemotion events are being processed but it doesn't stop drawing a line or allow exiting the program -- not even with sigterm.

AGG functions are commented out to highlight that this is a problem with how I'm using SDL, more than AGG.


http://pastebin.com/M9QPTWXx


                case SDL_MOUSEBUTTONDOWN:
                    if (e.button.button == SDL_BUTTON_LEFT)
                    {
                        SDL_GetMouseState(&a.x, &a.y);
                        SDL_RenderDrawPoint(ren, a.x, a.y);
//                        path.move_to(a.x, a.y);
                    }
                    break;
                   
                case SDL_MOUSEMOTION:
                    if(e.motion.state & SDL_BUTTON_LMASK)
                    {
                        SDL_GetMouseState(&b.x, &b.y);
                        SDL_RenderDrawLine
                        (
                            ren,
                            a.x,
                            a.y,
                            b.x,
                            b.y
                        );
                       
                        SDL_LockSurface(surf);
                        SDL_LockTexture
                        (   
                            tex,
                            NULL,
                            &surf->pixels,
                            &surf->pitch
                        );

/*                        path.line_to(b.x, b.y);

                        ras.add_path(stroke);   
                        rscan.color(agg::rgba8(200, 150, 50, 255));
                        agg::render_scanlines(ras, scanline, rscan);
    */                   
                        SDL_UnlockSurface(surf);
                        SDL_UnlockTexture(tex);
                        SDL_RenderCopy
                        (
                            ren,
                            tex,
                            NULL,
                            NULL
                        );
                        SDL_RenderPresent(ren);
                        a=b;
                    }
                    break;


On 17 May 2015 at 14:14, Travis McKinney <movonarvic <at> gmail.com> wrote:
I think I was getting overly fixated on converting pixel formats real time.
A preprocessor macro is quite an elegant fix for this, as one binary won't run on every device anyway...

    #if SDL_BYTEORDER == SDL_BIG_ENDIAN
    #define AGG_RGBA32_BYTE_ORDER agg::pixfmt_rgba32
    rmask = 0xff000000;
    gmask = 0x00ff0000;
    bmask = 0x0000ff00;
    amask = 0x000000ff;
    #else
    #define AGG_RGBA32_BYTE_ORDER agg::pixfmt_abgr32
    rmask = 0x000000ff;
    gmask = 0x0000ff00;
    bmask = 0x00ff0000;
    amask = 0xff000000;
    #endif

On 17 May 2015 at 12:27, Naith <Danielane85 <at> hotmail.com> wrote:
I'm afraid I don't have much knowledge when it comes to pixel formats and various topics so the only thing I can help you with is this:

Whenever I'm gonna do any SDL_Surface -> SDL_Texture pixel manipulations, I always make sure that my SDL_Surface and SDL_texture has the same pixel format as my window and since I usually don't have a clue about what pixel format my window has I use some SDL functions that can tell me that information and my code then usually looks like this:




Code:


   const CVector2D TextureSize = CVector2D(256.0f, 256.0f);

   SDL_Surface* pSurface            = SDL_CreateRGBSurface(0, (int)TextureSize.x, (int)TextureSize.y, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
   SDL_Surface* pConvertedSurface   = SDL_ConvertSurfaceFormat(pSurface, SDL_GetWindowPixelFormat(MyWindow), 0);

   SDL_Texture* pTexture = SDL_CreateTexture(MyRenderer, SDL_GetWindowPixelFormat(MyWindow), SDL_TEXTUREACCESS_STREAMING, (int)TextureSize.x, (int)TextureSize.y);





Then, each frame, if the texture needs to be updated every frame, I manipulate the pixels in the surface, upload the pixels to the texture with the SDL_UpdateTexture function and then finally render the texture.

I don't know if this will help you at all but hopefully it will.

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




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



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





_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Travis McKinney | 17 May 09:29 2015
Picon

Trouble with LockTexture & TextureStreaming

I'm attempting to integrate AGG into a project. I tried to use SDL_LockTexture to pass my surface->pixels but it doesn't work, all I get is black.
Do I have the concept backwards? Why does SDL_LockTexture have argument void**pixels?

Here is my code snippet:
/*
        SDL_Texture* tex = SDL_CreateTexture
                        (ren,
                        SDL_PIXELFORMAT_RGBA8888,
                        SDL_TEXTUREACCESS_STREAMING,
                        frame_width,
                        frame_height);
                       
        SDL_LockTexture
        (
                tex,
                NULL,
                &surf->pixels,
                &surf->pitch
        );
        SDL_UnlockTexture(tex);
       
        SDL_RenderCopy
        (
                ren,
                tex,
                NULL,
                NULL
        );
        SDL_RenderPresent(ren);
*/
The whole program on pastebin (it is only 165 lines) - http://pastebin.com/XNsvHQnn
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Ethan Lee | 15 May 12:59 2015

[GameController] Input Inversion in Config

In the current SDL_GAMECONTROLLERCONFIG parser, there is no method to 
invert input values received from the joystick. For instance, while the 
360 controller's Y axes go from -32767 to 32767 downward, most Nintendo 
hardware does the opposite (and IIRC, sometimes only for one of two 
thumbsticks?!). Sometimes it can be possible to invert it at the driver 
level, like we did with the Wii U GameCube Adapter's uinput driver...

https://github.com/ToadKing/wii-u-gc-adapter/blob/master/wii-u-gc-adapter.c#L334

... but this may not be possible in all cases (and for developers who 
are expecting raw input unaltered it may even be considered annoying). 
In FNA I still have my old SDL_Joystick config format from when it was 
called MonoGame-SDL2, and it works well enough on its own...

https://github.com/flibitijibibo/FNA/blob/master/src/SDL2/Input/SDL2_GamePad.cs#L43
https://github.com/flibitijibibo/FNA/blob/master/src/SDL2/Input/SDL2_GamePad.cs#L470
https://github.com/flibitijibibo/FNA/blob/master/src/SDL2/Input/SDL2_GamePad.cs#L495

... but it awkwardly conflicts with GameControllers, and of course has 
the problem of picking up weird devices like wireless receivers... So 
I'd like to be able to do this at SDL_GameController's level instead.

My idea was to just allow negative integers for the numeric values, 
store whether the atoi() value < 0 (or is "-0"?), and then just use 
abs() to retain the iSDLButton value:

https://hg.libsdl.org/SDL/file/223fbcc6a327/src/joystick/SDL_gamecontroller.c#l380

Of course, I'd like to hear feedback on this. I imagine a lot of people 
have input inversion done on their game's side, but for certain projects 
that are stuck assuming 360 layouts (like FNA) it'd be really nice to have.

-Ethan
JeZ-l-Lee | 14 May 10:49 2015
Picon

[SDL2]-3D Ray Casting Demo-Need Some Help!

[SDL2]-3D Ray Casting Demo-Need Some Help!

Hi,

We found some source code for an SDL2 ray casting demo.
We have incorporated it into our cross-platform SDL2 game engine.

Our issue now is it won't build on Linux?
(builds fine on Windows)

You can download the entire project below:
http://16bitsoft.com/files/3dRayCasting/Demo/3dRayCasting-Demo.zip

Any help fixing errors on Linux would be appreciated!




JeZxLee
JessePalser <AT> GMail <DOT> com
16BitSoft Inc.
Video Game Design Studio
www.16BitSoft.com
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
bilsch01 | 14 May 06:55 2015
Picon
Picon

Does anyone static link SDL2 ?

I use Ubuntu OS. I am trying to static link my program (called graf.cpp) with the libraries required for SDL2. I have the sdl2-config file from a fresh SDL2 build.
When I run command line: sdl2-config --libs it tells me the libraries to link are: -L/usr/lib/x86_64-linux-gnu -lSDL2. -L/usr/lib/x86_64-linux-gnu references all of the libraries at that path, and -lSDL2 references SDL2 dynamic object specifically. Since i need to static link the libraries I run the following command line:
g++ graf.cpp -o graf --static -L/usr/lib/x86_64-linux-gnu -lSDL2. I am pretty sure this is the correct way to do it. When I do it, g++ generates hundreds of errors for undefined references and the build fails. I get a similar result when I link with only the flag -lSDL2. NOTE: I get similar result linking to all the *.a static library files for SDL2.

The problem is that the linked libraries contain references to things in other libraries not being linked. I need to link additional libraries. One indication of the missing libraries can be gotten running:
ldd /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0.2.0 which shows 41 other libraries the that the dynamic library is dependent on. I assume the static libraries similarly require additional libraries. But these are unknown.

MY QUESTION is: has anyone here done static linking of SDL2 libraries? If so, please tell me how to do it
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Michael Labbe | 14 May 00:05 2015

Android timer precision increase 1000x

SDL_GetPerformanceCounter() on Android is implemented in timer/unix/SDL_systimer.c, and uses the gettimeofday() implementation.

If HAVE_CLOCK_GETTIME is defined in the Android.mk's CCFLAGS, it successfully uses clock_gettime() instead.  This is a 1000x increase of precision (nanosecond resolution instead of microsecond).

Two time related concerns:

1. Is there a reason why HAVE_CLOCK_GETTIME is not enabled on Android?

2. SDL_GetPerformanceFrequency() returns a hardcoded value instead of calling clock_getres(). Is this a potential bug?  From the clock_getres() manpage: "The resolution of clocks depends on the implementation"

Code excerpt from Mercurial:

 #if HAVE_CLOCK_GETTIME
        return 1000000000;
#elif ... 

Asking around, experienced Android NDK game developers have told me that they have successfully shipped games using nanosecond precision on various Android hardware.  Should SDL2 enable this by default?

Michael Labbe
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Michael Labbé | 12 May 20:45 2015

Android and graphics profiling: proposed readme update

NVidia has released some pretty nice Tegra profiling tools for their Android devices. The NVidia Tegra Graphics Debugger works by providing an interposer library that intercepts ES2 and EGL calls.  You must link against these libraries.

Unfortunately, this quietly fails with SDL2 because libEGL and libGLES2 are dynamically loaded with dlopen().

NVidia offers a secondary approach to using the Tegra Graphics Debugger: root your device and install a global interposer library.  Almost no devs will try this first if they don’t have a rooted device, leading to heaps of wasted time failing to attach the profiler.

I propose an update to the Android readme that explains why the static linking approach recommended by NVidia doesn’t work.

I have filed a bug, with proposed wording for the readme in the description, here:

Michael Labbé

_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Noxalus | 11 May 12:07 2015
Picon

[SDL_mixer 2.0.0] No sound from iPad speakers

Hello everyone.

Last week I tried to use SDL_mixer on iPad to play a simple OGG file. The code compile, it works properly on Android and Windows, and I have no error when I launch the app on iPad, but no sound comes out of the speakers.

Later, I figured out that I could hear the sound by connecting an headphone, but I don't understand why the sound is not played on the speakers when we don't connect any headphone.

Do you have any idea why?

PS: I tried with another application like Chrome, and sound works and is played on speakers.
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
kj192 | 11 May 10:48 2015
Picon

2 window, same content

Hi Everyone,

I would like to know to is there any way to mirror the content from one window to another.
Like clone the SDL_RENDER before calling SDL_RenderPresent

or Do I have to make 2 different SDL_RENDER and when I open an image I have to do it twice like this:
IMG_LoadTexture(RENDER1,"filename")
IMG_LoadTexture(RENDER2,"filename")

Thanks. KJ
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Gmane