Welcome, Guest. Please login or register.
Login with username, password and session length

 
Advanced search
49749 Posts in 5835 Topics- by 2075 Members - Latest Member: Steamforge
 
Pages: [1] 2 3 ... 5
Print
Author Topic: Pascal and XNA...    (Read 13566 times)
savage
Administrator
Zettabyte Zealot
*****
Posts: 2444


38535054 savagesoftware@hotmail.com
View Profile WWW
« on: January 23, 2007, 07:44:33 AM »

I was just discussing with cairnswm about creating stuff with Pascal and XNA. Since Chrome 1.5 supports .NET 2.0 I thought I would quickly try and get a Hello world progam workin. This is the result...



0. Install .NET 2.0 and XNA Game Studio Express

1. Download the Free Chrome 1.5 command line compiler and install it

2. Create a file named XNADemo.pas and copy code as follows...

Code:

namespace XNADemo;

interface

uses
  Microsoft.Xna.Framework,
  Microsoft.Xna.Framework.Content,
  Microsoft.Xna.Framework.Audio,
  Microsoft.Xna.Framework.Graphics,
  Microsoft.Xna.Framework.Input,
  Microsoft.Xna.Framework.Storage;

type
  TXNAGame = class(Microsoft.Xna.Framework.Game)
  private
    // these are the size of the output window, ignored on Xbox 360
    preferredWindowWidth  : integer;
    preferredWindowHeight : integer;

    graphics : GraphicsDeviceManager;

    class content : ContentManager;
  protected
    method Initialize; override;
    method BeginRun; override;
    method Update( gameTime : Gametime ); override;
    method BeginDraw : boolean; override;
    method Draw( gameTime : Gametime ); override;
    method EndDraw; override;
    method LoadGraphicsContent( loadAllContent : boolean ); override;
    method UnloadGraphicsContent( unloadAllContent : boolean ); override;
  public
    constructor;

    // Entry point into this object.
    class method Main;
  end;

implementation

constructor TXNAGame;
begin
  inherited;
  preferredWindowWidth := 320;//1280;
  preferredWindowHeight := 240;//720;
 
  Self.graphics := new Microsoft.Xna.Framework.GraphicsDeviceManager(Self);
  Self.graphics.PreferredBackBufferWidth := preferredWindowWidth;
  Self.graphics.PreferredBackBufferHeight := preferredWindowHeight;
end;

class method TXNAGame.Main;
begin
  try
    // probably should not be instantiating an object within itself :).
    with lGame := new TXNAGame do
      lGame.Run;
  except
    on E: Exception do
    begin
      // MessageBox.Show(E.Message);
    end;
  end;
end;

method TXNAGame.Initialize;
begin
  // Your Initialize Code here
  Window.Title := 'Pascal and XNA';
 
  inherited;
end;

method TXNAGame.BeginRun;
begin
  // Your BeginRun Code here
  inherited;
end;

method TXNAGame.Update( gameTime : Gametime );
begin
  // Allows the default game to exit on Xbox 360 and Windows
  if (GamePad.GetState(PlayerIndex.One).Buttons.Back = ButtonState.Pressed) then
     Self.Exit();

  // Your Update Code here

  inherited Update( gameTime );
end;

method TXNAGame.BeginDraw : boolean;
begin
  if not ( inherited BeginDraw ) then
  begin
    result := false;
    exit;
  end;

  // Your BeginDraw Code here

  result := true;
end;

method TXNAGame.Draw( gameTime : Gametime );
begin
  graphics.GraphicsDevice.Clear( Color.CornflowerBlue );

  inherited Draw( gameTime );

  // Your Draw Code here

end;

method TXNAGame.EndDraw;
begin
  // Your EndDraw Code here

  inherited;
end;

method TXNAGame.LoadGraphicsContent( loadAllContent : boolean );
begin
  if (loadAllContent) then
  begin
    // TODO: Load any ResourceManagementMode.Automatic content
  end;

  // TODO: Load any ResourceManagementMode.Manual content
 
end;

method TXNAGame.UnloadGraphicsContent( unloadAllContent : boolean );
begin
  if (unloadAllContent) then
  begin
    content.Unload;
  end;
end;

end.


3. At the command line type
Code:

