Justin Agrell | 17 Sep 03:29 2014
Picon

Triangle will not render

I'm getting started with SDL2 and modern OpenGL.
I am having trouble getting the triangle to render in my template:

source code here: http://u4e.us/c/main.c

This may be due to my laptop only supporting OpenGL 3.1.
> glxinfo |grep "Core Profile"
OpenGL core profile version string: 3.1 (Core Profile) Mesa 9.1.8

It also may be because I have been staring at it for too long and am
missing something simple.

Any help would be appreciated.
dfrizel | 15 Sep 19:22 2014
Picon
Picon

Pulseaudio, selecting Audio Device + multiple Audio

I just did some work with audio on SDL2. I had some troubles with selecting an audio device on pulseaudio. Somehow it always seemed to fall back to the default device.
A had a quick look over the code and fixed the problem (at least for me). Additionally it adds support for multi-device audio and device detection. If you are interested here is the patch for (SDL2-2.0.3) but I found no difference with the current repo.








Code:

diff -r 5bf21e9e191f src/audio/pulseaudio/SDL_pulseaudio.c
--- a/src/audio/pulseaudio/SDL_pulseaudio.c   Sun Sep 14 19:44:53 2014 +0200
+++ b/src/audio/pulseaudio/SDL_pulseaudio.c   Sun Sep 14 21:40:27 2014 +0200
<at> <at> -106,6 +106,7 <at> <at>
 
 static int load_pulseaudio_syms(void);
 
+pa_operation* (*PULSEAUDIO_pa_context_get_sink_info_list)(pa_context *c, pa_sink_info_cb_t cb, void *userdata);
 
 #ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
 
<at> <at> -202,11 +203,31 <at> <at>
     SDL_PULSEAUDIO_SYM(pa_stream_disconnect);
     SDL_PULSEAUDIO_SYM(pa_stream_unref);
     SDL_PULSEAUDIO_SYM(pa_channel_map_init_auto);
+    SDL_PULSEAUDIO_SYM(pa_context_get_sink_info_list);
     SDL_PULSEAUDIO_SYM(pa_strerror);
     return 0;
 }
 
 
+static void DeInit(struct SDL_PrivateAudioData *pulse_local_server)
+{
+   if (pulse_local_server != NULL)
+   {
+      if (pulse_local_server->context != NULL)
+      {
+         PULSEAUDIO_pa_context_disconnect(pulse_local_server->context);
+         PULSEAUDIO_pa_context_unref(pulse_local_server->context);
+         pulse_local_server->context = NULL;
+      }
+      if (pulse_local_server->mainloop != NULL) {
+         PULSEAUDIO_pa_mainloop_free(pulse_local_server->mainloop);
+         pulse_local_server->mainloop = NULL;
+      }
+      SDL_free(pulse_local_server);
+   }
+}
+
+
 /* Check to see if we can connect to PulseAudio */
 static SDL_bool
 CheckPulseAudioAvailable()
<at> <at> -307,16 +328,7 <at> <at>
             PULSEAUDIO_pa_stream_unref(this->hidden->stream);
             this->hidden->stream = NULL;
         }
-        if (this->hidden->context != NULL) {
-            PULSEAUDIO_pa_context_disconnect(this->hidden->context);
-            PULSEAUDIO_pa_context_unref(this->hidden->context);
-            this->hidden->context = NULL;
-        }
-        if (this->hidden->mainloop != NULL) {
-            PULSEAUDIO_pa_mainloop_free(this->hidden->mainloop);
-            this->hidden->mainloop = NULL;
-        }
-        SDL_free(this->hidden);
+      DeInit(this->hidden);
         this->hidden = NULL;
     }
 }
<at> <at> -344,6 +356,53 <at> <at>
     return "SDL Application";  /* oh well. */
 }
 
