bilsch01 | 1 Apr 17:26 2015
Picon
Picon

Building a GUI using SDL.

I have a C program using SDL to plot graphs. The program can take many user input parameters via scanf. The program below is an example of the user input part. I want to replace the printf and scanf stuff by making a GUI using SDL. Can someone recommend appropriate SDL statements for drawing boxes and taking user input? Is there an example GUI I could adapt? Thanks. Bill S.








Code:

#include

int main(void)
{

float w1=0.5, w2=2.0, w3=0.14159;
char yesno;

   printf("\nchange frequency w1, w2 or w3? (y/n): ");
   scanf("%s", &yesno);
   if (yesno == 'y')
   {   printf("\nw1 = %1.3f  ",w1);
      printf(" change w1? (y/n): ");
      scanf("%s", &yesno);
      if (yesno == 'y')
      {   printf("\nenter n.nnn for new w1: ");
         scanf("%f", &w1);
      }
      printf("\nw2 = %1.3f  ",w2);
      printf(" change w2? (y/n):");
      scanf("%s", &yesno);
      if (yesno == 'y')
      {   printf("\nenter n.nnn for new w2: ");
         scanf("%f", &w2);
      }
      printf("\nw3 = %1.3f  ",w3);
      printf(" change w3? (y/n):");
      scanf("%s", &yesno);
      if (yesno == 'y')
      {   printf("\nenter n.nnn for new w3: ");
         scanf("%f", &w3);
      }
   }
}
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
TheSHEEEP | 31 Mar 11:11 2015
Picon

SDL_TEXTINPUT happens too often

Hey there,

I am currently implementing text input into our application and am of course using SDL_TEXTINPUT for that.

Now for some reason I can't figure out, the SDL_TEXTINPUT event happens multiple times.
For example, pressing a yields two events, each containing "a".
Pressing ö,ä,ü or ß (German keyboard) and some other keys yields the event three times (so "ß", "ß", "ß" for example).

The reason is not key up and key down. All events are fired when the key is down.

Of course I could easily prevent this by checking for duplicate events, but if there is a better way to solve this, I'm open to suggestions
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
ternaryd | 30 Mar 22:01 2015
Picon

SDL2 crash on first steps

Hi,

The following lines (w/o error handling):

    SDL_Init (SDL_INIT_VIDEO);
    w = SDL_CreateWindow ("title", x, y, w, h,
                          SDL_WINDOW_SHOWN);
    r = SDL_CreateRenderer (w, -1, 0);

will cause a SIGSEGV in the last line. The
first two calls succeed. I'm running Debian
unstable where I installed the debug version.
So I found out, that this happens in
SDL_x11windows.c on line 347. From that line on
I find:

    SDL_DisplayData *displaydata =
        (SDL_DisplayData *)
        SDL_GetDisplayForWindow(window)->driverdata;

From gdb I know, that "window" is still a valid
pointer, so it seems SDL_GetDisplayForWindow()
must have failed. Under which circumstances is
this possible? I ran the example programs for
SDL_gfx without problems, so the basic
installation on this computer should be OK,
right? Also, this doesn't seem to be a stage
where a correct OpenGL setup is required. This
is basic X11, right?

Is there an alternative start for an SDL
program which would get me around this?

Thanks,

--

-- 
Cris
Alexey Petruchik | 28 Mar 18:15 2015
Picon

SDL IME support question

I'm porting to SDL2 windows game that has IME support. Game logic implies that no keys are processed during IME composition. This is accomplished by

 if( wParam == VK_PROCESSKEY ) return 0;

condition in WM_KEYDOWN\WM_KEYUP event handlers. I need some way to emulate this behaviour in SDL_KEYDOWN/SDL_KEYUP event handlers. there is no flags in     SDL_KeyboardEvent structure that can be used to filter keys during IME composition. I don't see any composition-started/composition-ended events so i can maintain my own boolean flag. Any ideas how should I accomplish my goal? Should I prepare a patch that adds such functionality? Any opinions are welcome.


Regards, Alexey
 
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
bilsch01 | 28 Mar 12:55 2015
Picon
Picon

Double clicking the icon to run SDL program.

I wrote a C program that draws Lissajous patterns (periodic graphs) using sine functions and exponential functions. There are many parameters that affect the display of these graphs. The program uses SDL for plotting the points of the graph. There is 'front end' C code that allows user to set these parameters using scanf statements. This front end should query the user any time the program is started - indeed it does when the program is started from the command line. I have an icon on my Ubuntu desktop that starts the program when you double click the icon - however when you do it that way none of the user querys are executed. The
program simply runs using the values initialized when the variables were declared. This behavior is a mystery to me. How does it skip over the front end code? I have another simpler program structured the same way also using SDL and it has the same behavior when started by double clicking the icon. I asked this question in a C programming group and they suggested I ask SDL people about it.

TIA. Bill S.
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
jeroen clarysse | 27 Mar 13:33 2015
Picon

rendering centered text

hi all,

i'm trying to figure out how I can render a given char* as centered text 

i use this call currently : 

	SDL_Surface *msg1Sur = TTF_RenderUTF8_Blended_Wrapped(msg_font, msg, msg_color, screen_width);

in which msg_font is ptr to a TTF_Font object, msg is a char* ptr, msg_color is a ptr to an SDL_Color object and
screen_width is calculated as the width of the current SDL window

msg is usually 3 to 6 lines of text, generated from internal code (so NOT read from an RTF file or something
like that)

I'm trying to figure out how I can make the text-align set to centered`

any help would be greatly appreciated !
Hamadi Hawari | 27 Mar 11:48 2015
Picon

scrollig

HI . I NEED A SCROLLIG CODE FOR 2D GAME IN C
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Eric Wasylishen | 27 Mar 01:03 2015
Picon

Xaudio2 - distortion at <44100Hz sample rates

Hey Ryan,
I was wondering if you could give the "loopwave" test in SDL2 a quick run with the Xaudio2 backend, and see if you hear this distortion I'm getting [1].

There's a bug report I made some more details:


I thought maybe it was just my PC, but I'm concerned because I reproduced it on a few different computers today. (Windows 8 and 8.1, Realtek and AMD audio.)   The only explanation I can think of is Xaudio2 is using a very low quality (linear or nearest-neighbour) resampler for upsampling.

Thanks,
Eric


[1] Here's an MP3 of what it sounds like to me: https://bugzilla.libsdl.org/attachment.cgi?id=2090
The distortion sounds like static or clipping, and it's not present when playing the sample.wav with a normal media player or an SDL2 backend other than Xaudio2.
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Emmanuel Gil Peyrot | 26 Mar 18:10 2015
Picon

Difference in behaviour between GLX and EGL contect creation

Hi,

I noticed a quite trappy difference in the frame buffer configuration
selection done by the GLX and EGL code.  Both emit their wish, as the
user defined it using SDL_GL_SetAttribute, but GLX selects the first
one, which is the best, and EGL the most fitting.

I noticed that issue because the default is RGB332, which always gave
me a RGB888 frame buffer on X11, but gave me a RGB565 one on Wayland.

I don’t know what the solution is, maybe removing the code trying to
find the most fitting configuration from EGL would make the most sense.

I also haven’t checked what the other backends do, for that context
creation issue.

--

-- 
Emmanuel Gil Peyrot
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
JeZ-l-Lee | 26 Mar 15:44 2015
Picon

Re: [2.0]-Clear Mouse Button Down Events At App Start?








macrofeet wrote:
Same issue with left click starting app with double click

...

while (SDL_PollEvent(&discard)) { SDL_Delay(100);} // This worked bit lame tho
Hi,

I tried what you typed and it does not work for me?



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
bazz | 25 Mar 11:12 2015
Picon

Simple implementation of SDL_Events

Hi, I'm programming an embedded system. Porting the entire SDL library to this system is more than intimidating, but there are certain things I'm used to thinking like SDL_Events and I was wondering if someone with more experience than I have, can offer some tips on how to simply implement a kind of SDL_Event queue.. It's the queue itself I'm not sure about.. Should I just google 'queue C' ?

But the rest I can handle.. like I understand that I would be adding to the queue when certain events happen low level (like a button released), and in the main loop I will check the queue to parse to process the events like I would in SDL...
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Gmane