Scott Sibley | 10 Feb 01:09
Picon
Gravatar

debugging android example

Hello. I'm trying to debug code based on the android-project SDL example. The crash I'm working with happens within a loop in SDL_main(), and the app exits before GDB has a chance to attach. I've tried creating a loop with: t=1;while(t);, and I'm supposed to be able to change t, but I'm not sure how to go about that as the app is busy running when it gets to t, and when I ctrl-c, then the execution isn't stopped at that while loop. I get the following:

warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint
0xafd0c51c in epoll_wait () from /home/starlon/workspace/FroyVisuals/obj/local/armeabi-v7a/libc.so
(gdb) c
Continuing.
^C[New Thread 8452]

Program received signal SIGINT, Interrupt.
[Switching to Thread 8452]
0xafd0c51c in epoll_wait () from /home/starlon/workspace/FroyVisuals/obj/local/armeabi-v7a/libc.so
(gdb) quit
The program is running.  Exit anyway? (y or n) y


Any clues how I can debug this?

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

SDL2 for HP TouchPad and BlackBerry PlayBook?

Hi guys,

Does SDL2 support HP TouchPad (webOS 3.0.5) and BlackBerry PlayBook (2.0 
SDK)

There is SDL12 in HP TouchPad, and I think something like it for 
PlayBook (on github), but I was wondering whether these will get 
supported in the main branch for SDL.

Thanks!
Mike Lawrence | 9 Feb 17:17
Picon
Picon
Favicon

Time of screen update?

Hi folks,

First, thanks to everyone that has helped with my previous queries;
this list has be very useful so far in my explorations on how I can
make my experiments more precise using SDL.

I think my last question is this: after SDL_Flip() is it possible to
get a timestamp for when the flip will actually take place? As I
understand it, SDL_Flip() will simply set up the flip to occur at the
next vertical retrace then return immediately, not waiting until the
actual retrace happens. It would be useful to me to know the time of
the retrace that presented the surface supplied to SDL_Flip().

Cheers,

Mike

--
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar: http://goo.gl/BYH99

~ Certainty is folly... I think. ~
gabomdq | 9 Feb 16:14
Picon
Gravatar

Re: Android SDL_RWFromFile ERROR

I think the native code needs to return to the "Java side" to actually release the references, that's why you eventually run out. See here http://groups.google.com/group/android-ndk/browse_thread/thread/490e1ba73e3102b5



Gabriel Jacobo
mdqinc.com
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
riksweeney | 8 Feb 10:36
Picon
Gravatar

Re: How to copy a certain part of the screen?

This should work for you. Note that "screen" is your sdl screen as defined by SDL_SetVideoMode.








Code:
void drawClippedImage(SDL_Surface *original, int srcX, int srcY, int destX, int destY, int width, int height)
{
   SDL_Rect src, dest;

   // Set the source x, y, width and height
   src.x = srcX;
   src.y = srcY;
   src.w = width;
   src.h = height;

   // Set the destination x, y, width and height
   dest.x = destX;
   dest.y = destY;
   dest.w = width;
   dest.h = height;

   // Copy the portion of the original image to the screen
   SDL_BlitSurface(original, &src, screen, &dest);
}


So if you wanted to copy from 50, 0 and blit it to 200, 400 and the width is 32 and the height is 64, you would call








Code:
drawClippedImage(original, 50, 50, 200, 400, 32, 64);
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Brian Barnes | 8 Feb 01:02
Favicon

Re: SDL 2.0 patches

I'd like to second these patches, I've been compiling a new list of problems I've had with 2.0 on OS X and the
crashing with the relative mouse movement is the big one.  I'll also put out that the "SDL 1.2 Mac shortcut
key passthrough" one is also important as things like cmd-q are now caught by the system and produce a
"beep" because my program doesn't have a proper quit action.

[>] Brian
vlag | 6 Feb 20:56
Picon
Gravatar

