Skip to: Site menu | Main content


Welcome to PSP-Programming.com, a place for developers to get together.

Welcome to the forums. Here you can find other user tutorials as well as homebrew releases and the source code repository. You can also ask for help with your code here and post your own homebrew!

PSP-Programming.com Forums
February 10, 2012, 01:59:01 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

News: Welcome to PSP-Programming.com
Home Help Search Shop Login Register
Digg This!
Pages: [1]
Print
Author Topic: Trouble drawing with GU_SPRITE  (Read 2827 times)
jono
C/C++ Developer
Full Member
*

Karma: +23/-1
Offline Offline

Posts: 210
282.59 points

View Inventory
Send Money to jono


View Profile WWW
« on: July 21, 2007, 04:07:43 AM »

I'm currently trying to draw a simple HUD over the top of a project I am doing, unfortunatly the images are not drawn correctly. Rather than the images being drawn, a flat pink colored rectangle with correct dimensions are showing up in te correct position. I'm pretty sure it's an initialisation problem but cannot seem to get a good combination.

I have included code for the parts of the project that are involved below, it is all contained within a guStart/Finish block:

The blitting function:
Note: before this function is called depth testing is disabled with "sceGuDisable(GU_DEPTH_TEST);". It is later re-enabled.
Code:
void blitTexture2( Texture* source, int x, int y)
{
sceGuTexImage( 0, source->width, source->height, source->width, source->data);

Vertex* vertices = (Vertex*)sceGuGetMemory(2 * sizeof(Vertex));
vertices[0].u = 0.0;
vertices[0].v = 0.0;
vertices[0].x = x;
vertices[0].y = y;
vertices[0].z = 0;
vertices[1].u = 1.0;
vertices[1].v = 1.0;
vertices[1].x = x + source->width;
vertices[1].y = y + source->height;
vertices[1].z = 0;
sceGuDrawArray( GU_SPRITES, GU_TEXTURE_32BITF | GU_TEXTURE_32BITF | GU_TRANSFORM_2D, 2, 0, vertices);
}

The initialisation code:
Code:
// Init GU
sceGuInit();
sceGuStart( GU_DIRECT, display_list );

// Allocate Buffers
frame_buffer_0 = vrelptr( valloc(FRAME_BUFFER_SIZE));
frame_buffer_1 = vrelptr( valloc(FRAME_BUFFER_SIZE));
depth_buffer = vrelptr( valloc(FRAME_BUFFER_SIZE / 2));

current_frame_buffer = frame_buffer_0;

// Set Buffers
sceGuDrawBuffer( GU_PSM_8888, frame_buffer_0, LINE_WIDTH );
sceGuDispBuffer( SCREEN_WIDTH, SCREEN_HEIGHT, frame_buffer_1, LINE_WIDTH);
sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);
sceGuDepthBuffer( depth_buffer, LINE_WIDTH);

sceGuOffset( 2048 - (SCREEN_WIDTH/2), 2048 - (SCREEN_HEIGHT/2));
sceGuViewport( 2048, 2048, SCREEN_WIDTH, SCREEN_HEIGHT);
sceGuDepthRange(0xc350,0x2710);