Chrome XNADemo.pas /frameworkversion:v2.0.50727 /ref:"C:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\References\Windows\x86\Microsoft.Xna.Framework.dll" /ref:"C:\Program Files\Microsoft XNA\XNA Game Studio Express\v1.0\References\Windows\x86\Microsoft.Xna.Framework.Game.dll"


If all goes well you should have an XNADemo.exe file ready to run. This will display a blank screen with the Window title "Pascal and XNA"!

Remember this is Chrome Object Pascal, which is slightly different to CodeGear Object Pascal
Logged



There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
-= Paulo Coelho =-
tanffn
Byte Master
**
Posts: 336


50837450
View Profile
« Reply #1 on: January 23, 2007, 07:50:01 AM »

An impressive black window  :wink:
Logged

BEGIN GEEK CODE BLOCK
d s-- : a24 GB GCS GTW GE C++ P L+ W++ N+ K- w++++ M- PS+ PE+ Y- t+ 5+++ X+ R*
tv b+ DI++ D+ e++ h+ G-
END GEEK CODE BLOCK

Create your own GeekCode block at: ...
savage
Administrator
Zettabyte Zealot
*****
Posts: 2444


38535054 savagesoftware@hotmail.com
View Profile WWW
« Reply #2 on: January 23, 2007, 07:58:57 AM »

Quote from: "tanffn"
An impressive black window  :wink:


I've been told I create the best black windows in the business.
Logged



There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
-= Paulo Coelho =-
Traveler
Administrator
Petabyte Protector
*****
Posts: 1804



View Profile WWW
« Reply #3 on: January 23, 2007, 08:03:41 AM »

Perhaps a silly question but does this mean we can develop for Xbox 360?
Logged
Luuk van Venrooij
Octal Champion
**
Posts: 143


View Profile
« Reply #4 on: January 23, 2007, 08:14:14 AM »

.net 2.0 executables should be able to run on the XBOX 360. THis is a pretty sweet find savage Smiley.
Logged
savage
Administrator
Zettabyte Zealot
*****
Posts: 2444


38535054 savagesoftware@hotmail.com
View Profile WWW
« Reply #5 on: January 23, 2007, 08:38:07 AM »

Quote from: "Traveler"
Perhaps a silly question but does this mean we can develop for Xbox 360?


In theory, that is the case.

Taken from a google link...
Quote

The cash cow is XNA Creators Club, an Xbox Live-hosted service that Microsoft hopes budding developers will turn to for help, white papers, game assets offered not only by Microsoft but also by third-parties, forums and the like. More to the point, coders won't be able to deliver games to Xbox 360 owners without coughing up to Microsoft.

In addition to the $99 annual subscription, purchased through Xbox Live Marketplace, Microsoft is also offering a $49 four-month sub. Membership will allow developers to offer finished games through Xbox Live Arcade.

Downloaders will require a console fitted with a hard drive and likewise be an XNA Creators Club member, Microsoft's XNA FAQ reveals. That's because creators don't share the game but the assets and source code, which the recipient must then compile into an Xbox 360-friendly format. Xbox 360 games must be offered on non-commercial terms, Microsoft added, though XNA can be used to develop commercial titles for Windows.

"Games developed using XNA Game Studio Express cannot be shared through a memory card or CD/DVD at this time," the software giant warned.


Someone would need to investigate this further. I would if I had an XB360 but I don't and only plan on getting a PS3 when that is released in the UK.
Logged



There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
-= Paulo Coelho =-
jdarling
Megabyte Mage
***
Posts: 1104



View Profile WWW
« Reply #6 on: January 23, 2007, 09:19:45 AM »

http://blogs.msdn.com/coding4fun/archive/2007/01/18/1491742.aspx

I'll also ask around and see what I can find out about doing this outside of VisualStudios.  The link above at least explains how to do it within VisualStudios (witch can be used with Chrome).
Logged

- Jeremy


http://www.eonclash.com/
"It aint much yet, but its what I got!"
cairnswm
PGD Staff
Gigabyte Gladiator
****
Posts: 1372


william@cairnsgames.co.za
View Profile WWW Email
« Reply #7 on: January 23, 2007, 10:04:00 AM »

If I can get a Pascal Program running on an XBox360 I might actually buy one!

I've already converted my S2DL framework over to C# and XNA Game Studio Express. If I can use Pascal instead I will also convert to Chrome and XNA.

