Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: JGE++ : A hardware accelerated 2D game engine for PSP/Windows

                  
   
  1. #1

    Default JGE++ : A hardware accelerated 2D game engine for PSP/Windows

    Introduction

    JGE++ (Jas Game Engine++) is a hardware accelerated 2D game engine for PSP (using GU) and Windows. It's inspired by the popular game engine HGE on MS Windows. In fact the Windows' counterpart is basically a wrapper of HGE.

    For more information about HGE, please visit its web site at:

    http://hge.relishgames.com.

    With JGE++, you can build a project as a Windows executable or a PSP EBOOT image with the same source code without any modification. This means the game development process, including coding, debugging and testing, can be done mainly in Windows. However, since JGE++ is still under development and not heavily tested, it is recommended that the PSP EBOOT image should be built and put onto a PSP for testing from time to time just to make sure everything is working properly.

    Of course you may also put in platform specific codes with #if/#else/#endif.

    SkyAnimator is introduced with JGE++ v0.2b. It is a visual tool written by
    HuangYZ for creating sprite animations. HuangYZ has ported the runtime library to JGE++ and this gives JGE++ a very powerful animation system to play with.

    Contents of the JGE++ package

    - JGE++ v0.2b (source + lib)
    - SkyAnimator lib
    - JGE++ demo (source + assets)
    - SkyAnimator demo (source + assets)
    - StarBugz (source + assets)
    - Mario Demo (source + assets)


    Prerequisites

    libpng
    libz
    mikmodlib


    Directory Structure

    Code:
    ____JGE
    |    |___HGE (Windows backend)
    |    |___include (JGE++ header files)
    |    |___lib
    |    |    |___psp (lib files for PSP)
    |    |    |    |
    |    |    |    |___libjgesky.a (SkyAnimator lib)
    |    |    |    |___libjge.a (JGE++ lib)
    |    |    |
    |    |    |___win (lib files for Windows)
    |    |         |
    |    |         |___JgeSky60.lib (SkyAnimator lib for VC6.0)
    |    |         |___JgeSky71.lib (SkyAnimator lib for VC2003)
    |    |         |___jge.lib (JGE++ lib Release version)
    |    |         |___jge_debug.lib (JGE++ lib debug version)
    |    |
    |    |___src (JGE++ source files)
    |
    |___Demo
    |    |___bin
    |    |___Debug
    |    |___JGEFramework
    |    |___Release
    |    |___src
    |        |___GameApp.cpp
    |        |___GameApp.h
    |            
    |___Mario (same structure as Demo)
    |
    |___SkyDemo (same structure as Demo)
    |
    |___StarBugz (same structure as Demo)

    To build the JGE++ lib for Windows

    Open "JGE.dsw" in JGE directory with Visual Studio 6.0. With the BATCH BUILD option, select "REBUILD ALL".


    To build the JGE++ lib for PSP

    Change to JGE directory, then

    make clean
    make install

    or just run the batch file "mk.bat"


    To build a project for Windows

    Open "xxx.dsw" in the project directory with Visual Studio 6.0 and build for either "Release" or "Debug".


    To build a project for PSP

    Change to the project directory, then

    make clean
    make

    or just run the batch file "mk.bat"


    To run on Windows

    You need DirectX 8.0+ installed.

    Key mapping:

    Code:
    PSP                     WINDOWS
    ------------------      -------------
    UP/DOWN/LEFT/RIGHT      W/S/A/D
    ANALOG CONTROL          UP/DOWN/LEFT/RIGHT
    TRIANGLE                8 on NumPad (with NUMLOCK)
    SQUARE                  4 on NumPad (with NUMLOCK)
    CIRCLE                  6 on NumPad (with NUMLOCK)
    CROSS                   2 on NumPad (with NUMLOCK)
    SELECT                  CTRL
    START                   ENTER
    HOME                    F1
    HOLD                    F2
    NOTE                    F3
    L                       Q
    R                       E

    To run on PSP

    With firmware 1.50 PSP, use KXploit Tool to transfer the proper EBOOT.PBP
    onto your memory stick. Then you need to copy the entire folder "Res" into
    the appropriate folder.


    License

    SkyAnimator(libjgesky/JgeSky60.lib/JgeSky71.lib) is free software. You can use it anyway you like at your own risk. Copyright (C) 2006 HuangYZ.

    JGE++/JGE++ Demo/SkyAnimator Demo/StarBugz/Mario Demo are released under GPL and below is the license agreement:

    "This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"


    Special thanks to

    - PSPSDK team
    - devkitPSP team
    - friends at pspchina.net
    - Jasmine (James' lovely wife )


    Credits

    JGE++:
    Programmer - James Hui (a.k.a. Dr.Watson)

    SkyAnimator and SkyAnimator Demo:
    Programmer - HuangYZ

    JGE++ Demo:
    Programmer - James Hui
    Artist - Zhen (TMD Games)

    StarBugz:
    Programmer - James Hui
    Artist - Fung Lap Tong

    Mario Demo:
    Programmer - James Hui
    Artist - Zhen (TMD Games)


    Screenshots

    SkyAnimator:


    SkyAnimator Demo:


    JGE++ Demo:


    StarBugz:


    Mario Demo:



    Downloads
    JGE++ v0.2b
    SkyAnimator v1.6b R2 (English version)
    SkyAnimator v1.6b R2 (Chinese version)

    Prebuilt binaries:

    JGE++ Demo for PSP firmware 1.50
    JGE++ Demo for Windows
    SkyAnimator Demo for PSP firmware 1.50
    SkyAnimator Demo for Windows
    Mario Demo for PSP firmware 1.50
    Mario Demo for Windows
    StarBugz Prototype for PSP firmware 1.50
    StarBugz Prototype for Windows



    Known issues
    - Wav files must be 8 bit mono.
    - There is an extra "." in front of hge.lib in VC6 project settings of Demo's Debug build for Windows. Please remove it in order to build.

  2. #2

    Default An introduction to rendering 2D images with GU

    An introduction to rendering 2D images with GU

    JGE++ uses the GU functions for rendering and this is an introduction on how the 2D rendering is done with this 3D library.

    PSP has 2MB video RAM. Apart from using as frame buffers, user textures can also be stored here for faster GPU process. The pixel format that is chosen for the game will have a big impact on how many textures can be stored in the video RAM.

    There are four different pixel formats available on PSP:

    PSP_DISPLAY_PIXEL_FORMAT_565 //16-bit RGB 5:6:5
    PSP_DISPLAY_PIXEL_FORMAT_5551 //16-bit RGBA 5:5:5:1
    PSP_DISPLAY_PIXEL_FORMAT_4444 //16-bit RGBA 4:4:4:4
    PSP_DISPLAY_PIXEL_FORMAT_8888 //32-bit RGBA 8:8:8:8

    Since transparent colour is pretty much needed for all game applications, the 565 format is basically out. The 5551 and 4444 format both take 2 bytes for a single pixel. If effects such as alpha blending is required, then the 4444 format will be the choice to use.

    Of course, the optimal option will be the 8888 format, which produce the maximum number of colours on screen. However this format uses 4 bytes for each pixel. A primary frame buffer plus a back buffer will take up 512x272x4x2 = 1,088KB. There will be only 960KB left for user textures. In that case, most of the textures will need to be stored in system RAM and thus will slow down all the rendering.

    Here is the code segment on GU intialization:


    sceGuInit();

    sceGuStart(GU_DIRECT,list);
    mVideoBufferStart = 0;

    // setup frame buffer for rendering
    sceGuDrawBuffer(BUFFER_FORMAT, (void *)mVideoBufferStart, FRAME_BUFFER_WIDTH);
    mVideoBufferStart += FRAME_BUFFER_SIZE;

    // setup frame buffer for displaying
    sceGuDispBuffer(SCREEN_WIDTH, SCREEN_HEIGHT, (void *)mVideoBufferStart, FRAME_BUFFER_WIDTH);

    // setup starting address of video RAM for user textures
    mVideoBufferStart += FRAME_BUFFER_SIZE;
    mCurrentPointer = mVideoBufferStart;

    sceGuOffset(2048 - (SCREEN_WIDTH/2), 2048 - (SCREEN_HEIGHT/2));
    sceGuViewport(2048, 2048, SCREEN_WIDTH, SCREEN_HEIGHT);

    sceGuScissor(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    sceGuEnable(GU_SCISSOR_TEST);
    sceGuFrontFace(GU_CW);
    sceGuEnable(GU_TEXTURE_2D);
    sceGuShadeModel(GU_SMOOTH);

    // enable alpha blending
    sceGuEnable(GU_BLEND);
    sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);

    sceGuClear(GU_COLOR_BUFFER_BIT);
    sceGuFinish();
    sceGuSync(0,0);

    sceDisplayWaitVblankStart();
    sceGuDisplay(1);
    To render a 2D image onto screen, a texture containing such image is loaded and a quad structure is defined to specify the area of the texture to render. Basically 2D images rendering with GU is done by rendering textured quads.

    A quad consists of four vertices. The order of the vertices is shown below:

    Code:
    v0---v1
     |  /|
     | / |
     |/  |
    v2---v3
    Here is the structure of Vertex:

    Code:
    struct Vertex
    {
           float u, v;
           PIXEL_TYPE color;
           float x, y, z;
    };
    (x,y) is the screen coordinates and (u,v) is the texture coordinates.

    As an example, the first frame of the following animation will be shown at screen location (100,100). The size of each frame is 100x100:



    Here is the settings of the four vertices:

    Code:
    vertices[0].u = 0.0f; 
    vertices[0].v = 0.0f;
    vertices[0].color = color;
    vertices[0].x = 100.0f; 
    vertices[0].y = 100.0f; 
    vertices[0].z = 0.0f;
    
    vertices[1].u = 100.0f; 
    vertices[1].v = 0.0f;
    vertices[1].color = color;
    vertices[1].x = 200.0f; 
    vertices[1].y = 100.0f; 
    vertices[1].z = 0.0f;
    
    vertices[2].u = 0.0f; 
    vertices[2].v = 100.0f;
    vertices[2].color = color;
    vertices[2].x = 100.0f; 
    vertices[2].y = 200.0f; 
    vertices[2].z = 0.0f;
    
    vertices[3].u = 100.0f 
    vertices[3].v = 100.0f;
    vertices[3].color = color;
    vertices[3].x = 200.0f; 
    vertices[3].y = 200.0f; 
    vertices[3].z = 0.0f;
    After setting up the vertices, GU function sceGuDrawArray will be used to render the quad:

    Code:
    sceGuDrawArray(GU_TRIANGLE_STRIP,GU_TEXTURE_32BITF|TEXTURE_COLOR_FORMAT|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 4, 0, vertices);
    Parameters of sceGuDrawArray:

    GU_TRIANGLE_STRIP
    - rendering triangles

    GU_TEXTURE_32BITF|TEXTURE_COLOR_FORMAT|GU_VERTEX_3 2BITF|GU_TRANSFORM_2D:
    - vertex structure is texture coordinates(floats), followed by colour, followed by screen coordinates(floats) with 2D transform.

    4
    - 4 vertices.

    0
    - starting index of vertices

    vertices
    - vertices

  3. #3

    Default Hello World for JGE++

    Hello World for JGE++

    The JGE++ package comes with a demo application called Demo. This is basically a Hello World program for JGE++.

    When programming 2D games, in order to show an image on screen, the image is loaded and then a "DrawImage" function is used to do the job. Sometimes a few images are packed into a single one and portions of it are used for rendering in order to save file space, for easy management or for whatever reasons.

    With hardware accelerated 2D game engines, this "packed" image approach has become a necessary because the width/height of the texture that is fed to the graphics hardware need to be in the power of 2. And also, switching from one texture to another may take some extra GPU cycles. Obviously the best way to do is to have a relative large texture, say 512x512, and putting all images in it and render portions of it for different sprites. In practice of course it is not required to have just one single texture for a whole game. But keeping the number of textures to a minimal is a good habit anyway!

    Here is a sample texture (128x128) with a cartoon character and the text "HELLO WORLD":



    A quad structure is used to specify which area of the large texture is to be rendered. Here is an example on how to load a texture and render an image to screen in JGE++:

    Code:
    // load texture
    mTexture = mEngine->LoadTexture("Res/mario.png", true);	
    // setup quad structure
    mMario = new JQuad(mTexture, 0.0f, 0.0f, 62.0f, 72.0f);
    // set center of quad
    mMario->SetHotSpot(31.0f, 36.0f);
    
    .
    .
    .
    // render to screen
    mEngine->RenderQuad(mMario, 80.0f, 80.0f);
    It may seem tedious to concatenate images together and define quads just to render a few images on screen, but the good thing about using hardware accelerated functions is that apart from plain rendering, it is possible to do scaling, rotation and alpha/colour blending at the same time and cost nothing to the main CPU. All these mean fast speed, hence, the term hardware accleration!

    Here are some examples of how to do scaling, rotation and colour blending:

    Code:
    // render with rotation
    mEngine->RenderQuad(mMario, 80.0f, 200.0f, mAngle, 1.0f, 1.0f);
    
    // set blending colour
    mMario->SetColor(ARGB(128,255,255,0));
    // render with colour blending and scaling
    mEngine->RenderQuad(mMario, 380.0f, 150.0f, 0.0f, mScale, mScale);	
    mMario->SetColor(ARGB(255,255,255,255));
    Easy! Time to make some cool games!

  4. #4

    Default

    WOW very cool

  5. #5
    DCEmu Newbie
    Join Date
    Oct 2005
    Posts
    89
    Rep Power
    0

    Default

    Well this work with the GTA ELoader or is it for 1.5 only?

  6. #6
    DCEmu Newbie
    Join Date
    Nov 2005
    Posts
    1
    Rep Power
    0

    Default

    will definitly check this out after my exam, n1 work guys!

  7. #7
    DCEmu Rookie O-bake's Avatar
    Join Date
    Mar 2006
    Posts
    151
    Rep Power
    66

    Default

    That sounds unbelievable cool
    Much better than these pseudo-languages which require an interpreter, like LUA.

    But can i create my own libraries and include them?
    What kind of PSP-specific libraries are there yet and how good are they documented?

  8. #8

    Default

    So this "popular" library uses standard pspsdk functions to draw sprites etc. Where's the benefit of using it?
    I write enough code at work.

  9. #9

    Default

    SkyAnimator English version is available now. You can grab it from the original post.


    Quote Originally Posted by HeX
    Well this work with the GTA ELoader or is it for 1.5 only?
    According to http://www.fanjita.org, My first game, StarBugz(developed using JGE, source included in the package), works with the GTA ELoader and also the ELoader for 2.0 firmware, so I would say games written by using JGE++ have a very good chance to work on all PSP firmwares.

    Quote Originally Posted by O-bake
    can i create my own libraries and include them?
    Yes, for sure. JGE++ is open source under GPL license. You can do whatever you want to. But if you modified the engine code, you will need to share it with us as well There are 2 demos and 2 playable games (not complete games though ) with all the source code and assets for you to play with to get some good understanding of the engine.

    Quote Originally Posted by Nige
    So this "popular" library uses standard pspsdk functions to draw sprites etc. Where's the benefit of using it?
    Well... this is like saying "all Windows game engines use standard OpenGL/DirectX functions to draw spites etc. Where's the benefit of using it?" I would say using JGE++ is much easier than using just the standard PSPSDK libs and code everything all by yourself.

  10. #10

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •