Jump to content


Photo

Sdlx And The Xdk


  • Please log in to reply
8 replies to this topic

#1 richi902

richi902

    X-S Enthusiast

  • Members
  • 6 posts

Posted 04 September 2011 - 07:41 PM

hi,

i'm trying to get one of the sdl samples running on the xbox from

http://lazyfoo.net/S...on01/index2.php

i modified mine to look like this

CODE

#include "SDL.h"
#include "xstring"


//The Surfaces
SDL_Surface* Padel = NULL;
SDL_Surface* Screen = NULL;

//void __cdecl main()

SDL_Surface *load_image(std::string filename)
{
    //Temporary storage for the image that's loaded
    SDL_Surface* loadedimage = NULL;

    //The optimized image that will be used
    SDL_Surface* optimizedimage = NULL;

    //Load the image
    loadedimage = SDL_LoadBMP(filename.c_str());


    //if nothing went wrong in loading the image
    if(loadedimage != NULL)
    {
        //Create an optimized image
        optimizedimage = SDL_DisplayFormat(loadedimage);

        //Free the old image
        SDL_FreeSurface(loadedimage);
    }

    //Return the optimized image
    return optimizedimage;
}

void apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination)
{
    //Make a temporary rectangle to hold the offsets
    SDL_Rect offset;

    //Give the offsets to the rectangle
    offset.x = x;
    offset.y = y;

    //Blit the surface
    SDL_BlitSurface(source, NULL, destination, &offset);
}

int main(int argc, char* args[])
{
    
    
    //Fireup SDL
    SDL_Init(SDL_INIT_EVERYTHING);
    //Setup SDL Screen
    Screen = SDL_SetVideoMode( 640, 480, 16, SDL_SWSURFACE | SDL_ANYFORMAT);
        
    //Window Name
    SDL_WM_SetCaption( "SDL Test APP", NULL );

    //Loading Bitmap
    Padel = load_image("image/sprite_one.bmp");
        
    //Apply image on screen
    apply_surface(180, 140, Padel, Screen);
    apply_surface(240, 80, Padel, Screen);

    //update the screen
    SDL_UpdateRect(Screen, 0, 0, 0, 0);

    //Pause
    SDL_Delay(15000);
    
    //Free the loaded image
    SDL_FreeSurface(Padel);
    
    //Quit SDL
    SDL_Quit();

    return 1;
    
}




it compiles fine but it displays no picture on the screen, just a black screen.
the bmp is in the main folder of the xbe on the xbox "e:/games/xbox_sdl/sprite_one.bmp"

i can confirm that the xbe itself is working, because if i change the amount of time for the
SDL_Delay it takes that amount of time to go back to the dash.

so my questen is, whats wrong?

i think 1 have sdlx correctly installed(Microsoft Xbox SDK\xbox\includes and \lib).

is there anything i need to keep in mind while porting windows stuff to the xbox?

oh and i have the latest xdk(59) and the sdlx from hyper_eve's svn
(compiled that in "trunk", i'm not really used to that svn stuff)


hope someone has a clue to fix my problem, thanks in advance uhh.gif


edit:
i forgot to add that it compiles and runs under windows fine and display the bmp

Edited by richi902, 04 September 2011 - 07:44 PM.


#2 Hyper_Eye

Hyper_Eye

    X-S Expert

  • Members
  • PipPipPip
  • 594 posts
  • Location:Huntsvegas, AL.
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 04 September 2011 - 08:33 PM

The Xbox cannot handle forward slashes in paths. You must provide a path with a backslash separator. In C/C++ a backslash character must be escaped and the escape character is a backslash so the result is two per: "\\". It is also good to use the drive letter which is D: in the case of your applications working directory. Using D: ensures that your application can be executed from any installation location. So try the following snippet:

CODE
   //Loading Bitmap
#ifdef _XBOX
    Padel = load_image("D:\\sprite_one.bmp");
#else
    Padel = load_image("image/sprite_one.bmp");
#endif


In a large cross-platform application it is good to use preprocessor directives to define a global const that can be used where needed so that you don't need preprocessor directives all over the code.

CODE
#if (defined _WIN32 || defined _XBOX)
    #define PATHSEP     "\\"
    #define PATHSEPCHAR '\\'
#else
    #define PATHSEP     "/"
    #define PATHSEPCHAR '/'
#endif

Edited by Hyper_Eye, 04 September 2011 - 08:35 PM.


#3 richi902

richi902

    X-S Enthusiast

  • Members
  • 6 posts

Posted 04 September 2011 - 08:53 PM

thank you man, it worked!! biggrin.gif

i was trying countless different things lol

so i can now focus on making a little basic game and then port it over to the xbox.




oh and btw, great work with the odamex port, finaly a good xbox doom port.



#4 Hyper_Eye

Hyper_Eye

    X-S Expert

  • Members
  • PipPipPip
  • 594 posts
  • Location:Huntsvegas, AL.
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 04 September 2011 - 10:36 PM

I'm glad that solved your issue. Good luck with your project!

#5 richi902

richi902

    X-S Enthusiast

  • Members
  • 6 posts

Posted 04 September 2011 - 11:31 PM

oh and do you perhaps know how to disable that "xbox_sdl error X1001: Could not connect to Xbox ''
since i dont have a debug-kit/dev-kit xbox and its kinds irritating.


#6 Hyper_Eye

Hyper_Eye

    X-S Expert

  • Members
  • PipPipPip
  • 594 posts
  • Location:Huntsvegas, AL.
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 05 September 2011 - 02:27 AM

1) Open your project
2) Select Project->Properties
3) Select Xbox Deployment
4) Change "Exclude From Build" to Yes.

You should consider getting a debug kit or installing a debug bios and xdk dash on your Xbox. It is really easy to do if you use a modchip but not hard to do with a softmod either. It makes a very big difference. When you are chasing down a bug it is invaluable.

#7 hcf

hcf

    X-S Senior Member

  • Members
  • PipPip
  • 200 posts

Posted 05 September 2011 - 10:15 AM

QUOTE(richi902 @ Sep 5 2011, 12:31 AM) View Post

oh and do you perhaps know how to disable that "xbox_sdl error X1001: Could not connect to Xbox ''
since i dont have a debug-kit/dev-kit xbox and its kinds irritating.

Richy, you can ignore that error message. The XBE executable file is generated anyways smile.gif

#8 Hyper_Eye

Hyper_Eye

    X-S Expert

  • Members
  • PipPipPip
  • 594 posts
  • Location:Huntsvegas, AL.
  • Xbox Version:v1.0
  • 360 version:v1 (xenon)

Posted 05 September 2011 - 06:21 PM

He is aware of that. He just wants to skip that step because it holds up the build process. If you don't have a machine to deploy to that step takes a little bit before it fails. The instructions I provided allow you to disable deployment and avoid the issue. It makes building without a deployment target much faster.

#9 richi902

richi902

    X-S Enthusiast

  • Members
  • 6 posts

Posted 27 September 2011 - 03:26 AM

i installed a debug bios now anyway, i used that x2 bios so i can still keep my other dashboard.
it is much better to just press the button and it copys the new file over tongue.gif.
now i just need to learn more c(++) :/ gets too confusing sometimes, and i have a hard time understanding,
especially classes, functions and arrays(and probably some other stuff), well just the hole c++ lol.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users