yep what i wanted thanks
Printable View
yep what i wanted thanks
For reference, in C++ it be:
Code:void function( int & aInt )
{
aInt = 6;
}
// use
int blah = 4;
function(blah);
I have seen some use int& as well as int &aInt --- which one does it refer to?Zitat:
Zitat von yaustar
The error means you tried to initialize the variable in an impossible way, ie you had the variable global (outside of a function scope). You cannot call functions outside of a function scope.Zitat:
Zitat von myschoo
Doesn't matter, they are both the same:Zitat:
Zitat von Mr305
Code:int& aInt
// is the same as
int &aInt
// and
int & aInt
ok i solved it like this:
in the begginning i have:
int bat;
and later in main:
bat = scePowerGetBatteryLfePerc ent();
Is it harmful or potentially flawed?Code:void sayHellow0rld(const char varname[])
Becz ever since I changed it to char varname[100], everything is very very stable...
Can be very harmful. Buffer overruns is going to be the biggest problem.Zitat:
Zitat von Mr305
The first one or the one I fixed [it isn't going to be >100 for sure] ?Zitat:
Zitat von yaustar
Suppose, for the first one:
If first a char array of length 3 is passed ... Then char array of length 6 passed.. Would allocation be done?
not really flawed. In C++, if you pass a 1D array to a funcion, you don't have to tell it the size of the array you are passing.Zitat:
Zitat von Mr305
As yaustar mentioned, it can cause overflows if you start trying an array that is bigger than 100 chars. Check if you are trying to change something in the array, as delcaring the array as const means that you only get read access to the array, whereas with char varname[100] you obviously get access, so maybe your trying to change something somewhere.
how do i use printTextScreen() to print out a variable?
I want to display a score from a variable to a specific area on the screen.
I HIGHLY recommend www.cprogramming.com
--
use sprintf.
sprintf? ok...
yes, i do use that website, but i'm not sure whats different for psp. there is a lot that is changed.
Yeah, i figured out sprintf now.
i'm writing a prx using dsxlib, its a nice looking vsh extender. I'm trying to bring all the functions of other prxs screenshot, homebrew launching, brightness, cpu speed etc into one package.
my problem is this, i've just noticed the music, video and web browser freeze up when its launched. Would lowering the thread priority have an effect on these freezes. Does anybody know why this is happening:PC:
Please guys could someone help me out.
post or just send me a pm
-> Keep Arrays/any sizes as small as possible.Zitat:
Zitat von brethren
-> Put up a small delay at the end of the loop
-> 1 Thread's enough.
That's I cud think of...
Zitat:
Zitat von Mr305
sorry, im still a n00b at this.
google psp sdk documentation. also www.psp-programming.com - great resourceZitat:
Zitat von Nicko01
Are there draw commands in C/C++? I want to draw a line from one coordinate to another on my psp, but I have no idea how to do it without using ascii.
In particular, I'm looking for line drawing in particular colors, if there is a fill command, and draw polygon command.
And how do I use the trig commands like arctan?
i know psp-programming.com....
i'm using pspjunkies dsxlib to make a prx, i've solved the last problem i had (further up the page) but i need a bit more help. Sometimes the menu i display in the vsh flickers (usually when a umd is being read or i underclock) is there anyway to stop this flickering.
lesson4 graphics.c.Zitat:
Zitat von zwnage
math.h
lesson 4? The simple image processing tutorial? But that refers to displaying a picture, I did not see any instance of line drawing commands in the tutorial.Zitat:
Zitat von Mr305
EDIT: Ooops, my bad. I just looked though graphics.c and found it.
Now how about a draw polygon command? fill command?
i dont remmbr, its there tooZitat:
Zitat von zwnage
Thanks for the help :) .
Now is there a way to fill the polygon with a color?
You need to understand how slow and basic graphics library is. But, you could make a draw polygon command
That should draw a white, closed square with an area of 25 in the center of the screen, not filledCode:typedef struct Point {
int x,y;
} Point;
inline void drawPolygon(int x, int y, const Point *points, const Color color, const bool closed) {
for(int i=0; i<sizeof(points); i++) {
drawLine(x + points[i].x, y + points[i].y,
x + ((closed && i==sizeof(points)-1) ? points[0].x : points[i+1].x),
y + ((closed && i==sizeof(points)-1) ? points[0].y : points[i+1].y),
color);
}
// usage:
Point square[4] = { {-5,5}, {5,5}, {5,-5}. {-5,-5} }
drawPolygon(237,133,square,RGB(255,255,255), true);
I believe drawLine is the function name, and those are it's parameters?
Code:typedef struct
{
float x, y, z;
} DSX2DVERTEX;
void dsxDrawLine(float x1, float y1, float x2, float y2, Color color)
{
DSX2DVERTEX* src = (DSX2DVERTEX*) sceGuGetMemory(sizeof(DSX2DVERTEX) * 2);
src[0].x = x1;
src[0].y = y1;
src[0].z = 0.0f;
src[1].x = x2;
src[1].y = y2;
src[1].z = 0.0f;
sceGuColor(color);
sceGuDisable(GU_TEXTURE_2D);
sceGuShadeModel(GU_FLAT);
sceGuDrawArray(GU_LINES, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, 0, src);
sceGuShadeModel(GU_SMOOTH);
sceGuEnable(GU_TEXTURE_2D);
}
void dsxDrawRectangleFilled(float x, float y, float w, float h, Color color)
{
DSX2DVERTEX* src = (DSX2DVERTEX*) sceGuGetMemory(sizeof(DSX2DVERTEX) * 2);
src[0].x = x;
src[0].y = y;
src[0].z = 0.0f;
src[1].x = x + w;
src[1].y = y + h;
src[1].z = 0.0f;
sceGuColor(color);
sceGuDisable(GU_TEXTURE_2D);
sceGuShadeModel(GU_FLAT);
sceGuDrawArray(GU_SPRITES, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, 0, src);
sceGuShadeModel(GU_SMOOTH);
sceGuEnable(GU_TEXTURE_2D);
}
void dsxDrawRectangleOutlined(float x, float y, float w, float h, Color color)
{
DSX2DVERTEX* src = (DSX2DVERTEX*) sceGuGetMemory(sizeof(DSX2DVERTEX) * 3);
DSX2DVERTEX* src2 = (DSX2DVERTEX*) sceGuGetMemory(sizeof(DSX2DVERTEX) * 3);
src[0].x = x;
src[0].y = y;
src[0].z = 0.0f;
src[1].x = x + w;
src[1].y = y;
src[1].z = 0.0f;
src[2].x = x + w;
src[2].y = y + h;
src[2].z = 0.0f;
src2[0].x = x;
src2[0].y = y;
src2[0].z = 0.0f;
src2[1].x = x;
src2[1].y = y + h;
src2[1].z = 0.0f;
src2[2].x = x + w + 1.0f;
src2[2].y = y + h;
src2[2].z = 0.0f;
sceGuColor(color);
sceGuDisable(GU_TEXTURE_2D);
sceGuShadeModel(GU_FLAT);
sceGuDrawArray(GU_LINE_STRIP, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 3, 0, src2);
sceGuDrawArray(GU_LINE_STRIP, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 3, 0, src);
sceGuShadeModel(GU_SMOOTH);
sceGuEnable(GU_TEXTURE_2D);
}
void dsxDrawCircleFilled(float x, float y, float radius, u32 numSteps, Color color)
{
if(radius <= 0)
{
return;
}
if(numSteps < 1)
{
numSteps = 1;
}
numSteps = radius * 400;
float stepSize = (2 * GU_PI) / (numSteps * 4);
DSX2DVERTEX* vertices = (DSX2DVERTEX*) sceGuGetMemory((numSteps * 4 + 2) * sizeof(DSX2DVERTEX));
vertices[0].x = x;
vertices[0].y = y;
vertices[0].z = 0.0f;
int step;
u32 numSteps2 = numSteps * 2, numSteps3 = numSteps * 3;
float angle = 0;
for(step = 1; step < numSteps + 1; step++)
{
float s = sinf(angle) * radius;
float c = cosf(angle) * radius;
angle += stepSize;
vertices[step].x = x + s;
vertices[step].y = y + c;
vertices[step].z = 0.0f;
vertices[step + numSteps].x = x + c;
vertices[step + numSteps].y = y - s;
vertices[step + numSteps].z = 0.0f;
vertices[step + numSteps2].x = x - s;
vertices[step + numSteps2].y = y - c;
vertices[step + numSteps2].z = 0.0f;
vertices[step + numSteps3].x = x - c;
vertices[step + numSteps3].y = y + s;
vertices[step + numSteps3].z = 0.0f;
}
vertices[numSteps * 4 + 1].x = vertices[1].x;
vertices[numSteps * 4 + 1].y = vertices[1].y;
vertices[numSteps * 4 + 1].z = 0.0f;
sceGuColor(color);
sceGuDisable(GU_TEXTURE_2D);
sceGuShadeModel(GU_FLAT);
sceGuDrawArray(GU_TRIANGLE_FAN, GU_VERTEX_32BITF | GU_TRANSFORM_2D, numSteps * 4 + 2, 0, vertices);
sceGuShadeModel(GU_SMOOTH);
sceGuEnable(GU_TEXTURE_2D);
}
void dsxDrawCircleOutlined(float x, float y, float radius, u32 numSteps, Color color)
{
if (radius <= 0)
{
return;
}
if (numSteps < 1)
{
numSteps = 1;
}
if(numSteps == 0)
{
//use preset value
numSteps = radius * 400;
}
float stepSize = (2 * GU_PI) / (numSteps * 4);
DSX2DVERTEX* vertices = (DSX2DVERTEX*) sceGuGetMemory((numSteps * 4 + 1) * sizeof(DSX2DVERTEX));
int step;
u32 numSteps2 = numSteps * 2, numSteps3 = numSteps * 3;
float angle = 0;
for(step = 0; step < numSteps; step++)
{
float s = sinf(angle) * radius;
float c = cosf(angle) * radius;
angle += stepSize;
vertices[step].x = x + s;
vertices[step].y = y + c;
vertices[step].z = 0.0f;
vertices[step + numSteps].x = x + c;
vertices[step + numSteps].y = y - s;
vertices[step + numSteps].z = 0.0f;
vertices[step + numSteps2].x = x - s;
vertices[step + numSteps2].y = y - c;
vertices[step + numSteps2].z = 0.0f;
vertices[step + numSteps3].x = x - c;
vertices[step + numSteps3].y = y + s;
vertices[step + numSteps3].z = 0.0f;
}
vertices[numSteps * 4].x = vertices[0].x;
vertices[numSteps * 4].y = vertices[0].y;
vertices[numSteps * 4].z = 0.0f;
sceGuColor(color);
sceGuDisable(GU_TEXTURE_2D);
sceGuShadeModel(GU_FLAT);
sceGuDrawArray(GU_LINE_STRIP, GU_VERTEX_32BITF | GU_TRANSFORM_2D, numSteps * 4 + 1, 0, vertices);
sceGuShadeModel(GU_SMOOTH);
sceGuEnable(GU_TEXTURE_2D);
}
May I ask you why there is a large, ~25 line gap between the last } and the bottom of the code block? Forum bug I hope (or do you add a bunch of returns once you finish a source file (eww))
I don't see a gap.
Perhaps it's your browser? (I'm on Firefox).
I've been doing all my testing in iRShell for various reasons (one being I can't get PSPlink to work), and after completing my first quest, I decided to try it properly on the PSP...
Where on iRShell buttons are accepted, when run alone, I can only get buttons in the main thread to be recognised, and not from any other threads... this is obviously proving a problem...
I've had to NULL the buffer after pritty much every button press due to it going mental when you press a button (it does that thing many times before it stops)...
Any help would be greatly welcome as its the only thing stopping me finishing off the rest of my quests :Argh:
Thanks
-Aura
Excuse me while I shoot myself... solved the problem :p
Just for the record...I'm seeing a massive gap... and I'm on Opera...Zitat:
I don't see a gap.
Perhaps it's your browser? (I'm on Firefox).
Hi guys!
Just a lil' question : To get the color of a pixel, I use GetPixelScreen(int x, int y), but can I use this function or an other to get the color of a pixel of a picture that is NOT blitted on screen?