+
+static struct SDL_PrivateAudioData *ThreadInit()
+{
+    struct SDL_PrivateAudioData *h = NULL;
+    int state = 0;
+
+    struct SDL_PrivateAudioData *pulse_local_server = SDL_malloc((sizeof *pulse_local_server));
+
+    if (pulse_local_server == NULL) {
+        return 0;
+    }
+    SDL_memset(pulse_local_server, 0, (sizeof *pulse_local_server));
+    h = pulse_local_server;
+
+   /* Set up a new main loop */
+   if (!(h->mainloop = PULSEAUDIO_pa_mainloop_new())) {
+      DeInit(pulse_local_server);
+      return 0;
+   }
+
+   h->mainloop_api = PULSEAUDIO_pa_mainloop_get_api(h->mainloop);
+   h->context = PULSEAUDIO_pa_context_new(h->mainloop_api, getAppName());
+   if (!h->context) {
+      DeInit(pulse_local_server);
+      return 0;
+   }
+
+   /* Connect to the PulseAudio server */
+   if (PULSEAUDIO_pa_context_connect(h->context, NULL, 0, NULL) +      DeInit(pulse_local_server);
+      return 0;
+   }
+
+   do {
+      if (PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) +         DeInit(pulse_local_server);
+         return 0;
+      }
+      state = PULSEAUDIO_pa_context_get_state(h->context);
+      if (!PA_CONTEXT_IS_GOOD(state)) {
+         DeInit(pulse_local_server);
+         return 0;
+      }
+   } while (state != PA_CONTEXT_READY);
+   return pulse_local_server;
+}
+
 static int
 PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
 {
<at> <at> -356,12 +415,12 <at> <at>
     int state = 0;
 
     /* Initialize all variables that we clean on shutdown */
-    this->hidden = (struct SDL_PrivateAudioData *)
-        SDL_malloc((sizeof *this->hidden));
+    this->hidden = ThreadInit();
+
     if (this->hidden == NULL) {
         return SDL_OutOfMemory();
     }
-    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+
     h = this->hidden;
 
     paspec.format = PA_SAMPLE_INVALID;
<at> <at> -448,36 +507,6 <at> <at>
                                         PA_CHANNEL_MAP_WAVEEX);
 
     /* Set up a new main loop */
-    if (!(h->mainloop = PULSEAUDIO_pa_mainloop_new())) {
-        PULSEAUDIO_CloseDevice(this);
-        return SDL_SetError("pa_mainloop_new() failed");
-    }
-
-    h->mainloop_api = PULSEAUDIO_pa_mainloop_get_api(h->mainloop);
-    h->context = PULSEAUDIO_pa_context_new(h->mainloop_api, getAppName());
-    if (!h->context) {
-        PULSEAUDIO_CloseDevice(this);
-        return SDL_SetError("pa_context_new() failed");
-    }
-
-    /* Connect to the PulseAudio server */
-    if (PULSEAUDIO_pa_context_connect(h->context, NULL, 0, NULL) -        PULSEAUDIO_CloseDevice(this);
-        return SDL_SetError("Could not setup connection to PulseAudio");
-    }
-
-    do {
-        if (PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) -            PULSEAUDIO_CloseDevice(this);
-            return SDL_SetError("pa_mainloop_iterate() failed");
-        }
-        state = PULSEAUDIO_pa_context_get_state(h->context);
-        if (!PA_CONTEXT_IS_GOOD(state)) {
-            PULSEAUDIO_CloseDevice(this);
-            return SDL_SetError("Could not connect to PulseAudio");
-        }
-    } while (state != PA_CONTEXT_READY);
-
     h->stream = PULSEAUDIO_pa_stream_new(
         h->context,
         "Simple DirectMedia Layer", /* stream description */
<at> <at> -490,7 +519,7 <at> <at>
         return SDL_SetError("Could not set up PulseAudio stream");
     }
 
-    if (PULSEAUDIO_pa_stream_connect_playback(h->stream, NULL, &paattr, flags,
+    if (PULSEAUDIO_pa_stream_connect_playback(h->stream, devname, &paattr, flags,
             NULL, NULL)          PULSEAUDIO_CloseDevice(this);
         return SDL_SetError("Could not connect PulseAudio stream");
<at> <at> -519,6 +548,58 <at> <at>
     UnloadPulseAudioLibrary();
 }
 
+
+
+typedef struct
+{
+   uint8_t last;
+   SDL_AddAudioDevice addfn;
+} sink_struct;
+
+static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_last, void *userdata)
+{
+   sink_struct *a = (sink_struct *) userdata;
+
+   a->last = is_last;
+   if(i)
+   {
+      a->addfn(i->name);
+   }
+}
+
+void PULSEAUDIO_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
+{
+    struct SDL_PrivateAudioData *h = NULL;
+    struct SDL_PrivateAudioData *pulse_local_server = ThreadInit();
+
+    if(pulse_local_server == NULL)
+    {
+       //Out of Memory
+       return;
+    }
+
+    sink_struct a;
+    h = pulse_local_server;
+
+   if(iscapture != 1)
+   {
+      a.last = 0;
+      a.addfn = addfn;
+      pa_operation* o = PULSEAUDIO_pa_context_get_sink_info_list(h->context, get_sink_info_callback, &a);
+      while(!a.last)
+      {
+         if(PULSEAUDIO_pa_operation_get_state(o) == PA_OPERATION_CANCELLED)
+         {
+            break;
+         }
+         if (PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) +            break;
+         }
+      }
+   }
+   DeInit(pulse_local_server);
+}
+
 static int
 PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
 {
<at> <at> -530,8 +611,9 <at> <at>
         UnloadPulseAudioLibrary();
         return 0;
     }
-
+   
     /* Set the function pointers */
+    impl->DetectDevices = PULSEAUDIO_DetectDevices;
     impl->OpenDevice = PULSEAUDIO_OpenDevice;
     impl->PlayDevice = PULSEAUDIO_PlayDevice;
     impl->WaitDevice = PULSEAUDIO_WaitDevice;
<at> <at> -539,7 +621,7 <at> <at>
     impl->CloseDevice = PULSEAUDIO_CloseDevice;
     impl->WaitDone = PULSEAUDIO_WaitDone;
     impl->Deinitialize = PULSEAUDIO_Deinitialize;
-    impl->OnlyHasDefaultOutputDevice = 1;
+    impl->OnlyHasDefaultOutputDevice = 0;
 
     return 1;   /* this audio target is available. */
 }
diff -r 5bf21e9e191f src/audio/pulseaudio/SDL_pulseaudio.h
--- a/src/audio/pulseaudio/SDL_pulseaudio.h   Sun Sep 14 19:44:53 2014 +0200
+++ b/src/audio/pulseaudio/SDL_pulseaudio.h   Sun Sep 14 21:40:27 2014 +0200
<at> <at> -30,6 +30,7 <at> <at>
 /* Hidden "this" pointer for the audio functions */
 #define _THIS SDL_AudioDevice *this
 
+
 struct SDL_PrivateAudioData
 {
     /* pulseaudio structures */


And I assume it is necessary to add: It is ok the add it to the SDL2 Codebase under the zlib license



void (*segfault)(void) = 0;
int main(int argc, char **argv){segfault(); return 0;}
//Should not work, but does what told
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Alexander Chaliovski | 15 Sep 15:00 2014
Picon

UITextField inside SDL_Window

Hello,

Is it currently possible to create UITextField inside SDL_Window for IOS ?
I am curious on how to do it I was trying something like this but I cannot get it to work correctly.


    UIWindow * appWindow = wmInfo.info.uikit.window;
    UITextField* text = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
    UIViewController * rootViewController = appWindow.rootViewController;
    [view addSubview:text];


Thanks,

Alex
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Iori Branford | 15 Sep 00:18 2014
Picon

App randomly crashes on Windows with latest MinGW/MSYS

I build my app for Win32 with MinGW/MSYS. Uses SDL2, SDL2_image, SDL2_mixer.
Since this revision, I tried upgrading MinGW/MSYS, which went bad due to existing-file conflicts, and so I did a full reinstall. Then I started to get random crashes with uninformative call stacks like:








Code:
#0  0x6c7b52e7 in SDL_LogCritical ()
   from C:\MinGW\msys\1.0\home\Kevin\witchfire\SDL2.dll
#1  0x00002000 in ?? ()
#2  0x00000080 in ?? ()
#3  0x00000000 in ?? ()

Some of them are longer and have random SDL2_mixer functions in there. But I've yet to notice any pattern to how long the app lasts or where exactly in what executable it happens.

Oh, I tried going back to the revision before that one and still had similar crashes. Haven't got any on Linux yet.

Any ideas or advice on this are appreciated.
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Alexander Chaliovski | 14 Sep 13:11 2014
Picon

Get UIView and UIViewController from SDL Window

Hi I am trying to get proper UIView and UIViewController from SDL Window and pass it to Ogre but the program crashes with [SDL_uikitopenglview setMWindowName:]: unrecognized selector sent to instance 0xa213940. I am not sure if I am doing it properly. My code is below.


    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        printf("Could not initialize SDL\n");
        return 1;
    }
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
  
    SDL_DisplayMode displayMode;
    SDL_GetDesktopDisplayMode(0, &displayMode);

    SDL_Window* window = SDL_CreateWindow(NULL, 0, 0, displayMode.w, displayMode.h, SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_RESIZABLE);


    SDL_GLContext glContext = SDL_GL_CreateContext(window);

    SDL_SysWMinfo wmInfo;
    SDL_VERSION(&wmInfo.version);
    SDL_GetWindowWMInfo(window,&wmInfo);
 
    //Objective-C
    UIWindow * appWindow = wmInfo.info.uikit.window;
    UIViewController * rootViewController = appWindow.rootViewController;
    UIView * myView = [appWindow.subviews objectAtIndex:0];


    //Passing the handles to Ogre
    Ogre::NameValuePairList params;
    params["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned long)appWindow);
    params["externalViewHandle"] = Ogre::StringConverter::toString((unsigned long)myView);
    params["externalViewControllerHandle"] = Ogre::StringConverter::toString((unsigned long)rootViewController);

_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Midi | 11 Sep 22:34 2014
Picon

Rendering textures to textures?

Before anyone asks, yes, I have checked Google.

I've been searching for a way to render a texture onto another texture. My problem is I need to be able to draw things to particular layers, and textures seem to only be able to draw directly to the screen or to a viewport. Whenever I look online, I just find links that lead back to the wiki page on rendering a texture to the screen. Is it possible to render a texture onto another texture without having to use surfaces and then converting to textures (which kinda defeats the point of textures in the first place, but I've actually had people tell me to do that).
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Architekt | 9 Sep 15:01 2014
Picon

SDL[audio]:XAudio2: XAudio2Create() failed at initialization

I get this error on Windows 7, 64 Bit with Code::Blocks 13.12 and g++ (MinGW) 9.8.1.
I simply try to call:







Code:

if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0) {
   std::cerr    exit(1);
}

It works fine, but if I call SDL_GetError after that, I get the error. Is that only a note? Or is that something bad?
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
JeZ-l-Lee | 12 Sep 21:33 2014
Picon

[Off Topic]-Check Website On Both OS X & iOS ?

[Off Topic]-Check Website On Both OS X & iOS ?

Hi,

We have made significant changes in the render code for our new HTML5/JS website.
I was hoping someone here with a Mac OS X computer and/or iOS iPhone/iPad/iPod device
could just do a quick test of our new HTML5/JS website and let us know if it works ok on Apple stuff?

The website URL is here:
http://www.16BitSoft.com

Just visit the above URL on your OS X computer and/or iOS device Internet browser and tell us if it works ok.
Also let us know what platform you tried and OS version.

The HTML5/JS engine used for this website is the precursor to our next HTML5/JS video game which would start soon...
Thank you!



JeZ+Lee
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
Alexander Chaliovski | 11 Sep 22:29 2014
Picon

Sdl 2.0.3 with Ogre 1.9.0

Hi guys,

I am trying to integrate SDL 2.0.3 to work Ogre 1.9.0 for window and events handling.
At the moment I cannot get any input or window events from SDL, but I can get Ogre to use the SDL window handle. I am using the wmInfo.info.uikit.window to get the handle and then I pass it to Ogre. The only thing I am not sure is if I am getting the GL context properly. I can get only one event when I start SDL with Ogre SDL_APP_DIDENTERFOREGROUND.
I would really appreciate any help as I am stuck on the problems above.
Also I am working under OSX and IOS 7.1  simulator. The same thing with irrlicht worked like a charm.

SDL and Ogre initialization:

//SDL     if (SDL_Init(SDL_INIT_VIDEO) < 0)     {         printf("Could not initialize SDL\n");         return 1;     }     SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1);     SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);         SDL_DisplayMode displayMode;     SDL_GetDesktopDisplayMode(0, &displayMode);         /* create window and renderer */     SDL_Window* window = SDL_CreateWindow(NULL, 0, 0, displayMode.w, displayMode.h, SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_RESIZABLE);         SDL_GLContext glContext = SDL_GL_CreateContext(window);         SDL_SysWMinfo wmInfo;     SDL_VERSION(&wmInfo.version);     SDL_GetWindowWMInfo(window,&wmInfo);     m_pLog = Ogre::LogManager::getSingleton().createLog("OgreLogfile.log", true, true, false);     m_pLog->setDebugOutputEnabled(true);     String pluginsPath;     m_pRoot = new Ogre::Root(pluginsPath, Ogre::macBundlePath() + "/ogre.cfg");     m_StaticPluginLoader.load();         m_pRenderWnd = m_pRoot->initialise(false, wndTitle);         size_t winHandle = reinterpret_cast<size_t>(wmInfo.info.uikit.window);     size_t glHandle = reinterpret_cast<size_t>(glContext);         Ogre::NameValuePairList params;     params["externalWindowHandle"] = Ogre::StringConverter::toString((unsigned long)winHandle);     params["externalGLContext"] =   Ogre::StringConverter::toString((unsigned long)glHandle);     params["externalGLControl"] = String("True");     m_pRenderWnd = m_pRoot->createRenderWindow("", displayMode.w/2, displayMode.h/2, false,  &params);


My main loop:



DemoApp demo;     demo.startDemo();     bool done = false;         SDL_Event event;         double mStartTime;     double mLastFrameTime;     while (!done)     {               mStartTime = OgreFramework::getSingletonPtr()->m_pTimer->getMillisecondsCPU();       OgreFramework::getSingletonPtr()->updateOgre(mLastFrameTime);       OgreFramework::getSingletonPtr()->m_pRoot->renderOneFrame();       mLastFrameTime = OgreFramework::getSingletonPtr()->m_pTimer->getMillisecondsCPU() - mStartTime;                         while (SDL_PollEvent(&event))         {             switch (event.type)             {                 case SDL_FINGERMOTION:                     SDL_Log("Finger Motion");                     break;                 case SDL_FINGERDOWN:                     SDL_Log("Finger Down");                     break;                             case SDL_FINGERUP:                     SDL_Log("Finger Up");                     break;                 case SDL_QUIT:                     done = true;                     break;                                     case SDL_APP_DIDENTERFOREGROUND:                     SDL_Log("SDL_APP_DIDENTERFOREGROUND");                     break;                                     case SDL_APP_DIDENTERBACKGROUND:                     SDL_Log("SDL_APP_DIDENTERBACKGROUND");                     break;                                     case SDL_APP_LOWMEMORY:                     SDL_Log("SDL_APP_LOWMEMORY");                     break;                                     case SDL_APP_TERMINATING:                     SDL_Log("SDL_APP_TERMINATING");                     break;                                     case SDL_APP_WILLENTERBACKGROUND:                     SDL_Log("SDL_APP_WILLENTERBACKGROUND");                     break;                                     case SDL_APP_WILLENTERFOREGROUND:                     SDL_Log("SDL_APP_WILLENTERFOREGROUND");                     break;                                     case SDL_WINDOWEVENT:                 {                     switch (event.window.event)                     {                                             case SDL_WINDOWEVENT_RESIZED:                         {                             SDL_Log("Window %d resized to %dx%d", event.window.windowID, event.window.data1, event.window.data2);                                                         break;                         }                     }                 }             }         }


_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Starg | 11 Sep 20:52 2014

How to check if a mutex is locked?

Hi there,

Is there a way to check if a mutex is locked?

The only way I can see how to do it at the moment is to try and lock it. If it isn't locked I can then unlock it, and if it is locked I get a SDL_MUTEX_TIMEDOUT value back.

However, this seems like a clumsy solution.

Cheers,
Steve
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
kj192 | 11 Sep 17:52 2014
Picon

Sdl 2.0.3 and Ubuntu 14.04

Hi Everyone,

I don't know who has this problem like me, but I have a laptop freshly installed Ubuntu 14.04 32bit and SDL works fine just the screen goes to black and white after a 5 second.
I have installed the latest Ubuntu 14.04 64 bit to my PC, and the black and white effect is the same.
Is anybody know a solution how to solve this to not loose color?

Looking forward to your answers.
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Gmane