// Set Render States
sceGuScissor( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
sceGuEnable( GU_SCISSOR_TEST );
sceGuDepthFunc( GU_GEQUAL );
sceGuAlphaFunc(GU_GREATER, 0, 0xff);
sceGuEnable(GU_ALPHA_TEST);
sceGuEnable( GU_DEPTH_TEST );
sceGuFrontFace( GU_CW );
sceGuEnable( GU_CULL_FACE );
sceGuShadeModel( GU_SMOOTH );
sceGuEnable( GU_CLIP_PLANES );
sceGuEnable( GU_TEXTURE_2D );

// 32-bit textures, assuming all are swizzled
sceGuTexMode( GU_PSM_8888, 0, 0, GU_TRUE);
sceGuTexFunc( GU_TFX_DECAL, GU_TCC_RGB ); // Modulate the color of the image
sceGuTexFilter( GU_LINEAR, GU_LINEAR ); // Linear filtering
sceGuTexScale( 1.0f, 1.0f ); // No scaling
sceGuTexOffset( 0.0f, 0.0f );
sceGuAmbientColor(0xffffffff);
sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
gumInit();

sceGuFinish();
sceDisplayWaitVblankStart();
sceGuSync(0,0);

sceGuDisplay(GU_TRUE);

The projection init: (Unsure if this is related)
Code:
static void projectionInit()
{
sceGuStart( GU_DIRECT, display_list );

// setup matrices for the triangle
sceGumMatrixMode(GU_PROJECTION);
sceGumLoadIdentity();
sceGumPerspective( 45.0f, 16.0f/9.0f, 0.8f, 100.0f);

sceGumMatrixMode(GU_VIEW);
sceGumLoadIdentity();

sceGuClearColor( GU_COLOR( 0.0f, 0.0f, 0.0f, 1.0f));
sceGuClearDepth(0);

sceGuFinish();
sceGuSync( 0, 0);
}

I haven't got code in place to grab a screenshot but if one is required I set some up and get one.

I have searched the forum and while there has been similair problems, none have been exactly the same.

Thanks.

Jono.
Logged

Good grief


Raphael
Global Moderator
Hero Member
*

Karma: +230/-10
Offline Offline

Posts: 1431
193700.11 points

View Inventory
Send Money to Raphael


View Profile WWW
« Reply #1 on: July 21, 2007, 04:55:44 AM »

Quote
sceGuDrawArray( GU_SPRITES, GU_TEXTURE_32BITF | GU_TEXTURE_32BITF | GU_TRANSFORM_2D, 2, 0, vertices);
Fixing that line should help wonders Wink
Logged

Don't push the river, it flows.
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki
http://www.homebrew-illuminati.co.uk - serious homebrew development for all platforms
Alexander Berl
"A good mod is a combination playground monitor, priest, big brother/sister, psychiatrist, professor and more."
jono
C/C++ Developer
Full Member
*

Karma: +23/-1
Offline Offline

Posts: 210
282.59 points

View Inventory
Send Money to jono


View Profile WWW
« Reply #2 on: July 21, 2007, 05:30:35 AM »

I need a punch in the head, I've been trying different states/setups and trying to ignore this problem and concentrate on other projects for about 2 weeks without a clue. Absolutly Unbelievable  Mad.

Thanks alot mate Smile.

Well now I've just got to work on getting alpha blending working and my HUD will be finished.

Jono.
« Last Edit: July 21, 2007, 06:26:36 AM by jono » Logged

Good grief
Raphael
Global Moderator
Hero Member
*

Karma: +230/-10
Offline Offline

Posts: 1431
193700.11 points

View Inventory
Send Money to Raphael


View Profile WWW
« Reply #3 on: July 21, 2007, 07:32:25 AM »

Sometimes you just can't help it and will overlook simple errors like that not matter how hard you look at the code (I have this too every so often). That's when you need someone else to take a look at the code and that's what we're here for ;P
Logged

Don't push the river, it flows.
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki
http://www.homebrew-illuminati.co.uk - serious homebrew development for all platforms
Alexander Berl
"A good mod is a combination playground monitor, priest, big brother/sister, psychiatrist, professor and more."
Vincent
Mudkips
C/C++ Developer
Hero Member
*

Karma: +76/-2
Offline Offline

Posts: 1384
9999999.99 points

View Inventory
Send Money to Vincent

Me and my 'Vette


View Profile WWW
« Reply #4 on: July 21, 2007, 12:06:13 PM »

Yeah, bro! Just happened to me with my new linked list template I've been developing. You're building a HUD huh? Sounds like a game; a cool game. Cool
Logged

Flatmush
Has a normal user title
Administrator
Hero Member
*

Karma: +84/-26
Offline Offline

Posts: 1046
12906.27 points

View Inventory
Send Money to Flatmush

The Omniscient One


View Profile WWW
« Reply #5 on: July 21, 2007, 02:55:30 PM »

I know, games with hud's pwn Smile

On a side note, why is jono not down as a C/C++ developer? He needs to join our army of pinks.
Logged

Firmware History: 2.60 -> 2.71 -> 1.50 -> 3.03oe-c

I am nerdier than 66% of all people. Are you nerdier? Click here to find out!I am 62% loser. What about you? Click here to find out!NerdTests.com User Test: The Can I Run A Business Test.

Hehe I'm a "Hero Member" because I bought posts back when they were in the shop.

Creator of FlatEditPSP, funcLib and flAstro
Insert_Witty_Name
Global Moderator
Hero Member
*

Karma: +149/-17
Offline Offline

Posts: 1602
1141.66 points

View Inventory
Send Money to Insert_Witty_Name

View Profile WWW
« Reply #6 on: July 21, 2007, 03:18:09 PM »

Agreed and done.
Logged

Coder formerly known as:

Check out my homebrew & C tutorials at http://insomniac.0x89.org
Last updated 6th Oct 06 - Tutorial 2 added.
jono
C/C++ Developer
Full Member
*

Karma: +23/-1
Offline Offline

Posts: 210
282.59 points

View Inventory
Send Money to jono


View Profile WWW
« Reply #7 on: July 21, 2007, 05:24:16 PM »

Cool, thanks for putting in a good word flatmush, I had wondered what was required to join the pinks but had never asked Smile.
Logged

Good grief
Vincent
Mudkips
C/C++ Developer
Hero Member
*

Karma: +76/-2
Offline Offline

Posts: 1384
9999999.99 points

View Inventory
Send Money to Vincent

Me and my 'Vette


View Profile WWW
« Reply #8 on: July 22, 2007, 02:29:03 AM »

Not to spam up this post, but I was asked that a couple of months ago. I went to my profile settings, but I couldn't find an option to change my position from Sr. Member to C/C++ Dev.
Logged

jono
C/C++ Developer
Full Member
*

Karma: +23/-1
Offline Offline

Posts: 210
282.59 points

View Inventory
Send Money to jono


View Profile WWW
« Reply #9 on: July 22, 2007, 05:08:26 AM »

I'm not 100% sure because I haven't payed alot of attention to that side of the forums but I believe you have to get a mod to do it. I didn't change anything myself, IWN changed mine yesterday I think.
« Last Edit: July 22, 2007, 05:11:39 AM by jono » Logged

Good grief
Insert_Witty_Name
Global Moderator
Hero Member
*

Karma: +149/-17
Offline Offline

Posts: 1602
1141.66 points

View Inventory
Send Money to Insert_Witty_Name

View Profile WWW
« Reply #10 on: July 22, 2007, 05:39:27 AM »

It just allows you to create a thread in the releases forum.
Logged

Coder formerly known as:

Check out my homebrew & C tutorials at http://insomniac.0x89.org
Last updated 6th Oct 06 - Tutorial 2 added.
Pages: [1]
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.477 seconds with 35 queries.
Sister Sites: Guitar Hero 4   BrokeniTouch.com