[SDL_image & ttf] Bug on OSX 10.5 32bit

Hi everybody !

First of all, I apologize in advance for my English, I still have some languages problems

I'm currently try to port Zelda Solarus ( http://zelda-solarus.com/jeu-zsdx-download ), on Mac OSX 10.5+.
Actually, there is no problem for most of users, but I got some feedback from OSX 10.5 - Intel 32bit users, in wich the game doesn't launch.
After checking the error message, the issue is because of embed framework (Freetype on SDL_ttf and webp on SDL_image) are "not a suitable image" (unknow required load command 0x80000022).

Strangely, the framework are actually compiled for i386 and x86_64, so I guess you just forgot to set the deployment target on Mac OS 10.5, or the -mmacosx-version-min=10.5 flag if you compile without XCode.
I'm not even sure this is the trouble, and I'm not a Mac expert, so I'll just switch the "bugged" framework with an equivalent dylib compiled with this flag, send it to the 10.5 users, and this works. Then there is another problem with SDL_image, but the point is the system found the lib.

This is not a big deal, but I thought you might like to know that there is a backyard compatibility issue on the latest frameworks.

PS : I use, of course, the latest version, downloaded yesterday

Thanks

Valentin
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Matthijs Kooijman | 6 Feb 17:44
Picon

Autorefresh on expose removed from 1.3/2.0 ?

(Please CC me, I am not subscribed)

Hey folks,

I've been trying to get an application to work with 1.3 (previously
linking against 1.2) and ran into a redraw issue. When switching from
and back to my application, the screen was not properly redrawn, while
it worked with 1.2.

A bit of digging suggests that SDL had an "autorefresh" feature where it
would just update the entire screen instead of posting a SDL_VIDEOEXPOSE
event when using ximage. This feature seems to be removed in 1.3 / 2.0
(I'm also a bit confused about the distinction between those
versions...). This means with 1.3 I must handle the SDL_VIDEOEXPOSE
event with a call to SDL_UpdateRect to make it work.

Finding a bit more info on this removal using the mercurial repositories
didn't quite work, it seems the 1.2 and 2.0 repositories have no base?

Note that I am still using SDL_SetVideoMode and SDL_UpdateRects to do my
screen drawing, since I want to keep my application compatible with 1.2
as well (with minimal #ifdeffing). So perhaps this would be
automagically fixed

In any case, if my observations are correct, and this auto-refresh was
removed, would it make sense to document this at
http://wiki.libsdl.org/moin.cgi/MigrationGuide I would have a stab at
it, but I really don't know enough of the change to write anything
sensible.

Gr.

Matthijs
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
ecomsteve | 6 Feb 15:31
Picon
Gravatar

UpdateRect produces a black screen

Hi

I have been working through a tutorial book that uses SDL. I have a piece of code that reads a ppm file and displays the image on the screen. The program seems to read the file and set the hight and width correctly creating a window the width and hight as the image but there is no image. If i move the image file the program return an error incating the image is missing so i know its reading it. Any help would be greatly appreicated. I have included the code.

Thankd

Steve








Code:
#include
#include
#include
#include

//A public class is the same as a 'struct'
class CImage {
public:
  unsigned char red;
  unsigned char green;
  unsigned char blue;
};


void ppm_read_comments ( FILE *fp )
{
  int c;
  while ( (c = getc ( fp ) )  == '#' ) {
    while (  getc( fp )  != '\n' )
   ;
  }
  ungetc ( c, fp );
}

class ppm_error
{
  public:
    ppm_error() {
      printf("\nIncorrect PPM format!\n");
      exit ( 1 );
    }
};


//change from (R, G, B) to (B, G, R)
void  ppm2sdl ( CImage *ibuf, int width, int height )
{
  unsigned char temp;

  for ( int i = 0; i     int row_offset = i * width;
    for ( int j = 0; j       int offset =  row_offset + j;
      temp = ibuf[offset].red;
      ibuf[offset].red = ibuf[offset].blue;
      ibuf[offset].blue = temp;
    }
  }
}

int main( int argc, char* args[] )
{
  int ppmh[20], c;         //PPM header
  int width, height;         //image width and height
  SDL_Surface *screen;
  char filename[] = "C:/data/beach.ppm";

  FILE *input = fopen (filename, "rb"); //PPM file for testing read
  if ( !input ) {
    printf("\nError opening input file %s!\n", filename);
    return 1;
  }

  //read PPM input file
  ppm_read_comments ( input );      //read comments
  char temp[100];
  fscanf ( input, "%2s", temp );
  temp[3] = 0;
  if ( strncmp ( temp, "P6", 2 ) )
    throw ppm_error();
  ppm_read_comments ( input );
  fscanf ( input, "%d", &width );
  ppm_read_comments ( input );
  fscanf ( input, "%d", &height );
  ppm_read_comments ( input );
  int colorlevels;
  fscanf ( input, "%d", &colorlevels );
  printf("\n%s PPM file: ", temp );
  printf(" \n\twidth=%d\theight=%d\tcolorlevles=%d\n", width,height,colorlevels+1 );
  ppm_read_comments ( input );
  while ( ( c = getc ( input )) == '\n' );     //get rid of extra line returns
  ungetc ( c ,input );

  // May use CImage ibuf[width][height] if we do not use SDL_QUIT;
  CImage *ibuf = (CImage *) malloc ( width * height * 3 );
  fread ( ibuf,  3, width * height, input );   //read image data from file
  fclose ( input );

  //initialize video system
  if ( SDL_Init( SDL_INIT_VIDEO )     fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
    exit(1);
  }
  //ensure SDL_Quit is called when the program exits
  atexit(SDL_Quit);   //if not use this, we need to
                        //  do house cleaning manually when program ends

  //set video mode of width x height with 24-bit pixels
  screen = SDL_SetVideoMode( width, height, 24, SDL_SWSURFACE);
  if ( screen == NULL ) {
        fprintf(stderr, "Unable to set %dx%d video: %s\n", width, height, SDL_GetError());
        exit(1);
  }

  //convert PPM format (R, G, B)  to SDL format (B, G, R)
  ppm2sdl ( ibuf,  width, height );

  screen->pixels = ibuf;  //point framebuffer to data buffer

    //  ibuf needs to be dynamically allocated if SDL_QUIT is used
    printf("update rect\n"   );
    SDL_UpdateRect ( screen, 0, 0, 0, 0 );   //blit data to screen

   // SDL_Flip(screen);
   // SDL_CreateRGBSurface(screen, 0, 0, 0, 0,0,0,0);

  SDL_Delay ( 4000 );     //delay 4 seconds before exit
  printf("Displaying PPM image %s successful!\n", filename );

  //do NOT free( ibuf ) if use SDL_QUIT which does the house cleaning
  return 0;
}



Steve
_______________________________________________
SDL mailing list
SDL <at> lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Wim Looman | 7 Feb 22:07
Picon
Gravatar

SDL 2.0 patches

Hi there SDL folks,

I've recently updated my first attempt at a game engine to use SDL 1.3/2.0.  I was very happy to see the new
relative mouse mode available on OS X and can't wait till it's supported on other window managers. 
Unfortunately I noticed a few problems with it, luckily I have attached patches to fix these problems :)

The first is simply fixing a crash when disabling relative mouse mode without the mouse being over an SDL
window, since the cursor was not being controlled by SDL we don't need to bother warping it around.

The second moves some of the low level cursor control from the window manager to the mouse manager.  I'm not
entirely certain this is correct, but I believe when the cursor is outside an SDL window it should be
rendered with the default look, while saving what look it had for when the window is re-entered.

