www.xbdev.net xbdev - software development
Friday December 14, 2018
home | about | contact | Donations

     
 

OpenXDK

The Free, Legal, Open Source XBox Development Kit...

 

Display TGA Bitmap - Cool image on the screen.

 

If you put an image on the screen ..its looks cool.  We can use some of the pre built openxdk library functions to load in a tga image and render it to the full screen.

Plleaaasseee, if you run the demo code, not to forget to put the 'image.tga' with your xbe :)...or else the code will crash :)   This code is a modified version of the code from on of the openxdk samples.

 

Project Source Code - Display TGA
 

// WARNING!!!

// Now don't forget to put the 'image.tga' with your xbe :)

 

#include <openxdk.h>

 

#include <xgfx2d/bitmap.h>                  // Bitmap*, create_bitmap(..) etc

#include <xgfx2d/blit.h>                    // blit(..)

#include <xgfx2d/blitters.h>                // normal_blit

 

// Program Entry Point

void XBoxStartup()

{

      //let's init the screen

      vga_init_mode(MODE_640x480x32);         // Some possible modes all defined in

                                              // xvga.h

                                              // MODE_320x240x32

                                              // MODE_640x240x32

                                              // MODE_640x480x32 etc...plus many more

      Bitmap      *screen;

      Bitmap      *image;

 

      //let's load the test image (one of the opexdk demo images)

      image = load_tga("D:\\image.tga");

 

      while(1)

      {

            // A list of all these functions can be found at the top of xvga.h

            vga_vsync();                                    // Wait for Vertical Blank

        vga_flip();                                         // Flip

            // You can comment this line our really as where totally overwritting

            // the full screen - but I left it in anyhow, as you woudl usually clear

            vga_clear();                                    // Clear screen

           

            //so where's the screen? who knows if we're page flipping?

            screen = get_screen_bitmap();

 

            // blit method definition:

            // void blit(Bitmap *dest, Bitmap *src, int dx, int dy, int sx,

            // int sy, int sw, int sh, void (*blitter)(uint32*,uint32*,int,int), int parameter)

 

            blit( screen,                       // destination

                    image,                        // source

                    0, 0,                         // destination x,y (top left)

                    0, 0,                         // source x,y (top left)

                    640, 480,                     // width and height (source)

                    normal_blit, 0);              // blit method, options (ignored)

 

      }// End while loop

}//End

 

 

 

 

 

 

 
 Visitor: 9534626  { 209.237.238.175 } Copyright (c) 2002-2017 xbdev.net - All rights reserved.
Designated tutorial and software are the property of their respective owners.