Simple Sdl_Rect Problem


JustJoekingEX

Still Fresh
Joined
Aug 28, 2009
Messages
5
I have the following code fragment which I compiled for the wiz using xp 64 sp2, and for some reason it worked right the first time , however now
it seems like i can only blit images on row 1. using any bitmap the image appears but its blitting at 10,0 instead of 10,20.

i am using SDL.a to link from the gp2x wiz libs and using no linker options. (compiler is mingw), any ideas?

Code:
#define DWORD unsigned int
#if __GP2XWIZ__
#define VK_ACTIVATED SDL_JOYBUTTONDOWN
#define VK_DEACTIVATED SDL_JOYBUTTONUP
#define INPUT_EVT jbutton.button
#define VK_UP  GP2X_BUTTON_UP
#define VK_DOWN  GP2X_BUTTON_DOWN
#define VK_LEFT   GP2X_BUTTON_LEFT            
#define VK_RIGHT  GP2X_BUTTON_RIGHT           
#define VK_UPLEFT  GP2X_BUTTON_UPLEFT          
#define VK_UPRIGHT  GP2X_BUTTON_UPRIGHT         
#define VK_DOWNLEFT  GP2X_BUTTON_DOWNLEFT        
#define VK_DOWNRIGHT  GP2X_BUTTON_DOWNRIGHT       
#define VK_CLICK  GP2X_BUTTON_CLICK           
#define VK_ACTION2  GP2X_BUTTON_A
#define VK_ACTION4  GP2X_BUTTON_B
#define VK_ACTION3  GP2X_BUTTON_X
#define VK_ACTION1  GP2X_BUTTON_Y
#define VK_SHOULDER_LEFT  GP2X_BUTTON_L
#define VK_SHOULDER_RIGHT  GP2X_BUTTON_R
#define VK_START  GP2X_BUTTON_START
#define VK_SELECT  GP2X_BUTTON_SELECT
#define VK_VOLUP  GP2X_BUTTON_VOLUP
#define VK_VOLDOWN  GP2X_BUTTON_VOLDOWN

#else
#define VK_ACTIVATED SDL_KEYDOWN
#define VK_DEACTIVATED SDL_KEYUP
#define  INPUT_EVT key.keysym.sym
#define VK_UP  SDLK_UP
#define VK_DOWN  SDLK_DOWN
#define VK_LEFT   SDLK_LEFT
#define VK_RIGHT  SDLK_RIGHT
#define VK_UPLEFT  -1
#define VK_UPRIGHT  -1

#include <stdlib.h>
#include <SDL.h>
#include <SDL_video.h>

#define VK_DOWNLEFT  -1
#define VK_DOWNRIGHT  -1
#define VK_CLICK  -1
#define VK_ACTION2  SDLK_a
#define VK_ACTION4  SDLK_d
#define VK_ACTION3  SDLK_s
#define VK_ACTION1  SDLK_w
#define VK_SHOULDER_LEFT  SDLK_INSERT
#define VK_SHOULDER_RIGHT  SDLK_PAGEUP
#define VK_START  SDLK_DELETE
#define VK_SELECT  SDLK_PAGEDOWN
#define VK_VOLUP  SDLK_PLUS
#define VK_VOLDOWN  SDLK_MINUS

#endif







using namespace std ; 



const int SCREEN_WIDTH = 320;
const int SCREEN_HEIGHT = 240;
const int SCREEN_BPP = 16;

//The event structure that will be used
SDL_Event event;
bool quit = false;


int main(int argc, char** argv) {

SDL_Surface *screen;
     SDL_Surface *bmp;
     SDL_Rect    targetarea;

     /* Initialize SDL */
     SDL_Init(SDL_INIT_VIDEO);

     /* Initialize the screen / window */
     screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 8, SDL_SWSURFACE);

     /* Load test.bmp */
     bmp = SDL_LoadBMP("test.bmp");

     /* Draw the image to 10, 20 */
     targetarea.x = 10;
     targetarea.y = 30;
     targetarea.w = bmp->w;
     targetarea.h = bmp->h;

     SDL_BlitSurface(bmp, NULL, screen, &targetarea);

     /* update the screen (aka double buffering) */
     SDL_Flip(screen);
     SDL_Delay(1000);
         chdir("/usr/gp2x");


	execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);

    return (0);
}
 
JustJoekingEX said:
Pickle said:
try linking dynamically.

I thought that was the default, what is the linker commandline switch for that?

ok simplified it to this, and it works on the pc but not the wiz - specifically i see nothing on the screen, but it runs for 2 seconds and then quits like its supposed to.

I compiled the particles demo for the wiz and it ran fine,and then when i used sdl fillrect right before the flip, it looks correct on the pc, but draws minus the filled rect on the wiz.

Code:
/* 
 * File:   main.cpp
 * Author: Joseph
 *
 * Created on August 20, 2009, 12:28 PM
 */
 

#include <SDL.h>
#include <SDL_video.h>

#include <iostream>
int main(int argc, char *argv[]) {
     SDL_Surface *screen;
     SDL_Surface *bmp,*tmp;
     SDL_Rect    targetarea;

     /* Initialize SDL */
     SDL_Init(SDL_INIT_EVERYTHING);

     /* Initialize the screen / window */
     screen = SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE);




    SDL_ShowCursor(SDL_DISABLE);
     /* Load test.bmp */

     /* Draw the image to 10, 20 */
     targetarea.x = 32;
     targetarea.y = 32;
     targetarea.w = 320-64;
     targetarea.h =240-64;




     SDL_FillRect(screen,&targetarea,0x0F00);
            SDL_Flip(screen);


     SDL_Delay(2000);

  
     chdir("/usr/gp2x");
       execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);

       SDL_Quit();
    return (0);
}
 
Last edited by a moderator:
Added -dynamic switch and removed sdl.so from my project and it ran fine! I had to include the sdl libs from the archive in the project folder but it works :) thanks a million
 
Back
Top