simple gu question
simple gu question
this is the first time i'm trying to use psp internal gu library.
the question is: how can i draw a line from let's say (10,20) to (400, 220), specifing the cordinates in pixels and working in 2D (for now)?
i think that i should use
sceGuDrawArray
with as first argument GU_LINES, but i don't know much more...
any help?
thanks
the question is: how can i draw a line from let's say (10,20) to (400, 220), specifing the cordinates in pixels and working in 2D (for now)?
i think that i should use
sceGuDrawArray
with as first argument GU_LINES, but i don't know much more...
any help?
thanks
Ciao! from Italy
You're on the right track. To draw the line in your example, you need something like this:
This will allocate the memory for the endpoints and draw the line in the current color (set by sceGuColor).
Code: Select all
typedef struct { float x, y, z; } vType;
vType *vert = (vType *)sceGuGetMemory(2 * sizeof(vType));
vert[0].x = 10; vert[0].y = 20; vert[0].z = 0;
vert[1].x = 400; vert[1].y = 220; vert[1].z = 0;
sceGuDrawArray(GU_LINES, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, 0, vert);
"You hungry? I haven't eaten since later this afternoon."
oh thanks, except for
typedef struct { float x, y, z; } vType;
has this to be called in the main loop?
EDIT: i cannot make it work..
the problem is with
sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
that is called in the init gu function.
if i comment these lines out, i can se perfectely the line but strings written by intrafont are messed up. with these lines "active" the texts rendered by intrafont are ok, but the line is not there on the screen!
EDIT2:
another question.
how to use GU_LINE_STRIP to draw a line by specifting first two vertices and than only one? for example how to draw this array?
vert[0].x = 10; vert[0].y = 20; vert[0].z = 0;
vert[1].x = 400; vert[1].y = 220; vert[1].z = 0;
vert[2].x = 100; vert[2].y = 120; vert[2].z = 0;
is the array correct? or should it be written in another way?
typedef struct { float x, y, z; } vType;
has this to be called in the main loop?
EDIT: i cannot make it work..
the problem is with
sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
that is called in the init gu function.
if i comment these lines out, i can se perfectely the line but strings written by intrafont are messed up. with these lines "active" the texts rendered by intrafont are ok, but the line is not there on the screen!
EDIT2:
another question.
how to use GU_LINE_STRIP to draw a line by specifting first two vertices and than only one? for example how to draw this array?
vert[0].x = 10; vert[0].y = 20; vert[0].z = 0;
vert[1].x = 400; vert[1].y = 220; vert[1].z = 0;
vert[2].x = 100; vert[2].y = 120; vert[2].z = 0;
is the array correct? or should it be written in another way?
Ciao! from Italy
-
- Posts: 87
- Joined: Thu Oct 01, 2009 8:43 pm
Hi maybe you need to set the alpha check function:
Using intrafont you should set the following after writing your string to restore your current GU behavior (this was my finding):
regards
Code: Select all
sceGuEnable(GU_ALPHA_TEST);
sceGuAlphaFunc(GU_GREATER, 0, 0xff);
Code: Select all
sceGuTexFilter(GU_NEAREST, GU_NEAREST);
sceGuTexMode(GU_PSM_8888, 0, 0, 0);
sceGuDisable(GU_BLEND);
-
- Posts: 87
- Joined: Thu Oct 01, 2009 8:43 pm
Hi,
I've wrapped the intraFont in a texthelper class to use it properbly in my GU developments. The Output-Method looks like following:
Hope this helps
I've wrapped the intraFont in a texthelper class to use it properbly in my GU developments. The Output-Method looks like following:
Code: Select all
void clTextHelper::writeText(fontType ft, const char *text, short tx, short ty){
//assuming sceGuSart was already called ...
sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
intraFontPrint(font[ft], tx, ty, text);
//intraFont call does destroy the kind of texture handle
//restore is needed:
sceGuTexFilter(GU_NEAREST, GU_NEAREST);
sceGuTexMode(GU_PSM_8888, 0, 0, 0);
sceGuDisable(GU_BLEND);
}
thanks for that but i cannot make transparency work...
when i insert
in the initialization function, the only thing that gets drawed is the intrafont strings, everything else (lines and poligons) are invisible, regardless the alpha value..
EDIT: when an utility dialog is running on the screen (like msg dialog) the alpha works correctely
when i insert
Code: Select all
sceGuAlphaFunc(GU_GREATER, 0, 0xFF);
sceGuEnable(GU_ALPHA_TEST);
EDIT: when an utility dialog is running on the screen (like msg dialog) the alpha works correctely
Ciao! from Italy
-
- Posts: 87
- Joined: Thu Oct 01, 2009 8:43 pm
Hmm...
could you try to add a color component to your vertice like:
setting up your vertices with color = 0xffffffff; which should make them white.
However, if the string is written to the screen than Alpha blending works for them as this library uses alphablending to have a bit of transparency between the letters ;o)
change the drawing call to :
Regards
could you try to add a color component to your vertice like:
Code: Select all
typedef struct { int color;float x, y, z; } vType;
However, if the string is written to the screen than Alpha blending works for them as this library uses alphablending to have a bit of transparency between the letters ;o)
change the drawing call to :
Code: Select all
sceGuDrawArray(GU_LINES, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, 0, vert);