space_images.h has no headers in it that defines the 'Image' struct... include graphics.h.Zitat:
Zitat von BlackShark
Printable View
space_images.h has no headers in it that defines the 'Image' struct... include graphics.h.Zitat:
Zitat von BlackShark
ahh, thank you, that might be it, let me try that
I need some help getting Alpha images displayed on screen using the GU.
Here's what I'm using so far, and it's still not working.
Code:sceGuEnable(GU_BLEND);
sceGumLoadIdentity();
{
ScePspFVector3 pos = { 0.0f, 0.0f, 0.0f };
ScePspFVector3 rot = { 0.0f, 0.0f, 0.0f };
ScePspFVector3 scale = { 1.0f, 1.0f, 1.0f };
sceGumTranslate(&pos);
sceGumRotateXYZ(&rot);
sceGumScale(&scale);
}
sceGuTexMode(GU_PSM_8888,0,0,true);
sceGuTexImage(0,64,64,64,weaponHold2.sysram->data);
sceGuTexFunc(GU_TFX_BLEND,GU_TCC_RGBA);
sceGuTexFilter(GU_LINEAR,GU_LINEAR);
sceGuTexScale(1.0f,1.0f);
sceGuTexOffset(0.0f,0.0f);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
sceGumDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,2*3,0,floor_vertices);
sceGuDisable(GU_BLEND);
I don't understand? what's goin on?Code:struct Vertex __attribute__((aligned(16))) floor_vertices[2*3] =
{
{1, 0, GU_RGBA(255,255,255,255), 1, 0, 0},
{0, 0, GU_RGBA(255,255,255,255), 0, 0, 0},
{1, 1, GU_RGBA(255,255,255,255), 1, 0, 1},
{0, 1, GU_RGBA(255,255,255,255), 0, 0, 1},
{1, 1, GU_RGBA(255,255,255,255), 1, 0, 1},
{0, 0, GU_RGBA(255,255,255,255), 0, 0, 0},
};
Some help ASAP would be hugely appreciated, thanks.
edit -
Alright I've been screwing with GU_DEPTH_TEST and I have it atleast somewhat rendering properly. But the image is distorted and not displaying the way the image looks.
(Notice the ship partially behind it implying alpha is atleast sort of working?)
wait, are you trying to blit a constant 2d picture on top of the 3d scene? is so, use this function (taken from graphics.c and modded)Zitat:
Zitat von Slasher
also, you'll need to make a new texture class/struct or modify your current one to fit this one.Code:void guDisplayImage(int sx, int sy, int width, int height, Texture* source, int dx, int dy) {
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
sceGuTexMode(GU_PSM_8888, 0, 0, 1);
sceGuTexFilter(GU_NEAREST,GU_NEAREST);
sceGuTexWrap(GU_CLAMP, GU_CLAMP);
sceGuAmbientColor(0xffffffff);
sceGuEnable(GU_TEXTURE_2D);
//sceGuEnable(GU_BLEND);
sceGuDisable(GU_DEPTH_TEST);
sceGuTexImage(0, source->textureWidth, source->textureHeight, source->textureWidth, (void*) source->data);
float j = 0.0f;
while (j < width) {
ModelVertexTV* vertices = (ModelVertexTV*) sceGuGetMemory(2 * sizeof(ModelVertexTV));
float sliceWidth = 64.0f;
if (j + sliceWidth > width) sliceWidth = width - j;
vertices[0].u = sx + j;
vertices[0].v = sy;
vertices[0].x = dx + j;
vertices[0].y = dy;
vertices[0].z = 0;
vertices[1].u = sx + j + sliceWidth;
vertices[1].v = sy + height;
vertices[1].x = dx + j + sliceWidth;
vertices[1].y = dy + height;
vertices[1].z = 0;
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, 0, vertices);
j += sliceWidth;
}
sceGuDisable(GU_TEXTURE_2D);
//sceGuDisable(GU_BLEND);
sceGuEnable(GU_DEPTH_TEST);
}
if im wayy off mark, let me know :p
Uhm, not quite, although your function does help lol.
My goal is to set an image right into my vertices struct so I can alter it as needed.
Here's a screenshot of it without the alpha
wait, isnt the A in your vertices struct supposed to be 0 for full transparency?
try replacing ur verticies with this:
Code:struct Vertex __attribute__((aligned(16))) floor_vertices[6] =
{
{1, 0, GU_RGBA(255,255,255,0), 1, 0, 0},
{0, 0, GU_RGBA(255,255,255,0), 0, 0, 0},
{1, 1, GU_RGBA(255,255,255,0), 1, 0, 1},
{0, 1, GU_RGBA(255,255,255,0), 0, 0, 1},
{1, 1, GU_RGBA(255,255,255,0), 1, 0, 1},
{0, 0, GU_RGBA(255,255,255,0), 0, 0, 0},
};
Is there any easier way to check if a folder exists, I'm currently using...
-AuraCode:SceIoDirent dirent;
memset(&dirent, 0, sizeof(SceIoDirent));
SceUID dirId = sceIoDopen(bpath);
if(dirId<0)// error message
If the directory didnt exist, it would obviously return -1. I don't think theres an easier way of doing this, you could impliment this into a function for easier use i suppose.Zitat:
Zitat von Auraomega
two lines of code and you want it easier??? lol
Use sceIoGetstat()
And, uh, it would return an 800xxxxx error, not -1.
oppsih... i can say i never knew that, you learn something new every day :tup:Zitat:
Zitat von Archaemic
@JaSo:
its actually in header file:
Code:/**
* Open a directory
*
* @par Example:
* @code
* int dfd;
* dfd = sceIoDopen("device:/");
* if(dfd >= 0)
* { Do something with the file descriptor }
* @endcode
* @param dirname - The directory to open for reading.
* @return If >= 0 then a valid file descriptor, otherwise a Sony error code.
*/
SceUID sceIoDopen(const char *dirname);
Ok, more dirents questions... How would I go about deleting and renaming a directory... Can I just use sceIoRename to rename, or does that only work with files?
Currently, I've tried to remove a directory unsuccesfully using...
what am I doing wrong?Code:int checkfile = sceIoRemove(bpath);
printf("%d : checkfile\n", checkfile);
if(checkfile<0)
{
checkfile = sceIoRmdir(bpath);
printf("%d : checkfile\n", checkfile);
}
-Aura
Can somebody here tell me how to load a font in OSLIB. Of course I've already read and re-read the manual, and am using the normal code to load the fontTurns out that never happens, it loads something very strage, and unreadable.Code:oslLoadFontFile
I've created the font with the tool provided to do so, and even got a font file from the samples, but nothing works here. I'm sure there should be something else, or even an easier way to load fonts. I've tried some examples I found here, but they don't seem to work very well. :Argh:
Can somebody help me with that?
Cheers
how do i read an integer from a txt file? like say that txt file contains the number "3" how would i read that, and manipulate/compare that number with my program?
Depends. You could use getc to read 1 byte from the file (the number 3), then you could go several ways about it.Zitat:
Zitat von BlackShark
You could create a string to int function. It converts the string to an integer up until a non-digit is found.
UseageCode:int str2int(char* byte)
{
int retval = 0;
for(;*byte >= '0' && *byte <='9';byte++)
retval = retval*10 + *byte-'0';
return retval;
}
Prints out the number 34992Code:int x = str2int("34992");
printf("%d",x);
Moca: I think you misunderstood his question. You're demonstrating how to withdraw an int value from a string. He's asking how to get it from a file.
I haven't done much PSP development, especially not for a long time, but with STL (Standard Template Library, basically the standard libraries that most compilers use), you would set up an fstream. Set up an fstream object, use its open() method to open up the file, and use its getline() method to get a line of text from a file. You would parse that string in a way similar to what Moca described. Reference for fstream: http://www.cplusplus.com/reference/iostream/fstream/Zitat:
Zitat von BlackShark
Example:
Code:fstream stream;
string buffer;
stream.open("filename.txt");
stream.getline(buffer, 300); // change 300 to the maximum number of characters you want to read from the line
// extract that int from the buffer, the entire line will at this point be stored in buffer
stream.close();
what im trying to do is read the high score, so the number on the text changes, what im trying to do is, when a person dies, the program compares his/her score to the highscore(number in txt file) and sees if it saves the score as the new high score or not. im not sure that would work for this, as the high score changes.
This is assuming that you are storing the highscore in a file by itself, with no other data in that file.Zitat:
Zitat von BlackShark
You can try other method's of course <_<Code:int fsize(FILE* fd)
{
int size;
fseek(fd,0,2);
size = ftell(fd);
fseek(fd,0,0);
return size;
}
int str2int(char* byte)
{
int retval = 0;
int compl = 0;
for(;*byte >= '0' && *byte <='9';byte++)
retval = retval*10 + *byte-'0';
return retval;
}
void scorecmp(int current_score)
{
int last_score;
FILE* fd = fopen("high_score.txt","rb");
u32 filesize = fsize(fd);
char* buffer = (char*)malloc(filesize + 1);
fread(&buffer,1,filesize,fd);
last_score = str2int(buffer);
if(last_score > current_score) ; // do nothing
else if(current_score > last_score)
save_high(current_score); // function to save high score.
else ; // They are equal. DO whatever you want.
free(buffer);
}
There's lots of different ways to do this. One is (assuming score is an int of the current score):
I think that should work; haven't tested it though.Code:FILE* file = fopen("highscore.txt","r+");
char scoretext[10];
fgets(scoretext,10,file);
int oldscore;
sscanf(line,"%d",&oldscore);
if (score > oldscore) {
sprintf(scoretext,"%d",score);
fseek(file,0,SEEK_SET);
fputs(scoretext,file);
}
fclose(file);
" how would i read that, and manipulate/compare that number with my program?"Zitat:
Zitat von Josh1billion
Thats why I offered a string to integer function. He would read the value from the file, then turn it into a number so he can compare it with a variable in his program.
Thank you very much guys, ill try out the two ways, this helps alot!
I've created a menu, but it isn't working ...
Spoiler for Main.c:
It only shows "Error.." :Argh:
1 you dont init your graphical functions
2 you can't call the main function
3. You have to redraw the menu after every loop.
4. That last 'else printf("Error")' shouldn't be there. You're saying that there's an error whenever the arrow is between 65 and 95. That makes no sense at all.
also:
#define White RGB(0, 0, 0)
#define Black RGB(255, 255, 255)
white is 255 255 255
and
black is 0 0 0
.....
LoL it looks like I made allot of stupid mistakes .. :ROFL:
I've fixed them all.. but menu isn't working (I don't see anything:S) The Up/Down does work!:Jump:
New Code (MakeFile hasn't been changed)
Spoiler for Code:
Can someone please compile its.. because maby my Cygwin is f*cked-up.. :o
Can somebody here tell me how to load a font in OSLIB. Of course I've already read and re-read the manual, and am using the normal code to load the fontTurns out that never happens, it loads something very strage, and unreadable.Code:oslLoadFontFile
I've created the font with the tool provided to do so, and even got a font file from the samples, but nothing works here. I'm sure there should be something else, or even an easier way to load fonts. I've tried some examples I found here, but they don't seem to work very well. :Argh:
Can somebody help me with that?
Cheers
Are there any tutorials or samples on working with WiFi in C (on the PSP)?
From connecting to an IP till receiving/sending (the) data from/to it?
Yes, there are.
X:/cygwin/usr/local/pspdev/psp/sdk/samples
I already knew about those, but it only covers the very basic things like checking if the WLAN switch is on, or reading the MAC address. I mean samples/tutorials for connecting to an IP and receiving data from it.Zitat:
Zitat von Judas
http://xs119.xs.to/xs119/07386/yesh.png.xs.jpg
Check psp-programming.com, or search google. There's none that I know of.
Alright, thanks anyway ;)Zitat:
Zitat von Judas
Anyone?
Zitat:
Zitat von Auraomega
Code:/**
* Remove a directory file
*
* @param path - Removes a directory file pointed by the string path
* @return Returns the value 0 if its succesful otherwise -1
*/
int sceIoRmdir(const char *path);
I don't believe that sceIoRmdir works if the directory has files inside of it...so do a recursive open directory, delete contents, delete directory routine.
It is the same for the PSP, Linux, and Windows. There are no specific PSP differences when working with sockets. The only differences you may encounter, are which header files to include. I'd be willing to write a tutorial though, if people are interested.Zitat:
Zitat von DarkSeveN
That would be great :tup: Even though I found a few samples now, it might be better and easier to understand then what I'm now at. For some reason my PSP now just shows a black screen and freezes whenever I launch the homebrew (after adding some parts from the sample) so a tutorial would really be appreciated, by me at least :) (copying parts from samples always kills my homebrew, for some reason, even though it are very basic functions that should work everywhere, lol)Zitat:
Zitat von _dysfunctional
My current code tries to delete like its a file, if it is unsuccessful, then it tries to delete like a directory, my code uses sceIoRmdir, so that wasn't really helpful...Zitat:
Zitat von Judas
Thanks, thinking about it, it does seem the most likely option.Zitat:
Zitat von Archaemic
@_dysfunctional:
A tutorial/guide would be really helpful for anyone who wants to do more advanced WiFi
-Aura
Don't know if you found an answer, but use atoi(). This converts a string to an integer. Use it like this:Zitat:
Zitat von BlackShark
Code:#include <string.h>
....
fread(buffer,1,1,file);
int highscore = atoi(buffer);