I use ConTEXT as my editor of choice for command line compilers - I will try set it up tonight to compile and run the program with F9. If I can I pretty much have enough to start writing XBox games Smiley

Well done Savage!
Logged

---------------------------
William Cairns              
My Games: http://www.cairnsgames.co.za          
My Blog: http://TheGameDeveloper.co.za
savage
Administrator
Zettabyte Zealot
*****
Posts: 2444


38535054 savagesoftware@hotmail.com
View Profile WWW
« Reply #8 on: January 23, 2007, 10:09:08 AM »

using /ref: switch in Chrome you should be able to link to the XBox versions of the Xna.* Assemblies which are installed when XNA Game Studio Express is installed. So I think it should theoretically be possible to use Chrome to create an XB360 exe.

There are some tutorial videos that show how to load 3D objects etc over @ http://blogs.msdn.com/xna/archive/2006/12/13/xna-game-studio-express-video-tutorials-available.aspx
but you should be able to keep up to date by checking
http://blogs.msdn.com/xna/
regularly
Logged



There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
-= Paulo Coelho =-
WILL
PGD Co-Founder
Administrator
Yottabyte HighLord
*****
Posts: 3961



View Profile WWW
« Reply #9 on: January 23, 2007, 11:37:03 AM »

Am I going to have to put XBox360 in the description for the 'Console Development' forum? Smiley
Logged

NecroDOME
Megabyte Mage
***
Posts: 1033



View Profile WWW
« Reply #10 on: January 23, 2007, 02:16:46 PM »

(Very offtopic:)
@savage - Oh great master of black windows! Could you make a yellow window for me?
Logged


NecroSOFT
 - End of line -
cairnswm
PGD Staff
Gigabyte Gladiator
****
Posts: 1372


william@cairnsgames.co.za
View Profile WWW Email
« Reply #11 on: January 23, 2007, 03:21:26 PM »

Actually I dont think the screen was being cleared at all - I had a black screen with some very retro looking blocks all over it Smiley

Change the GraphicsDevice.Clear statement to
Code:
 graphics.GraphicsDevice.Clear( Color.CornflowerBlue );

and you'll have the correct CornFlower blue of the empty XNA GSE base project.

Smiley
Logged

---------------------------
William Cairns              
My Games: http://www.cairnsgames.co.za          
My Blog: http://TheGameDeveloper.co.za
savage
Administrator
Zettabyte Zealot
*****
Posts: 2444


38535054 savagesoftware@hotmail.com
View Profile WWW
« Reply #12 on: January 23, 2007, 04:39:10 PM »

Quote from: "cairnswm"
Actually I dont think the screen was being cleared at all - I had a black screen with some very retro looking blocks all over it Smiley

Change the GraphicsDevice.Clear statement to
Code:
 graphics.GraphicsDevice.Clear( Color.CornflowerBlue );

and you'll have the correct CornFlower blue of the empty XNA GSE base project.

Smiley


I've changed the above base code as mentioned, though it would be nice to know why the other Clear code does not work.
Logged



There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
-= Paulo Coelho =-
savage
Administrator
Zettabyte Zealot
*****
Posts: 2444


38535054 savagesoftware@hotmail.com
View Profile WWW
« Reply #13 on: January 23, 2007, 04:40:04 PM »

Quote from: "NecroDOME"
(Very offtopic:)
@savage - Oh great master of black windows! Could you make a yellow window for me?


I'm sorry NecroDOME I only specialise in black windows. Yellow windows are just so 80s.
Logged



There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
-= Paulo Coelho =-
savage
Administrator
Zettabyte Zealot
*****
Posts: 2444


38535054 savagesoftware@hotmail.com
View Profile WWW
« Reply #14 on: January 29, 2007, 04:44:06 AM »

OK I finally worked out what I was doing wrong with the 3D stuff. Basically XNA expects XNA specific compatible 3D resources and audio file to load correctly. Once that was established it works like a charm ( as seen below )




This rotating 3D model is very, and I mean very, easy to get working.

I've spoken to the people at RemObjects and they are keen to have these demos, and a few more, showing off Chrome's XNA and .NET 2.0 compatibility. They would like a game project template for XNA and they are speaking to Microsoft about what is required to get these Chrome created Exes working on an XBox 360.
Logged



There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.
-= Paulo Coelho =-
Pages: [1] 2 3 ... 5
Print
Jump to: