xbox-scene.com - your xbox news information source
Quick Links: Main Forums | Xbox360 Forums | Xbox1 Forums | PS3 Forums
Xbox-Scene Forum Help  Search Xbox-Scene Forums   Xbox-Scene Forum Members   Xbox-Scene Calendar

Giganews Usenet Offers: +1150 days binary retention, 99%+ Completion, and Unlimited Speed/Access!

360 ODD Emulators: X360 Key $99 | Wasabi360 FAT $99 | Wasabi360 Slim $99
C4E's iXtreme Burner MAX Drive: LiteOn iHAS124 DROPPED TO JUST $17


Welcome Guest ( Log In | Register )

 Forum Rules Rules
 
Reply to this topicStart new topic
> Sdlx And The Xdk
richi902
post Sep 4 2011, 07:41 PM
Post #1


X-S Enthusiast


Group: Members
Posts: 6
Joined: 4-September 11
Member No.: 456934



hi,

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

http://lazyfoo.net/SDL_tutorials/lesson01/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

This post has been edited by richi902: Sep 4 2011, 07:44 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Hyper_Eye
post Sep 4 2011, 08:33 PM
Post #2


X-S Expert
***

Group: Members
Posts: 592
Joined: 26-December 03
From: Huntsvegas, AL.
Member No.: 85607
Xbox Version: v1.0
360 version: v1 (xenon)



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


This post has been edited by Hyper_Eye: Sep 4 2011, 08:35 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
richi902
post Sep 4 2011, 08:53 PM
Post #3


X-S Enthusiast


Group: Members
Posts: 6
Joined: 4-September 11
Member No.: 456934



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.

User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Hyper_Eye
post Sep 4 2011, 10:36 PM
Post #4


X-S Expert
***

Group: Members
Posts: 592
Joined: 26-December 03
From: Huntsvegas, AL.
Member No.: 85607
Xbox Version: v1.0
360 version: v1 (xenon)



I'm glad that solved your issue. Good luck with your project!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
richi902
post Sep 4 2011, 11:31 PM
Post #5


X-S Enthusiast


Group: Members
Posts: 6
Joined: 4-September 11
Member No.: 456934



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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Hyper_Eye
post Sep 5 2011, 02:27 AM
Post #6


X-S Expert
***

Group: Members
Posts: 592
Joined: 26-December 03
From: Huntsvegas, AL.
Member No.: 85607
Xbox Version: v1.0
360 version: v1 (xenon)



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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
hcf
post Sep 5 2011, 10:15 AM
Post #7


X-S Senior Member
**

Group: Members
Posts: 194
Joined: 29-October 08
Member No.: 393866



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

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
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Hyper_Eye
post Sep 5 2011, 06:21 PM
Post #8


X-S Expert
***

Group: Members
Posts: 592
Joined: 26-December 03
From: Huntsvegas, AL.
Member No.: 85607
Xbox Version: v1.0
360 version: v1 (xenon)



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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
richi902
post Sep 27 2011, 03:26 AM
Post #9


X-S Enthusiast


Group: Members
Posts: 6
Joined: 4-September 11
Member No.: 456934



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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post





Reply to this topicStart new topic

 

Lo-Fi Version Time is now: 24th May 2013 - 02:08 PM