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

     
 

OpenXDK

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

 

HelloWorld - Text Output

 

We can use some of the built in text output library's to display text output.  We can display a lot of useful information with text output - one such piece of information we can display is the frames per second so we know how well our code is performing.

 

Download Project Code - TextOutput

 

// Basic text output

 

#include <openxdk.h>

#include <stdio.h>

#include <stdlib.h>

 

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

 

      float last = (float)KeTickCount;

    int   fps  = 0;

 

      int   testcount = 0;

      while(1)

      {

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

            // Comment this line out to watch the frame rate go up...on my xbox

            // I comment this out, and my frame rate is nearly 1000fps!...wow!

            // but of course you can notice the flicker :-/

            vga_vsync();                                    // Wait for Vertical Blank

        vga_flip();                                         // Flip

            vga_clear();                                    // Clear screen

           

 

            fps  = (int)(1.0f/(((float)KeTickCount - last) / 1000.0f));

        last = (float)KeTickCount;

       

            // Print to screen

            char buffer[300]; // large temp text buffer

          sprintf(buffer,"OpenXDK Sample: %d fps", fps);

            vga_print(50, 50, buffer);

 

            sprintf(buffer, "Dynamic Counter Value: %d", testcount++);

            vga_print(50, 75, buffer);

 

 

      }// End while loop

}//End

 

 

 

On we go....

 
 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.