The reason behind this change was the cursor was not being hidden/unhidden when relative mode was
enabled/disabled with the mouse outside any SDL window.

The third change saves the current x, y co-ordinates when relative mode is entered and then restores them
when relative mode is disabled.  I'm pretty sure this was the intended behavior of the warp.

--
Wim Looman
ghostunderscore <at> gmail.com

---

# HG changeset patch
# User Wim Looman <ghostunderscore <at> gmail.com>
# Date 1328263728 -46800
# Node ID 43d4e29a5dfc8f3343127578047d38183b1c1a4c
# Parent  07e08cb5869602f5771ff5a61f4ef5b76e8a4cba
Fix null reference exception.

Occurred when using relative mouse mode without a focused window.

diff -r 07e08cb58696 -r 43d4e29a5dfc src/events/SDL_mouse.c
--- a/src/events/SDL_mouse.c	Sat Jan 28 14:53:23 2012 -0500
+++ b/src/events/SDL_mouse.c	Fri Feb 03 23:08:48 2012 +1300
@@ -323,7 +323,7 @@
    /* Set the relative mode */
    mouse->relative_mode = enabled;

-    if (!enabled) {
+    if (!enabled && mouse->focus) {
        /* Restore the expected mouse position */
        SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
    }

# HG changeset patch
# User Wim Looman <ghostunderscore <at> gmail.com>
# Date 1328266431 -46800
# Node ID 2688fd67db682b8f907c71b8e0516a46fa9a7f14
# Parent  43d4e29a5dfc8f3343127578047d38183b1c1a4c
Change SDL_SetCursor to set the cursor back to the default cursor when the
window is unfocused.

diff -r 43d4e29a5dfc -r 2688fd67db68 src/events/SDL_mouse.c
--- a/src/events/SDL_mouse.c	Fri Feb 03 23:08:48 2012 +1300
+++ b/src/events/SDL_mouse.c	Fri Feb 03 23:53:51 2012 +1300
@@ -465,7 +465,11 @@
        }
        mouse->cur_cursor = cursor;
    } else {
-        cursor = mouse->cur_cursor;
+        if (mouse->focus) {
+            cursor = mouse->cur_cursor;
+        } else {
+            cursor = mouse->def_cursor;
+        }
    }

    if (cursor && mouse->cursor_shown && !mouse->relative_mode) {
diff -r 43d4e29a5dfc -r 2688fd67db68 src/video/cocoa/SDL_cocoamouse.m
--- a/src/video/cocoa/SDL_cocoamouse.m	Fri Feb 03 23:08:48 2012 +1300
+++ b/src/video/cocoa/SDL_cocoamouse.m	Fri Feb 03 23:53:51 2012 +1300
@@ -92,15 +92,13 @@
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

-    if (SDL_GetMouseFocus()) {
-        if (cursor) {
-            NSCursor *nscursor = (NSCursor *)cursor->driverdata;
+    if (cursor) {
+        NSCursor *nscursor = (NSCursor *)cursor->driverdata;

-            [nscursor set];
-            [NSCursor unhide];
-        } else {
-            [NSCursor hide];
-        }
+        [nscursor set];
+        [NSCursor unhide];
+    } else {
+        [NSCursor hide];
    }

    [pool release];
diff -r 43d4e29a5dfc -r 2688fd67db68 src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/cocoa/SDL_cocoawindow.m	Fri Feb 03 23:08:48 2012 +1300
+++ b/src/video/cocoa/SDL_cocoawindow.m	Fri Feb 03 23:53:51 2012 +1300
@@ -313,9 +313,7 @@
            CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint);
        } else {
            SDL_SetMouseFocus(NULL);
-
-            [[NSCursor arrowCursor] set];
-            [NSCursor unhide];
+            SDL_SetCursor(NULL);
        }
    }
}

# HG changeset patch
# User Wim Looman <ghostunderscore <at> gmail.com>
# Date 1328267601 -46800
# Node ID 0d5148d1e578c2a9eb35f3afe2b541d1e48c90e5
# Parent  2688fd67db682b8f907c71b8e0516a46fa9a7f14
Make mouse relative mode save the original co-ordinates to restore them
properly.

diff -r 2688fd67db68 -r 0d5148d1e578 src/events/SDL_mouse.c
--- a/src/events/SDL_mouse.c	Fri Feb 03 23:53:51 2012 +1300
+++ b/src/events/SDL_mouse.c	Sat Feb 04 00:13:21 2012 +1300
@@ -323,9 +323,13 @@
    /* Set the relative mode */
    mouse->relative_mode = enabled;

-    if (!enabled && mouse->focus) {
+    if (enabled) {
+        /* Save the expected mouse position */
+        mouse->original_x = mouse->x;
+        mouse->original_y = mouse->y;
+    } else if (mouse->focus) {
        /* Restore the expected mouse position */
-        SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
+        SDL_WarpMouseInWindow(mouse->focus, mouse->original_x, mouse->original_y);
    }

    /* Flush pending mouse motion */
diff -r 2688fd67db68 -r 0d5148d1e578 src/events/SDL_mouse_c.h
--- a/src/events/SDL_mouse_c.h	Fri Feb 03 23:53:51 2012 +1300
+++ b/src/events/SDL_mouse_c.h	Sat Feb 04 00:13:21 2012 +1300
@@ -60,6 +60,8 @@
    int last_x, last_y;         /* the last reported x and y coordinates */
    Uint8 buttonstate;
    SDL_bool relative_mode;
+    /* the x and y coordinates when relative mode was activated */
+    int original_x, original_y;

    SDL_Cursor *cursors;
    SDL_Cursor *def_cursor;
Atis | 7 Feb 21:41
Picon
Gravatar

SDL 2.0: Loading textures on iOS with alpha

Hi,

for the past few months I've been using SDL 1.3 on iOS
to load textures into OpenGL.

The code is fairly basic and probably copied from some
example code. It's supposed to convert `img`, an SDL_Surface loaded
with SDL_image, to a format that's accepted by OpenGL.

-----

int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ABGR8888, &bpp, &Rmask,
                           &Gmask, &Bmask, &Amask);
SDL_Surface *img_rgba8888 = SDL_CreateRGBSurface(0, img->w, img->h, bpp,
                                                  Rmask, Gmask, Bmask, 
Amask);
SDL_SetAlpha(img, SDL_RLEACCEL, 0);
SDL_BlitSurface(img, NULL, img_rgba8888, NULL);

uint pow_w = nearest_pow2(img->w);
uint pow_h = nearest_pow2(img->h);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pow_w, pow_h, 0, GL_RGBA,
             GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, img->w, img->h, GL_RGBA,
                GL_UNSIGNED_BYTE, img_rgba8888->pixels);

-----

So anyway, for some reason the SDL_SetAlpha() call was necessary.
If not there, the final surface would end up with alpha=0 for all
pixels. With it however, everything was working perfectly.

Today I pulled from SDL and SDL_image hg repos, and noticed the
SDL_SetAlpha() function has been removed from SDL (and SDL version
updated to 2.0).

Removing the call once again produces alpha=0 for all pixels.
Replacing SetAlpha() with a call to
        SDL_SetSurfaceRLE(img, SDL_RLEACCEL)
does not help either -- partially transparent pixels end up being
fully opaque (alpha=255).

In fact the SDL_RLEACCEL thing is probably a red herring and
should not be necessary at all. In the end though, I'm not too
sure about SDL's blitting semantics and what exactly I'm
doing wrong. I've tried filling the destination surface with
alpha=255 pixels before the blit but nothing I do produces the
expected alpha values.

Summary: the above texture loading code messes up image alpha
values. Not sure what to do. Please help!

Thanks,
Atis

Gmane