Seite 299 von 340 ErsteErste ... 199 249 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 ... LetzteLetzte
Zeige Ergebnis 8.941 bis 8.970 von 10174

C/C++ Programming Help Thread

This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; stop using graphics.c...

  
  1. #8941
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    stop using graphics.c


    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  2. #8942
    QJ Gamer Blue
    Points: 5.672, Level: 48
    Level completed: 61%, Points required for next Level: 78
    Overall activity: 32,0%

    Registriert seit
    Dec 2007
    Ort
    Netherlands
    Beiträge
    148
    Points
    5.672
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    dont know i downloaded OSlib but didnt get it work its all new and i just wanted to make a simple game. no rotating or 3d or something.
    [SIZE="1"][color=#D1D1FF]______________________________________________________________[/color]
    [i]Last edited by basfreak; 01-01-1990 at [color=#666686]12:00 PM[/color][/i].[/SIZE]

  3. #8943
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    yea i understand, but i suggust trying to get oslib up and running over graphics.c
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  4. #8944
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    You're still passing 583.... change it.

    Or if you've changed the code, post the updated code.

    Check out my homebrew & C tutorials at http://insomniac.0x89.org/
    Coder formerly known as Insomniac197

    tshirtz: what is irshell ??
    Atarian_: it's where people who work for the IRS go when they die

  5. #8945
    QJ Gamer Green
    Points: 4.092, Level: 40
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Beiträge
    508
    Points
    4.092
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Raphael Beitrag anzeigen
    pspDebugScreenKprintf requires snprintf? You sure you have the right code? :) pspDebugScreenKprintf only uses prnt, which is a kernel function, so it *really should* work.
    Else you're open to use my previous macro that uses sprintf (not snprintf).
    Well, the keyboard's code uses snprintf, and decides it wants to overload if you change it to make it use sprintf. The rest of it works great, it's just the input. I might be able to find something on google.

    EDIT: Got a portable snprintf and modified it a little bit to make it work, and, it works...great.
    Geändert von NoEffex (08-20-2008 um 09:20 AM Uhr)

  6. #8946
    QJ Gamer Blue
    Points: 5.672, Level: 48
    Level completed: 61%, Points required for next Level: 78
    Overall activity: 32,0%

    Registriert seit
    Dec 2007
    Ort
    Netherlands
    Beiträge
    148
    Points
    5.672
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    changed to OSlib got this:
    Code:
    #include <oslib/oslib.h>
    
    PSP_MODULE_INFO("sample", 0, 1, 0);
    PSP_HEAP_SIZE_MAX();
    
    #define printf pspDebugScreenPrintf 
    #define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
    
    int ufoX = 0;
    int ufoY = 0;
    
    int main() {
        oslInit(0);
        oslInitGfx(OSL_PF_8888, 1);
    
        OSL_IMAGE *ufo = oslLoadImageFile("ufo.png", OSL_IN_RAM, OSL_PF_8888);
        
        oslStartDrawing();
        
        ufo->x = 50;
        ufo->y = 50;
        oslDrawImage(ufo);
        
        oslEndDrawing();
        oslSyncFrame();
        
        oslWaitKey();
        oslEndGfx();
        oslQuit();
        return 0;
    }
    Code:
    TARGET = sample
    OBJS = main.o
    
    CFLAGS = -O2 -G0 -Wall
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    BUILD_PRX = 1
    PSP_FW_VERSION = 371
    
    LIBDIR =
    LIBS = -losl -lpng -lz -lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm
     
    LDFLAGS =
    
    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = sample
    
    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak
    But it just crash after starting it?
    Geändert von basfreak (08-20-2008 um 10:00 AM Uhr)
    [SIZE="1"][color=#D1D1FF]______________________________________________________________[/color]
    [i]Last edited by basfreak; 01-01-1990 at [color=#666686]12:00 PM[/color][/i].[/SIZE]

  7. #8947
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    how big is the image?

    also why do u have these two lines:

    #define printf pspDebugScreenPrintf
    #define MAX(X, Y) ((X) > (Y) ? (X) : (Y))

    also defineing printf when it's already used in another library is a very VERY bad idea, i'd suggest just removing them from your program
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  8. #8948
    QJ Gamer Blue
    Points: 5.672, Level: 48
    Level completed: 61%, Points required for next Level: 78
    Overall activity: 32,0%

    Registriert seit
    Dec 2007
    Ort
    Netherlands
    Beiträge
    148
    Points
    5.672
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von slicer4ever Beitrag anzeigen
    how big is the image?

    also why do u have these two lines:

    #define printf pspDebugScreenPrintf
    #define MAX(X, Y) ((X) > (Y) ? (X) : (Y))

    also defineing printf when it's already used in another library is a very VERY bad idea, i'd suggest just removing them from your program
    Oh forgot to remove i just start writing the code without looking up.
    The ufo.png is 94x18.
    [SIZE="1"][color=#D1D1FF]______________________________________________________________[/color]
    [i]Last edited by basfreak; 01-01-1990 at [color=#666686]12:00 PM[/color][/i].[/SIZE]

  9. #8949
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    If it is crashing, then ufo is probably NULL. Check that it can find the image.

  10. #8950
    QJ Gamer Green
    Points: 4.092, Level: 40
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Beiträge
    508
    Points
    4.092
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    Sorry to distract from your oslib problem, but, I have a working debug keyboard in kernel mode, in case anyone else has my problem.

    http://tshiso.com/downloads/DebugKBFix/debugkbfix.zip

    Works like a charm.

  11. #8951
    QJ Gamer Blue
    Points: 2.426, Level: 29
    Level completed: 84%, Points required for next Level: 24
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Aug 2008
    Beiträge
    26
    Points
    2.426
    Level
    29
    Downloads
    0
    Uploads
    0

    Standard

    c++ question

    I'm using
    Code:
    unsigned int color = GU_COLOR( 1.0f, 1.0f, 1.0f, 1.0f );
    as a global variable and is at the heading of my main.cPP
    inside my main loop I try to change it with

    Code:
    color = GU_COLOR( 0.0f, 0.0f, 1.0f, 1.0f );
    and it will not change. I bet odds are this is an extreme noob question, but I did a quick search of guide and couldn't find anything

  12. #8952
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Global variables are evil.

    Post the whole file so we can see more.

  13. #8953
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    wat _dysfunctional said, their can be a million reason's why it won't, currently i'm thinking it's because you don't change the vertices's color
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  14. #8954
    QJ Gamer Blue
    Points: 2.426, Level: 29
    Level completed: 84%, Points required for next Level: 24
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Aug 2008
    Beiträge
    26
    Points
    2.426
    Level
    29
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    //**************************************************************************
    //		PSPGU Tutorial: 'Lesson6' - main.cpp
    //**************************************************************************
    
    #include "main.h"
    
    PSP_MODULE_INFO("Lesson6", 0, 1, 1);
    PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
    
    int fps = 0;			// for calculating the frames per second
    char *fpsDisplay;
    void *dList;			// display List, used by sceGUStart
    void *fbp0;				// frame buffer
    
    u32 tickResolution;
    u64 fpsTickNow;
    u64 fpsTickLast;
    
    bool exiting = false;
    bool light = false;		// Lighting ON/OFF (NEW)
    bool texFilter = false; // Texture Filter, NEAREST / LINEAR (NEW)
    bool texon = true;
    
    float xrot = 0.0f;		// X Rotation (NEW)
    float yrot = 0.0f;		// Y Rotation (NEW)
    float xspeed = 0.0f;	// X Speed (NEW)
    float yspeed = 0.0f;	// Y Speed (NEW)
    float z = -3.0f;        // Z Position (NEW)
    
    float dt;				// For time based animation
    
    unsigned int color = GU_COLOR( 0.0f, 0.0f, 1.0f, 1.0f );
    
    CTGATexture texture;
    
    Vertex __attribute__((aligned(16))) quad[3*12] = 
    {
    	{ 0, 1, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Top
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f, 1.0f },	// Bottom
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 0, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f,-1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f, 1.0f },	// Front
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 1, 0, color, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f,-1.0f },	// Back
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f,-1.0f },
    
    	{ 0, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Left
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },	// Right
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f }
    
    };
    
    Vertex __attribute__((aligned(16))) quad1[3*12] = 
    {
    	{ 0, 1, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Top
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f, 1.0f },	// Bottom
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 0, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f,-1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f, 1.0f },	// Front
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 1, 0, color, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f,-1.0f },	// Back
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f,-1.0f },
    
    	{ 0, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Left
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },	// Right
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f }
    
    };
    
    Vertex __attribute__((aligned(16))) quad2[3*12] = 
    {
    	{ 0, 1, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Top
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f, 1.0f },	// Bottom
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 0, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f,-1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f, 1.0f },	// Front
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 1, 0, color, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f,-1.0f },	// Back
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f,-1.0f },
    
    	{ 0, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Left
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },	// Right
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f }
    
    };
    
    Vertex __attribute__((aligned(16))) quad3[3*12] = 
    {
    	{ 0, 1, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Top
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f, 1.0f },	// Bottom
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 0, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f,-1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f, 1.0f },	// Front
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 1, 0, color, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f,-1.0f },	// Back
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f,-1.0f },
    
    	{ 0, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Left
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },	// Right
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f }
    
    };
    
    int main(int argc, char **argv)
    {
    	fbp0  = 0;
    	dList = malloc( 262144 );
    	fpsDisplay = "FPS: calculating";
    	
    
    	sceRtcGetCurrentTick( &fpsTickLast );
    	tickResolution = sceRtcGetTickResolution();
    
    	CTimer timer;
    	SceCtrlData pad, lastPad;						// Controller structure				
    	sceCtrlReadBufferPositive(&lastPad, 1);
    
    	SetupCallbacks();
    	pspDebugScreenInit();
    	sceKernelDcacheWritebackAll();
    
    	if( !texture.LoadTGA( "Data/Crate.tga" ) ) {
    		sceKernelExitGame();
    	}
    	texture.Swizzle();
    
    	InitGU();
    	SetupProjection();
    
    	while( !exiting )
    	{
    		sceCtrlPeekBufferPositive(&pad, 1);			
    		if( pad.Buttons != lastPad.Buttons ) {		
    			lastPad = pad;
    			
    			if( pad.Buttons & PSP_CTRL_CROSS ) {
    				light = !light;	
    			}
    			if( pad.Buttons & PSP_CTRL_SQUARE ) {
    				texFilter = !texFilter;
    			}
    			if( pad.Buttons & PSP_CTRL_CIRCLE ) {
    				texon = !texon;
    			}
    		}
    		if( pad.Buttons & PSP_CTRL_LTRIGGER ) {
    			z -= (1.0f * dt);
    		}
    		if( pad.Buttons & PSP_CTRL_RTRIGGER ) {
    			z += (1.0f * dt);
    		}
    		if( pad.Buttons & PSP_CTRL_UP ) {
    			xspeed -= 0.01f;
    		}
    		if( pad.Buttons & PSP_CTRL_DOWN ) {
    			xspeed += 0.01f;
    		}
    		if( pad.Buttons & PSP_CTRL_LEFT ) {
    			yspeed -= 0.01f;
    		}
    		if( pad.Buttons & PSP_CTRL_RIGHT ) {
    			yspeed += 0.01f;
    		}
    
    		dt = timer.GetDeltaTime( );
    		DrawScene();
    		FPS();
    
    		//sceDisplayWaitVblankStart();
    		fbp0 = sceGuSwapBuffers();
    
    	}
    
    	sceGuTerm();			// Terminating the Graphics System
    
    	// Free Memory
    	free( dList );
    	free( fpsDisplay );
    
    	sceKernelExitGame();	// Quits Application
    	return 0;
    }
    
    void FPS( void )
    {
    	fps++;
    	sceRtcGetCurrentTick( &fpsTickNow );
    	if( ((fpsTickNow - fpsTickLast)/((float)tickResolution)) >= 1.0f )
    	{
    		fpsTickLast = fpsTickNow;
    		sprintf( fpsDisplay, "FPS: %i", (int)fps );
    		fps = 0;
    	}
    	pspDebugScreenSetOffset( (int)fbp0 );
    	pspDebugScreenSetXY( 0, 0 );
    	pspDebugScreenPrintf( fpsDisplay );
    
    }
    
    void InitGU( void )
    {
    	// Init GU
    	sceGuInit();
    	sceGuStart( GU_DIRECT, dList );
    
    	// Set Buffers
    	sceGuDrawBuffer( GU_PSM_8888, fbp0, BUF_WIDTH );
    	sceGuDispBuffer( SCR_WIDTH, SCR_HEIGHT, (void*)0x88000, BUF_WIDTH);
    	sceGuDepthBuffer( (void*)0x110000, BUF_WIDTH);
    
    	sceGuOffset( 2048 - (SCR_WIDTH/2), 2048 - (SCR_HEIGHT/2));
    	sceGuViewport( 2048, 2048, SCR_WIDTH, SCR_HEIGHT);
    	sceGuDepthRange( 65535, 0);
    
    	// Set Render States
    	sceGuScissor( 0, 0, SCR_WIDTH, SCR_HEIGHT);
    	sceGuEnable( GU_SCISSOR_TEST );
    	sceGuDepthFunc( GU_GEQUAL );
    	sceGuEnable( GU_DEPTH_TEST );
    	sceGuFrontFace( GU_CW );
    	sceGuEnable( GU_CULL_FACE );					
    	sceGuShadeModel( GU_SMOOTH );
    	sceGuEnable( GU_CLIP_PLANES );
    	sceGuEnable( GU_TEXTURE_2D );
    	sceGuEnable( GU_LIGHT0 );						// Enable Light 1 (NEW)
    	
    	// setup texture
    	// 32-bit image, if we swizzled the texture will return true, otherwise false (NEW)
    	sceGuTexMode( GU_PSM_8888, 0, 0, texture.Swizzled() );	
    	sceGuTexFunc( GU_TFX_MODULATE, GU_TCC_RGB );	// Modulate the color of the image
    	sceGuTexScale( 1.0f, 1.0f );					// No scaling
    	sceGuTexOffset( 0.0f, 0.0f );
    
    	ScePspFVector3 lightPosition = { 0.0f, 0.0f, 4.0f };
    
        sceGuLight( 0, GU_SPOTLIGHT, GU_AMBIENT_AND_DIFFUSE, &lightPosition ); //GU_POINTLIGHT
    	sceGuLightColor( 0, GU_AMBIENT, GU_COLOR( 0.2f, 0.2f, 0.2f, 1.0f ));
    	sceGuLightColor( 0, GU_DIFFUSE, GU_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
    
    	sceGuFinish();
    	sceGuSync(0,0);
    
    	sceDisplayWaitVblankStart();
    	sceGuDisplay(GU_TRUE);
    	// finish
    }
    
    void SetupProjection( void )
    {
    	// setup matrices for the triangle
    	sceGumMatrixMode(GU_PROJECTION);
    	sceGumLoadIdentity();
    	sceGumPerspective( 75.0f, 16.0f/9.0f, 0.5f, 1000.0f);
    
    	sceGumMatrixMode(GU_VIEW);
    	sceGumLoadIdentity();
    
    	sceGuClearColor( GU_COLOR( 0.0f, 0.0f, 0.0f, 1.0f ) );	// 0xff554433 == cool bg color
    	sceGuClearDepth(0);
    	
    }
    
    void DrawScene( void )
    {
    	sceGuStart( GU_DIRECT, dList );							// Starts the display list
    		
    	// clear screen
    	sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);	// Clears the Color and Depth Buffer
    	sceGumMatrixMode(GU_MODEL);								// Selects the Model Matrix
    	sceGumLoadIdentity();									// And Reset it
    
    	if( light ) {
    		sceGuEnable( GU_LIGHTING );							// Enable Lighting (NEW)
    	} else {
    		sceGuDisable( GU_LIGHTING );						// Disable Lighting (NEW)
    	}
    	if( texFilter ) {
    		sceGuTexFilter( GU_LINEAR, GU_LINEAR );				// Linear filtering (Good Quality)
    	} else {
    		sceGuTexFilter( GU_NEAREST, GU_NEAREST );			// Nearest filtering (Bad Quality) (NEW)
    	}
    	
    	if( texon ) {
    		sceGuEnable( GU_TEXTURE_2D );
    		color = GU_COLOR( 1.0f, 1.0f, 1.0f, 1.0f );
    	} else {
    		sceGuDisable( GU_TEXTURE_2D );
    		color = GU_COLOR( 0.0f, 0.0f, 1.0f, 1.0f );
    	}
    
    	
    	{	
    		ScePspFVector3 move = { -6.0f, 0.0f, z };			// Define position structure
    		ScePspFVector3 rot  = { xrot, yrot, 0.0f };			// Define rotation structure 
    
    		sceGumTranslate( &move );							// Move the Object
    		sceGumRotateXYZ( &rot );							// Rotate the Object 
    	}
    
    	sceGuTexImage( 0, texture.Width(), texture.Height(), texture.Width(), texture.Image() );
    
    	// Draw Quad
    	sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
    					3*12, 0, quad );						// Draw the Cube (NEW)
    
    					sceGumLoadIdentity();									// And Reset it
    
    	
    	{	
    		ScePspFVector3 move = { -3.0f, 0.0f, z };			// Define position structure
    		ScePspFVector3 rot  = { xrot, yrot, 0.0f };			// Define rotation structure 
    
    		sceGumTranslate( &move );							// Move the Object
    		sceGumRotateXYZ( &rot );							// Rotate the Object 
    	}
    
    	//sceGuTexImage( 0, texture.Width(), texture.Height(), texture.Width(), texture.Image() );
    						sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
    					3*12, 0, quad1 );
    					
    					sceGumLoadIdentity();									// And Reset it
    
    	
    	{	
    		ScePspFVector3 move = { 0.0f, 0.0f, z };			// Define position structure
    		ScePspFVector3 rot  = { xrot, yrot, 0.0f };			// Define rotation structure 
    
    		sceGumTranslate( &move );							// Move the Object
    		sceGumRotateXYZ( &rot );							// Rotate the Object 
    	}
    
    	//sceGuTexImage( 0, texture.Width(), texture.Height(), texture.Width(), texture.Image() );
    					
    						sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
    					3*12, 0, quad2 );
    					
    					sceGumLoadIdentity();									// And Reset it
    	
    	{	
    		ScePspFVector3 move = { 3.0f, 0.0f, z };			// Define position structure
    		ScePspFVector3 rot  = { xrot, yrot, 0.0f };			// Define rotation structure 
    
    		sceGumTranslate( &move );							// Move the Object
    		sceGumRotateXYZ( &rot );							// Rotate the Object 
    	}
    
    	//sceGuTexImage( 0, texture.Width(), texture.Height(), texture.Width(), texture.Image() );
    					
    						sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
    					3*12, 0, quad3 );
    					
    					
    	xrot+= ( xspeed * dt);
    	yrot+= ( yspeed * dt);
    
    	sceGuFinish();
    	sceGuSync(0,0);	
    
    }
    
    //END OF FILE
    -=Double Post Merge =-
    I'm just working off of a tutorial.
    -=Double Post Merge =-
    I think I know why, I need to reload the model.
    How would I do that though?
    Geändert von MoAShaun (08-21-2008 um 05:19 PM Uhr) Grund: Automerged Doublepost

  15. #8955
    QJ Gamer Gold
    Points: 17.453, Level: 84
    Level completed: 21%, Points required for next Level: 397
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    everywhere
    Beiträge
    3.526
    Points
    17.453
    Level
    84
    Downloads
    1
    Uploads
    0

    Standard

    yep just like i thought, your not actually changing the color of the vertex, simple telling the color variable....it's a new color that's it, you need to loop though your object and change it's vertex color
    1. Failed....again...
    2. http://slicer.gibbocool.com/ stay updated on all my projects
    3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been

  16. #8956
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Yeah, you are setting the color in those vertices to the value of color, but when you change the value of color, you need to update the vertices.

    For example, look at this code sample:
    Code:
    int someVariable = 12;
    int otherVaraible =  someVariable;
    someVariable = 14;
    
    std::cout << "someVariable is " << someVariable << ".\n"; // 14
    std::cout << "otherVariable is " << otherVariable << ".\n"; // 12
    
    otherVariable = someVariable;
    std::cout << "Now otherVariable is " << otherVariable << ".\n"; // 14
    The fix would to setup the vertices' colors after you change the color.

  17. #8957
    QJ Gamer Blue
    Points: 2.426, Level: 29
    Level completed: 84%, Points required for next Level: 24
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Aug 2008
    Beiträge
    26
    Points
    2.426
    Level
    29
    Downloads
    0
    Uploads
    0

    Standard

    Thanks guys.
    -=Double Post Merge =-
    Nope, not working D:
    I'm getting:
    unused variable quad_t (wtf is the "_t" about?)
    unused variable quad1
    unused variable quad2
    unused variable quad3

    Code:
    //**************************************************************************
    //		PSPGU Tutorial: 'Lesson6' - main.cpp
    //**************************************************************************
    
    #include "main.h"
    
    PSP_MODULE_INFO("Lesson6", 0, 1, 1);
    PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
    
    int fps = 0;			// for calculating the frames per second
    char *fpsDisplay;
    void *dList;			// display List, used by sceGUStart
    void *fbp0;				// frame buffer
    
    u32 tickResolution;
    u64 fpsTickNow;
    u64 fpsTickLast;
    
    bool exiting = false;
    bool light = false;		// Lighting ON/OFF (NEW)
    bool texFilter = false; // Texture Filter, NEAREST / LINEAR (NEW)
    bool texon = true;
    
    float xrot = 0.0f;		// X Rotation (NEW)
    float yrot = 0.0f;		// Y Rotation (NEW)
    float xspeed = 0.0f;	// X Speed (NEW)
    float yspeed = 0.0f;	// Y Speed (NEW)
    float z = -3.0f;        // Z Position (NEW)
    
    float dt;				// For time based animation
    
    unsigned int color = GU_COLOR( 0.0f, 0.0f, 1.0f, 1.0f );
    
    CTGATexture texture;
    
    void reloadmodel () {
    Vertex __attribute__((aligned(16))) quad[3*12] = 
    {
    	{ 0, 1, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Top
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f, 1.0f },	// Bottom
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 0, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f,-1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f, 1.0f },	// Front
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 1, 0, color, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f,-1.0f },	// Back
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f,-1.0f },
    
    	{ 0, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Left
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },	// Right
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f }
    
    };
    
    Vertex __attribute__((aligned(16))) quad1[3*12] = 
    {
    	{ 0, 1, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Top
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f, 1.0f },	// Bottom
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 0, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f,-1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f, 1.0f },	// Front
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 1, 0, color, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f,-1.0f },	// Back
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f,-1.0f },
    
    	{ 0, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Left
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },	// Right
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f }
    
    };
    
    Vertex __attribute__((aligned(16))) quad2[3*12] = 
    {
    	{ 0, 1, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Top
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f, 1.0f },	// Bottom
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 0, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f,-1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f, 1.0f },	// Front
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 1, 0, color, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f,-1.0f },	// Back
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f,-1.0f },
    
    	{ 0, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Left
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },	// Right
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f }
    
    };
    
    Vertex __attribute__((aligned(16))) quad3[3*12] = 
    {
    	{ 0, 1, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Top
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f, 1.0f },	// Bottom
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 0, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f,-1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f, 1.0f },	// Front
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 1, 0, color, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f,-1.0f },	// Back
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f,-1.0f },
    
    	{ 0, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Left
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },	// Right
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f }
    
    };
    }
    
    int main(int argc, char **argv)
    {
    	reloadmodel ();
    	fbp0  = 0;
    	dList = malloc( 262144 );
    	fpsDisplay = "FPS: calculating";
    	
    
    	sceRtcGetCurrentTick( &fpsTickLast );
    	tickResolution = sceRtcGetTickResolution();
    
    	CTimer timer;
    	SceCtrlData pad, lastPad;						// Controller structure				
    	sceCtrlReadBufferPositive(&lastPad, 1);
    
    	SetupCallbacks();
    	pspDebugScreenInit();
    	sceKernelDcacheWritebackAll();
    
    	if( !texture.LoadTGA( "Data/Crate.tga" ) ) {
    		sceKernelExitGame();
    	}
    	texture.Swizzle();
    
    	InitGU();
    	SetupProjection();
    
    	while( !exiting )
    	{
    		sceCtrlPeekBufferPositive(&pad, 1);			
    		if( pad.Buttons != lastPad.Buttons ) {		// Thanks to Insomniac for the hint!
    			lastPad = pad;
    			
    			if( pad.Buttons & PSP_CTRL_CROSS ) {
    				light = !light;	
    			}
    			if( pad.Buttons & PSP_CTRL_SQUARE ) {
    				texFilter = !texFilter;
    			}
    			if( pad.Buttons & PSP_CTRL_CIRCLE ) {
    				texon = !texon;
    			}
    		}
    		if( pad.Buttons & PSP_CTRL_LTRIGGER ) {
    			z -= (1.0f * dt);
    		}
    		if( pad.Buttons & PSP_CTRL_RTRIGGER ) {
    			z += (1.0f * dt);
    		}
    		if( pad.Buttons & PSP_CTRL_UP ) {
    			xspeed -= 0.01f;
    		}
    		if( pad.Buttons & PSP_CTRL_DOWN ) {
    			xspeed += 0.01f;
    		}
    		if( pad.Buttons & PSP_CTRL_LEFT ) {
    			yspeed -= 0.01f;
    		}
    		if( pad.Buttons & PSP_CTRL_RIGHT ) {
    			yspeed += 0.01f;
    		}
    
    		dt = timer.GetDeltaTime( );
    		DrawScene();
    		FPS();
    
    		//sceDisplayWaitVblankStart();
    		fbp0 = sceGuSwapBuffers();
    
    	}
    
    	sceGuTerm();			// Terminating the Graphics System
    
    	// Free Memory
    	free( dList );
    	free( fpsDisplay );
    
    	sceKernelExitGame();	// Quits Application
    	return 0;
    }
    
    void FPS( void )
    {
    	fps++;
    	sceRtcGetCurrentTick( &fpsTickNow );
    	if( ((fpsTickNow - fpsTickLast)/((float)tickResolution)) >= 1.0f )
    	{
    		fpsTickLast = fpsTickNow;
    		sprintf( fpsDisplay, "FPS: %i", (int)fps );
    		fps = 0;
    	}
    	pspDebugScreenSetOffset( (int)fbp0 );
    	pspDebugScreenSetXY( 0, 0 );
    	pspDebugScreenPrintf( fpsDisplay );
    
    }
    
    void InitGU( void )
    {
    	// Init GU
    	sceGuInit();
    	sceGuStart( GU_DIRECT, dList );
    
    	// Set Buffers
    	sceGuDrawBuffer( GU_PSM_8888, fbp0, BUF_WIDTH );
    	sceGuDispBuffer( SCR_WIDTH, SCR_HEIGHT, (void*)0x88000, BUF_WIDTH);
    	sceGuDepthBuffer( (void*)0x110000, BUF_WIDTH);
    
    	sceGuOffset( 2048 - (SCR_WIDTH/2), 2048 - (SCR_HEIGHT/2));
    	sceGuViewport( 2048, 2048, SCR_WIDTH, SCR_HEIGHT);
    	sceGuDepthRange( 65535, 0);
    
    	// Set Render States
    	sceGuScissor( 0, 0, SCR_WIDTH, SCR_HEIGHT);
    	sceGuEnable( GU_SCISSOR_TEST );
    	sceGuDepthFunc( GU_GEQUAL );
    	sceGuEnable( GU_DEPTH_TEST );
    	sceGuFrontFace( GU_CW );
    	sceGuEnable( GU_CULL_FACE );					
    	sceGuShadeModel( GU_SMOOTH );
    	sceGuEnable( GU_CLIP_PLANES );
    	sceGuEnable( GU_TEXTURE_2D );
    	sceGuEnable( GU_LIGHT0 );						// Enable Light 1 (NEW)
    	
    	// setup texture
    	// 32-bit image, if we swizzled the texture will return true, otherwise false (NEW)
    	sceGuTexMode( GU_PSM_8888, 0, 0, texture.Swizzled() );	
    	sceGuTexFunc( GU_TFX_MODULATE, GU_TCC_RGB );	// Modulate the color of the image
    	sceGuTexScale( 1.0f, 1.0f );					// No scaling
    	sceGuTexOffset( 0.0f, 0.0f );
    
    	ScePspFVector3 lightPosition = { 0.0f, 0.0f, 4.0f };
        sceGuLight( 0, GU_SPOTLIGHT, GU_AMBIENT_AND_DIFFUSE, &lightPosition ); //GU_POINTLIGHT
    	sceGuLightColor( 0, GU_AMBIENT, GU_COLOR( 0.2f, 0.2f, 0.2f, 1.0f ));
    	sceGuLightColor( 0, GU_DIFFUSE, GU_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
    
    	sceGuFinish();
    	sceGuSync(0,0);
    
    	sceDisplayWaitVblankStart();
    	sceGuDisplay(GU_TRUE);
    	// finish
    }
    
    void SetupProjection( void )
    {
    	// setup matrices for the triangle
    	sceGumMatrixMode(GU_PROJECTION);
    	sceGumLoadIdentity();
    	sceGumPerspective( 75.0f, 16.0f/9.0f, 0.5f, 1000.0f);
    
    	sceGumMatrixMode(GU_VIEW);
    	sceGumLoadIdentity();
    
    	sceGuClearColor( GU_COLOR( 0.0f, 0.0f, 0.0f, 1.0f ) );	// 0xff554433 == cool bg color
    	sceGuClearDepth(0);
    	
    }
    
    void DrawScene( void )
    {
    	sceGuStart( GU_DIRECT, dList );							// Starts the display list
    		
    	// clear screen
    	sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);	// Clears the Color and Depth Buffer
    	sceGumMatrixMode(GU_MODEL);								// Selects the Model Matrix
    	sceGumLoadIdentity();									// And Reset it
    
    	if( light ) {
    		sceGuEnable( GU_LIGHTING );							// Enable Lighting (NEW)
    	} else {
    		sceGuDisable( GU_LIGHTING );						// Disable Lighting (NEW)
    	}
    	if( texFilter ) {
    		sceGuTexFilter( GU_LINEAR, GU_LINEAR );				// Linear filtering (Good Quality)
    	} else {
    		sceGuTexFilter( GU_NEAREST, GU_NEAREST );			// Nearest filtering (Bad Quality) (NEW)
    	}
    	
    	if( texon ) {
    		sceGuEnable( GU_TEXTURE_2D );
    		color = GU_COLOR( 1.0f, 1.0f, 1.0f, 1.0f );
    		reloadmodel();
    	} else {
    		sceGuDisable( GU_TEXTURE_2D );
    		color = GU_COLOR( 0.0f, 0.0f, 1.0f, 1.0f );
    		reloadmodel();
    	}
    
    	
    	{	
    		ScePspFVector3 move = { -6.0f, 0.0f, z };			// Define position structure
    		ScePspFVector3 rot  = { xrot, yrot, 0.0f };			// Define rotation structure 
    
    		sceGumTranslate( &move );							// Move the Object
    		sceGumRotateXYZ( &rot );							// Rotate the Object 
    	}
    
    	sceGuTexImage( 0, texture.Width(), texture.Height(), texture.Width(), texture.Image() );
    
    	// Draw Quad
    	sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
    					3*12, 0, quad );						// Draw the Cube (NEW)
    
    					sceGumLoadIdentity();									// And Reset it
    
    	
    	{	
    		ScePspFVector3 move = { -3.0f, 0.0f, z };			// Define position structure
    		ScePspFVector3 rot  = { xrot, yrot, 0.0f };			// Define rotation structure 
    
    		sceGumTranslate( &move );							// Move the Object
    		sceGumRotateXYZ( &rot );							// Rotate the Object 
    	}
    
    	//sceGuTexImage( 0, texture.Width(), texture.Height(), texture.Width(), texture.Image() );
    						sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
    					3*12, 0, quad1 );
    					
    					sceGumLoadIdentity();									// And Reset it
    
    	
    	{	
    		ScePspFVector3 move = { 0.0f, 0.0f, z };			// Define position structure
    		ScePspFVector3 rot  = { xrot, yrot, 0.0f };			// Define rotation structure 
    
    		sceGumTranslate( &move );							// Move the Object
    		sceGumRotateXYZ( &rot );							// Rotate the Object 
    	}
    
    	//sceGuTexImage( 0, texture.Width(), texture.Height(), texture.Width(), texture.Image() );
    					
    						sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
    					3*12, 0, quad2 );
    					
    					sceGumLoadIdentity();									// And Reset it
    	
    	{	
    		ScePspFVector3 move = { 3.0f, 0.0f, z };			// Define position structure
    		ScePspFVector3 rot  = { xrot, yrot, 0.0f };			// Define rotation structure 
    
    		sceGumTranslate( &move );							// Move the Object
    		sceGumRotateXYZ( &rot );							// Rotate the Object 
    	}
    
    	//sceGuTexImage( 0, texture.Width(), texture.Height(), texture.Width(), texture.Image() );
    					
    						sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_COLOR_8888|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
    					3*12, 0, quad3 );
    					
    					
    	xrot+= ( xspeed * dt);
    	yrot+= ( yspeed * dt);
    
    	sceGuFinish();
    	sceGuSync(0,0);	
    
    }
    
    //END OF FILE
    Geändert von MoAShaun (08-21-2008 um 07:27 PM Uhr) Grund: Automerged Doublepost

  18. #8958
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    im assuming youre also getting some redefinition errors. Thing is, when you do this the 1st time:

    Vertex __attribute__((aligned(16 ))) quad[3*12]

    you have declared your quad. You cannot re-declare it, which you are doing each time you call reloadModel(). That would be like doing this:

    int number;
    int number;

    that would give you an error, since you cant have 2 variables of the same type and name, its a logical error.

    My recommendation:

    Code:
    //**************************************************************************
    //		PSPGU Tutorial: 'Lesson6' - main.cpp
    //**************************************************************************
    
    #include "main.h"
    
    PSP_MODULE_INFO("Lesson6", 0, 1, 1);
    PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
    
    int fps = 0;			// for calculating the frames per second
    char *fpsDisplay;
    void *dList;			// display List, used by sceGUStart
    void *fbp0;				// frame buffer
    
    u32 tickResolution;
    u64 fpsTickNow;
    u64 fpsTickLast;
    
    bool exiting = false;
    bool light = false;		// Lighting ON/OFF (NEW)
    bool texFilter = false; // Texture Filter, NEAREST / LINEAR (NEW)
    bool texon = true;
    
    float xrot = 0.0f;		// X Rotation (NEW)
    float yrot = 0.0f;		// Y Rotation (NEW)
    float xspeed = 0.0f;	// X Speed (NEW)
    float yspeed = 0.0f;	// Y Speed (NEW)
    float z = -3.0f;        // Z Position (NEW)
    
    float dt;				// For time based animation
    
    unsigned int color = GU_COLOR( 0.0f, 0.0f, 1.0f, 1.0f );
    
    CTGATexture texture;
    
    Vertex __attribute__((aligned(16))) quad[3*12] = 
    {
    	{ 0, 1, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Top
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f, 1.0f },	// Bottom
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 0, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f,-1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f, 1.0f },	// Front
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 1, 0, color, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f,-1.0f },	// Back
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f,-1.0f },
    
    	{ 0, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Left
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },	// Right
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f }
    
    };
    
    Vertex __attribute__((aligned(16))) quad1[3*12] = 
    {
    	{ 0, 1, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Top
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f, 1.0f },	// Bottom
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 0, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f,-1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f, 1.0f },	// Front
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 1, 0, color, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f,-1.0f },	// Back
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f,-1.0f },
    
    	{ 0, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Left
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },	// Right
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f }
    
    };
    
    Vertex __attribute__((aligned(16))) quad2[3*12] = 
    {
    	{ 0, 1, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Top
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f, 1.0f },	// Bottom
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 0, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f,-1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f, 1.0f },	// Front
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 1, 0, color, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f,-1.0f },	// Back
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f,-1.0f },
    
    	{ 0, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Left
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },	// Right
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f }
    
    };
    
    Vertex __attribute__((aligned(16))) quad3[3*12] = 
    {
    	{ 0, 1, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Top
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 1.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f, 1.0f },	// Bottom
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f,-1.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 0, color, 0.0f,-1.0f, 0.0f, 1.0f,-1.0f,-1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f, 1.0f },	// Front
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f },
    	{ 1, 0, color, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f,-1.0f },	// Back
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    
    	{ 0, 0, color, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f,-1.0f },
    	{ 1, 1, color, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f,-1.0f },
    	{ 1, 0, color, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f,-1.0f },
    
    	{ 0, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f,-1.0f },	// Left
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    
    	{ 0, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f,-1.0f },
    	{ 1, 1, color,-1.0f, 0.0f, 0.0f,-1.0f, 1.0f, 1.0f },
    	{ 1, 0, color,-1.0f, 0.0f, 0.0f,-1.0f,-1.0f, 1.0f },
    
    	{ 0, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },	// Right
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    
    	{ 0, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f, 1.0f },
    	{ 1, 1, color, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,-1.0f },
    	{ 1, 0, color, 1.0f, 0.0f, 0.0f, 1.0f,-1.0f,-1.0f }
    
    };
    
    int main(int argc, char **argv)
    {
    	reloadmodel ();
    	fbp0  = 0;
    	dList = malloc( 262144 );
    	fpsDisplay = "FPS: calculating";
    	
    
    	sceRtcGetCurrentTick( &fpsTickLast );
    	tickResolution = sceRtcGetTickResolution();
    
    	CTimer timer;
    	SceCtrlData pad, lastPad;						// Controller structure				
    	sceCtrlReadBufferPositive(&lastPad, 1);
    
    	SetupCallbacks();
    	pspDebugScreenInit();
    	sceKernelDcacheWritebackAll();
    
    	if( !texture.LoadTGA( "Data/Crate.tga" ) ) {
    		sceKernelExitGame();
    	}
    	texture.Swizzle();
    
    	InitGU();
    	SetupProjection();
    
    	while( !exiting )
    	{
    		sceCtrlPeekBufferPositive(&pad, 1);			
    		if( pad.Buttons != lastPad.Buttons ) {		// Thanks to Insomniac for the hint!
    			lastPad = pad;
    			
    			if( pad.Buttons & PSP_CTRL_CROSS ) {
    				light = !light;	
    			}
    			if( pad.Buttons & PSP_CTRL_SQUARE ) {
    				texFilter = !texFilter;
    			}
    			if( pad.Buttons & PSP_CTRL_CIRCLE ) {
    				texon = !texon;
    			}
    		}
    		if( pad.Buttons & PSP_CTRL_LTRIGGER ) {
    			z -= (1.0f * dt);
    		}
    		if( pad.Buttons & PSP_CTRL_RTRIGGER ) {
    			z += (1.0f * dt);
    		}
    		if( pad.Buttons & PSP_CTRL_UP ) {
    			xspeed -= 0.01f;
    		}
    		if( pad.Buttons & PSP_CTRL_DOWN ) {
    			xspeed += 0.01f;
    		}
    		if( pad.Buttons & PSP_CTRL_LEFT ) {
    			yspeed -= 0.01f;
    		}
    		if( pad.Buttons & PSP_CTRL_RIGHT ) {
    			yspeed += 0.01f;
    		}
    
    		dt = timer.GetDeltaTime( );
    		DrawScene();
    		FPS();
    
    		//sceDisplayWaitVblankStart();
    		fbp0 = sceGuSwapBuffers();
    
    	}
    
    	sceGuTerm();			// Terminating the Graphics System
    
    	// Free Memory
    	free( dList );
    	free( fpsDisplay );
    
    	sceKernelExitGame();	// Quits Application
    	return 0;
    }
    
    void FPS( void )
    {
    	fps++;
    	sceRtcGetCurrentTick( &fpsTickNow );
    	if( ((fpsTickNow - fpsTickLast)/((float)tickResolution)) >= 1.0f )
    	{
    		fpsTickLast = fpsTickNow;
    		sprintf( fpsDisplay, "FPS: %i", (int)fps );
    		fps = 0;
    	}
    	pspDebugScreenSetOffset( (int)fbp0 );
    	pspDebugScreenSetXY( 0, 0 );
    	pspDebugScreenPrintf( fpsDisplay );
    
    }
    
    void InitGU( void )
    {
    	// Init GU
    	sceGuInit();
    	sceGuStart( GU_DIRECT, dList );
    
    	// Set Buffers
    	sceGuDrawBuffer( GU_PSM_8888, fbp0, BUF_WIDTH );
    	sceGuDispBuffer( SCR_WIDTH, SCR_HEIGHT, (void*)0x88000, BUF_WIDTH);
    	sceGuDepthBuffer( (void*)0x110000, BUF_WIDTH);
    
    	sceGuOffset( 2048 - (SCR_WIDTH/2), 2048 - (SCR_HEIGHT/2));
    	sceGuViewport( 2048, 2048, SCR_WIDTH, SCR_HEIGHT);
    	sceGuDepthRange( 65535, 0);
    
    	// Set Render States
    	sceGuScissor( 0, 0, SCR_WIDTH, SCR_HEIGHT);
    	sceGuEnable( GU_SCISSOR_TEST );
    	sceGuDepthFunc( GU_GEQUAL );
    	sceGuEnable( GU_DEPTH_TEST );
    	sceGuFrontFace( GU_CW );
    	sceGuEnable( GU_CULL_FACE );					
    	sceGuShadeModel( GU_SMOOTH );
    	sceGuEnable( GU_CLIP_PLANES );
    	sceGuEnable( GU_TEXTURE_2D );
    	sceGuEnable( GU_LIGHT0 );						// Enable Light 1 (NEW)
    	
    	// setup texture
    	// 32-bit image, if we swizzled the texture will return true, otherwise false (NEW)
    	sceGuTexMode( GU_PSM_8888, 0, 0, texture.Swizzled() );	
    	sceGuTexFunc( GU_TFX_MODULATE, GU_TCC_RGB );	// Modulate the color of the image
    	sceGuTexScale( 1.0f, 1.0f );					// No scaling
    	sceGuTexOffset( 0.0f, 0.0f );
    
    	ScePspFVector3 lightPosition = { 0.0f, 0.0f, 4.0f };
        sceGuLight( 0, GU_SPOTLIGHT, GU_AMBIENT_AND_DIFFUSE, &lightPosition ); //GU_POINTLIGHT
    	sceGuLightColor( 0, GU_AMBIENT, GU_COLOR( 0.2f, 0.2f, 0.2f, 1.0f ));
    	sceGuLightColor( 0, GU_DIFFUSE, GU_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ) );
    
    	sceGuFinish();
    	sceGuSync(0,0);
    
    	sceDisplayWaitVblankStart();
    	sceGuDisplay(GU_TRUE);
    	// finish
    }
    
    void SetupProjection( void )
    {
    	// setup matrices for the triangle
    	sceGumMatrixMode(GU_PROJECTION);
    	sceGumLoadIdentity();
    	sceGumPerspective( 75.0f, 16.0f/9.0f, 0.5f, 1000.0f);
    
    	sceGumMatrixMode(GU_VIEW);
    	sceGumLoadIdentity();
    
    	sceGuClearColor( GU_COLOR( 0.0f, 0.0f, 0.0f, 1.0f ) );	// 0xff554433 == cool bg color
    	sceGuClearDepth(0);
    	
    }
    
    void DrawScene( void )
    {
    	sceGuStart( GU_DIRECT, dList );							// Starts the display list
    		
    	// clear screen
    	sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);	// Clears the Color and Depth Buffer
    	sceGumMatrixMode(GU_MODEL);								// Selects the Model Matrix
    	sceGumLoadIdentity();									// And Reset it
    
    	if( light ) {
    		sceGuEnable( GU_LIGHTING );							// Enable Lighting (NEW)
    	} else {
    		sceGuDisable( GU_LIGHTING );						// Disable Lighting (NEW)
    	}
    	if( texFilter ) {
    		sceGuTexFilter( GU_LINEAR, GU_LINEAR );				// Linear filtering (Good Quality)
    	} else {
    		sceGuTexFilter( GU_NEAREST, GU_NEAREST );			// Nearest filtering (Bad Quality) (NEW)
    	}
    	
    	if( texon ) {
    		color = GU_COLOR( 1.0f, 1.0f, 1.0f, 1.0f );
    	} else {
    		color = GU_COLOR( 0.0f, 0.0f, 1.0f, 1.0f );
    	}
    
    	
    	{	
    		ScePspFVector3 move = { -6.0f, 0.0f, z };			// Define position structure
    		ScePspFVector3 rot  = { xrot, yrot, 0.0f };			// Define rotation structure 
    
    		sceGumTranslate( &move );							// Move the Object
    		sceGumRotateXYZ( &rot );							// Rotate the Object 
    	}
    
    	sceGuEnable(GU_TEXTURE_2D);
    
    	sceGuTexImage( 0, texture.Width(), texture.Height(), texture.Width(), texture.Image() );
    
    	sceGuColor(color);
    	
    	// Draw Quad
    	sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
    					3*12, 0, quad );						// Draw the Cube (NEW)
    
    					sceGumLoadIdentity();									// And Reset it
    
    	
    	{	
    		ScePspFVector3 move = { -3.0f, 0.0f, z };			// Define position structure
    		ScePspFVector3 rot  = { xrot, yrot, 0.0f };			// Define rotation structure 
    
    		sceGumTranslate( &move );							// Move the Object
    		sceGumRotateXYZ( &rot );							// Rotate the Object 
    	}
    
    	//sceGuTexImage( 0, texture.Width(), texture.Height(), texture.Width(), texture.Image() );
    						sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
    					3*12, 0, quad1 );
    					
    					sceGumLoadIdentity();									// And Reset it
    
    	
    	{	
    		ScePspFVector3 move = { 0.0f, 0.0f, z };			// Define position structure
    		ScePspFVector3 rot  = { xrot, yrot, 0.0f };			// Define rotation structure 
    
    		sceGumTranslate( &move );							// Move the Object
    		sceGumRotateXYZ( &rot );							// Rotate the Object 
    	}
    
    	//sceGuTexImage( 0, texture.Width(), texture.Height(), texture.Width(), texture.Image() );
    					
    						sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
    					3*12, 0, quad2 );
    					
    					sceGumLoadIdentity();									// And Reset it
    	
    	{	
    		ScePspFVector3 move = { 3.0f, 0.0f, z };			// Define position structure
    		ScePspFVector3 rot  = { xrot, yrot, 0.0f };			// Define rotation structure 
    
    		sceGumTranslate( &move );							// Move the Object
    		sceGumRotateXYZ( &rot );							// Rotate the Object 
    	}
    
    	//sceGuTexImage( 0, texture.Width(), texture.Height(), texture.Width(), texture.Image() );
    					
    						sceGumDrawArray( GU_TRIANGLES, GU_TEXTURE_32BITF|GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
    					3*12, 0, quad3 );
    					
    					
    	xrot+= ( xspeed * dt);
    	yrot+= ( yspeed * dt);
    
    	sceGuFinish();
    	sceGuSync(0,0);	
    
    }
    
    //END OF FILE
    Also, change your "Vertex" from something like this:

    struct Vertex
    {
    float u, v;
    unsigned int color;
    float nx, ny, nz;
    float x, y, z;
    };

    to:

    struct Vertex
    {
    float u, v;
    float nx, ny, nz;
    float x, y, z;
    };


    i have NOT tested this, but it should work. might have gotten some spellings/syntax wrong though :/

    would someone else please explain to him what i did? i really need my beauty sleep...
    --------------------------------------------------------------------------------------

  19. #8959
    QJ Gamer Green
    Points: 4.092, Level: 40
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Beiträge
    508
    Points
    4.092
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    I feel kinda bad for populating the last few pages, but I know mips well enough this would be vedy vedy helpful.

    Code:
    int cvtValue(unsigned int cvtFloat, const char cvtMode)
    {
    int cvtVerted;
    asm( "mtc1 %0, $f0;"
    "cvt.w.s $f1, $f0;" 
    "mfc1 $5, $f1;"
    	: "=r" (cvtFloat)
    	: "r" (cvtVerted)
    	: "$5" 
    	);
    	
    return cvtVerted;
    
    
    }
    To sum it up, that does jack squat. After..idk how many google searches..I pretty much stopped looking. It's been a while, but if anyone can enlighten me as to how I would use the inline asm i/o type thing, I would be very greatful.

  20. #8960
    QJ Gamer Silver
    Points: 14.087, Level: 77
    Level completed: 10%, Points required for next Level: 363
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Germany
    Beiträge
    926
    Points
    14.087
    Level
    77
    Downloads
    0
    Uploads
    0

    Standard

    All that does... or better yet, tries to do, is convert a float to an int (with truncation). That's stupid to pack into an extra function, as you can just do type conversion and it will behave like that.
    Code:
    float somevalue = 3.64f;
    int somvalueint = (int)somevalue; // 3
    Or wait, are you really having the float as binary inside an int?
    Try this:
    Code:
    int cvtValue(unsigned int cvtFloat, const char cvtMode)
    {
    int cvtVerted;
    asm( "mtc1 %1, $f0;"
    "cvt.w.s $f0, $f0;" 
    "mfc1 %0, $f0;"
    	: "=r" (cvtVerted)
    	: "r" (cvtFloat)
    	: "$f0" 
    	);
    	
    return cvtVerted;
    }
    Geändert von Raphael (08-22-2008 um 04:22 AM Uhr)
    Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
    Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
    Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
    Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.

  21. #8961
    QJ Gamer Green
    Points: 4.092, Level: 40
    Level completed: 72%, Points required for next Level: 58
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Beiträge
    508
    Points
    4.092
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    It's for memory editing and 2 cheat devices, one I'm working on myself, and one I'm helping with. I shall try that, thanks.

  22. #8962
    QJ Gamer Bronze
    Points: 6.517, Level: 52
    Level completed: 84%, Points required for next Level: 33
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Ort
    Ireland
    Beiträge
    978
    Points
    6.517
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    ok im trying to make a simple program and i know im doing something stupid in my code.
    Its been a long day and am tired so don't make me look stupid.

    Code:
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspctrl.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    #define printf pspDebugScreenPrintf
    
    PSP_MODULE_INFO("Hello World",0,1,0);
    
    void fcopy(char * source, char * destination) 
    {
        printf("Preparing Variables... ");
    	FILE * src, * dst;
    	char * buffer;
    	long size;
    	src = fopen(source,"r");
    	fseek(src,0,SEEK_END);
    	size = ftell(src);
    	rewind(src);
    	buffer = malloc(size);
    	printf("Done. \n");
    	printf("Reading %s... ",source);
    	fread(buffer,1,size,src);
    	printf("Done. \n");
    	printf("Writing to %s... ",destination);
    	fclose(src);
    	dst = fopen(destination,"w");
    	fwrite(buffer,1,size,dst);
    	fclose(dst);
    	free(buffer);
    	printf("Done. \n");
    
    int copy_files ()
    {
      pspDebugScreenInit();
      pspDebugScreenClear();
      fcopy("flash0:/vsh/km/umd9660.prx","ms0:/umd9660.prx");
      fcopy("flash0:/vsh/resource/topmenu_plugin.rco","ms0:/topmenu_plugin.rco");
      fcopy("flash0:/font/ltn0.pgf","ms0:/ltn0.pgf");
      printf("\n\n");
      printf("Done.\tPress X to go back to the Main Menu.");
      
      while (1)
    	{
    		SceCtrlData pad;
    
    		sceCtrlReadBufferPositive(&pad, 1);
            
    		if (pad.Buttons & PSP_CTRL_CROSS)
            menu();
            }        
    }
    
    int menu ()
    {
        pspDebugScreenInit();
        pspDebugScreenClear();
        printf("Press X to Copy the files from the flash.\n");
        printf("Press O to exit the program.\n");
    
        while (1)
    	{
    		SceCtrlData pad;
    
    		sceCtrlReadBufferPositive(&pad, 1);
            
    		if (pad.Buttons & PSP_CTRL_CROSS)
    		{
            printf("Please wait.");
            sceKernalDelayThread(3*300*300);
            copy_files();
            }
            
            if (pad.Buttons & PSP_CTRL_CIRCLE)
            break;
            }
    }
            
    int main ()
    {
        pspDebugScreenInit();
        pspDebugScreenClear();
        printf("Press X to Copy the files from the flash.\n");
        printf("Press O to exit the program.\n");
        
        while (1)
    	{
    		SceCtrlData pad;
    
    		sceCtrlReadBufferPositive(&pad, 1);
            
    		if (pad.Buttons & PSP_CTRL_CROSS)
    		{
            printf("Please wait.");
            sceKernalDelayThread(3*300*300);
            copy_files();
            }
            
            if (pad.Buttons & PSP_CTRL_CIRCLE)
            break;
            }
            
      }
       return 0;
    }
    Could someone fix it?
    Or tell me what im doing wrong?

    Thanks.

    Note.. THE SPACES ARE LIKE THAT BECAUSE I COPIED IT FROM UBUNTU.
    Geändert von MiKeY188 (08-22-2008 um 11:15 AM Uhr)

  23. #8963
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    So, what is actually wrong with it? Compile error? Crashes?

  24. #8964
    QJ Gamer Bronze
    Points: 6.517, Level: 52
    Level completed: 84%, Points required for next Level: 33
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Ort
    Ireland
    Beiträge
    978
    Points
    6.517
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    the ones in red are causing me problems.

    Is that the right function to load the other functions?

    i got a compile error.

  25. #8965
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    You use the function menu() before you declared it in the source file. Forward declare the function at the top of the file.

  26. #8966
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Stop. Stop right now. Go throw away your PSP and stop trying to do things that you have NO IDEA how to do. Copy and pasting code is not a good thing to do. Seriously, you are an arrogant prick thinking we are going to just fix it for you.

    Go learn Python, and stay away from your PSP, for Pete's sake.

    In the mean time, read these articles.
    http://scientificninja.com/advice/dont-read-source-code
    and
    http://scientificninja.com/advice/dont-write-tutorials

    Additionally, it isn't Ubuntu's fault for the paste. Don't blame Ubuntu for your own mistakes.


  27. #8967
    QJ Gamer Silver
    Points: 14.717, Level: 78
    Level completed: 67%, Points required for next Level: 133
    Overall activity: 99,0%

    Registriert seit
    Sep 2005
    Beiträge
    2.223
    Points
    14.717
    Level
    78
    Downloads
    0
    Uploads
    0

    Standard

    Above: Cool it, there's no need for that kind of input here. There's nothing wrong with using someone's source code for practice as long as you don't try to pass it off as your own. If you don't have anything helpful to say, don't say anything at all.
    Please read our Piracy Policy before posting. Thank you.
    http://m7thcc.googlepages.com/Signature.PNG

  28. #8968
    QJ Gamer Bronze
    Points: 6.517, Level: 52
    Level completed: 84%, Points required for next Level: 33
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Ort
    Ireland
    Beiträge
    978
    Points
    6.517
    Level
    52
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von _dysfunctional Beitrag anzeigen
    Stop. Stop right now. Go throw away your PSP and stop trying to do things that you have NO IDEA how to do. Copy and pasting code is not a good thing to do. Seriously, you are an arrogant prick thinking we are going to just fix it for you.

    Go learn Python, and stay away from your PSP, for Pete's sake.

    In the mean time, read these articles.
    http://scientificninja.com/advice/dont-read-source-code
    and
    http://scientificninja.com/advice/dont-write-tutorials

    Additionally, it isn't Ubuntu's fault for the paste. Don't blame Ubuntu for your own mistakes.

    well it appeared with the lines spaced in the text editor with ubuntu.

    i didn't ask for your crap so please keep to your self it does use some source of a tutorial.

    oh and "arrogant prick" Please read over your post ;)

    Zitat Zitat von M7thCC Beitrag anzeigen
    Above: Cool it, there's no need for that kind of input here. There's nothing wrong with using someone's source code for practice as long as you don't try to pass it off as your own. If you don't have anything helpful to say, don't say anything at all.
    What he said it isn't going to me used for a program lol
    Its just practice making silly programs for fun because im bored :)

    What i basically want to know is how once i click the button do i load for ex "copy_files();"
    i know i have did something wrong could someone help thanks.

    Spoiler for The Code.:
    Code:
    #include <pspkernel.h>
    #include <pspdebug.h>
    #include <pspctrl.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    #define printf pspDebugScreenPrintf
    
    PSP_MODULE_INFO("Hello World",0,1,0);
    
    void fcopy(char * source, char * destination) 
    {
        printf("Preparing Variables... ");
    	FILE * src, * dst;
    	char * buffer;
    	long size;
    	src = fopen(source,"r");
    	fseek(src,0,SEEK_END);
    	size = ftell(src);
    	rewind(src);
    	buffer = malloc(size);
    	printf("Done. \n");
    	printf("Reading %s... ",source);
    	fread(buffer,1,size,src);
    	printf("Done. \n");
    	printf("Writing to %s... ",destination);
    	fclose(src);
    	dst = fopen(destination,"w");
    	fwrite(buffer,1,size,dst);
    	fclose(dst);
    	free(buffer);
    	printf("Done. \n");
    
    int copy_files ()
    {
      pspDebugScreenInit();
      pspDebugScreenClear();
      fcopy("flash0:/vsh/km/umd9660.prx","ms0:/umd9660.prx");
      fcopy("flash0:/vsh/resource/topmenu_plugin.rco","ms0:/topmenu_plugin.rco");
      fcopy("flash0:/font/ltn0.pgf","ms0:/ltn0.pgf");
      printf("\n\n");
      printf("Done.\tPress X to go back to the Main Menu.");
      
      while (1)
    	{
    		SceCtrlData pad;
    
    		sceCtrlReadBufferPositive(&pad, 1);
            
    		if (pad.Buttons & PSP_CTRL_CROSS)
            menu();
            }        
    }
    
    int menu ()
    {
        pspDebugScreenInit();
        pspDebugScreenClear();
        printf("Press X to Copy the files from the flash.\n");
        printf("Press O to exit the program.\n");
    
        while (1)
    	{
    		SceCtrlData pad;
    
    		sceCtrlReadBufferPositive(&pad, 1);
            
    		if (pad.Buttons & PSP_CTRL_CROSS)
    		{
            printf("Please wait.");
            sceKernalDelayThread(3*300*300);
            copy_files();
            }
            
            if (pad.Buttons & PSP_CTRL_CIRCLE)
            break;
            }
    }
            
    int main ()
    {
        pspDebugScreenInit();
        pspDebugScreenClear();
        printf("Press X to Copy the files from the flash.\n");
        printf("Press O to exit the program.\n");
        
        while (1)
    	{
    		SceCtrlData pad;
    
    		sceCtrlReadBufferPositive(&pad, 1);
            
    		if (pad.Buttons & PSP_CTRL_CROSS)
    		{
            printf("Please wait.");
            sceKernalDelayThread(3*300*300);
            copy_files();
            }
            
            if (pad.Buttons & PSP_CTRL_CIRCLE)
            break;
            }
            
      }
       return 0;
    }
    Geändert von MiKeY188 (08-22-2008 um 11:15 AM Uhr)

  29. #8969
    QJ Gamer Blue
    Points: 2.426, Level: 29
    Level completed: 84%, Points required for next Level: 24
    Overall activity: 0%
    Achievements:
    First 1000 Experience Points

    Registriert seit
    Aug 2008
    Beiträge
    26
    Points
    2.426
    Level
    29
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Grimfate126 Beitrag anzeigen
    im assuming youre also getting some redefinition errors. Thing is, when you do this the 1st time:

    Vertex __attribute__((aligned(16 ))) quad[3*12]

    you have declared your quad. You cannot re-declare it, which you are doing each time you call reloadModel(). That would be like doing this:

    int number;
    int number;

    that would give you an error, since you cant have 2 variables of the same type and name, its a logical error.

    My recommendation:

    Code:
    CODE GOES HERE
    Also, change your "Vertex" from something like this:

    struct Vertex
    {
    float u, v;
    unsigned int color;
    float nx, ny, nz;
    float x, y, z;
    };

    to:

    struct Vertex
    {
    float u, v;
    float nx, ny, nz;
    float x, y, z;
    };


    i have NOT tested this, but it should work. might have gotten some spellings/syntax wrong though :/

    would someone else please explain to him what i did? i really need my beauty sleep...
    This breaks the point of what I want do though.
    I wanted to have it so you can have multible color brick and set the color value when the vertex set is made.
    For this test though, all it was suppost to do is have a textured shape (color white), then when I hit circle, the texture goes away and the color is now blue.
    -=Double Post Merge =-


    This is the lua verson of the game.
    I'm recoding it in c++ due to limitations.
    Geändert von MoAShaun (08-22-2008 um 11:20 AM Uhr) Grund: Automerged Doublepost

  30. #8970
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Oh, you guys make me laugh so much.


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 09:15 PM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .