Thanks auraomego, I thought in IntraFont, and I do some samples with him, but I can do a menu with him, It blink and I can't show a nice menu with Intrafont, I will use the Gu or graphics lib(Or trying it :P )
Printable View
Hi,
Does anybody know how to draw a rectangle through the PSP GU?
(Without using graphics.c etc.)
Ty:tup:
Theres some pretty good tutorials on PSP-Programming.com, heres a list of them. And a direct link to the polygon tutorial.
Some of the links are dead, but from what I can see the GU tutorials all work fine bar no images. They are based off of the NeHe tutorials, so if theres a missing file, check on there and see if the file exists under a similar lesson.
-Aura
Well.. I do my own "sample" of Intrafont, I just printf an image, and then, I write with intrafont in the screen, but de image, blink :/ xD. This is my sample, Can you learn me how I can do it without blink?
Sorry for my bad english, I'm spanish...Code:#include <pspkernel.h>
#include <pspgu.h>
#include <pspgum.h>
#include <pspdisplay.h>
#include <png.h>
#include "graphics.h"
#include "intraFont.h"
PSP_MODULE_INFO("Sample Intrafont by Recse", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
static int running = 1;
int exit_callback(int arg1, int arg2, void *common)
{
running=0;
sceKernelExitGame();
return 0;
}
int CallbackThread(SceSize args, void *argp)
{
int cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void)
{
int thid = sceKernelCreateThread("CallbackThread", CallbackThread, 0x11, 0xFA0, PSP_THREAD_ATTR_USER, 0);
if (thid >= 0) sceKernelStartThread(thid, 0, 0);
return thid;
}
int main()
{
char buffer[200];
Image* Menu;
intraFont* ltn0;
pspDebugScreenInit();
initGraphics();
intraFontInit();
SetupCallbacks();
ltn0=intraFontLoad("flash0:/font/ltn0.pgf",0);
sprintf(buffer, "Imagen.png");
Menu = loadImage(buffer);
blitAlphaImageToScreen(0 ,0 ,480 , 272, Menu, 0, 0);
while(1)
{
guStart();
sceGuTexMode(GU_PSM_8888,0,0,GU_TRUE);
intraFontSetStyle(ltn0, 1.0f,0xff78e7e8,0x96000000,INTRAFONT_ALIGN_CENTER);
intraFontPrint(ltn0, 240, 45,"Zample IntraFont, By (gladii :P)");
sceGuFinish();
sceGuSync(0,0);
sceDisplayWaitVblankStart();
flipScreen();
}
intraFontUnload(ltn0);
intraFontShutdown();
return 0;
}
Gladiator: You're blitting the image outside of the while loop, thus it only gets called once. Put the image blitting function in the while loop.
In what Position I must put it in the while loop?
First off, change:
to:Code:sprintf(buffer, "Imagen.png");
Menu = loadImage(buffer);
Theres no need to use a buffer...Code:Menu = loadImage("Imagen.png");
Also, you're code could do with some tidying, keep a check on my sig, I'll be adding a nice link on how to format code to make it readable.Code:
while(1)
{
blitAlphaImageToScreen(0 ,0 ,480 , 272, Menu, 0, 0);
guStart();
sceGuTexMode(GU_PSM_8888,0,0,GU_TRUE);
intraFontSetStyle(ltn0, 1.0f,0xff78e7e8,0x96000000,INTRAFONT_ALIGN_CENTER);
intraFontPrint(ltn0, 240, 45,"Zample IntraFont, By (gladii :P)");
sceGuFinish();
sceGuSync(0,0);
sceDisplayWaitVblankStart();
flipScreen();
}
intraFontUnload(ltn0);
intraFontShutdown();
return 0;
}
Can someone help me with a peice of code? I'm trying to read a file and remove all the returns and \s, my code so far is:
except its not quite working with '\n'.Code:c = fgetc(fp);
for(int loop = 0; c != EOF; loop++)
{
if((c != '\n') && (c != '\\'))
{
buffer[loop] = c;
}
c = fgetc(fp);
}
-Aura
Okay, I do it, I remove sprintf, change loadImage(buffer); by loadImage("imagen.png"); and I put blitImage in the beginning of while loop, the psp return me this:
rcalero. net /images /ba6b3d731d .bmp
I'm not sure I follow.
Also, I should probably mention I've never used the GU and graphics.c together, and I can't say its advisable either, it'll probably create more problems than it'll solve.
-Aura
Looks fine to me. What's the not quite bit? Note that when fp is opened in binary mode, different platforms offer different line endings. Under *nix a '\n' is sufficient. Under win32 you may want to remove '\r' as well. Just guessing here (maybe you actually want to remove line endings), but this code definitely removes '\n' and '\'.
I didn't know about the \r, which was one of the problems, the other which was noticed by someone else is that I was incrementing loop every time, even if nothing was added to the buffer.
Fixed code is:
Thanks though, the \r I would never have known.Code:c = fgetc(fp);
for(int loop = 0; c != EOF;)
{
if((c != '\n') && (c != '\\') && (c != '\r'))
{
buffer[loop++] = c;
}
c = fgetc(fp);
}
-Aura
Hi. I was wonder if there was a way to manipulate the screen display, and to turn off the screen in user mode?
I know it's possible in kernel mode.
I can't even find a function to turn the screen off (other than lowering the brightness to 0). I doubt theres any other way, but just to make sure, you know how to wrap a kernel function and call it from a user mode application right?
-Aura
No, but I'd really appreciate an example. :)
The best example I can offer is in the 4.01M33 SDK. The example is with the shell, the rDriver is a kernel wrapper which you link (using a stub file) and then load the functions in user mode. Take a look at that and if that doesn't help much, I'll see if I can fish out some of my old Project4 code... but its not very tidy as it was a one-man program :p
-Aura
What do you mean 4.01 M33 SDK?
Download the 4.01M33 installer, inside theres a folder called SDK, thats got some libraries M33 created which allows for some kernel functions to be called in user mode (the kernel wrappers are loaded by default in the flash). Theres also a folder with the headers, and finally one with the source code in for compiling the shell. Its basic, but does the job teaching what needs to be done.
-Aura
Oh wow. Thanks, I'll check this out right now.
So kubridge.h is what I'm looking for.
SceUID kuKernelLoadModule()
I'm not sure how to use it though.
I need to load a module with it, so do I write my plugin with kernel functions, then load it with this?
Basically, you write 2 modules:
Module 1:
Kernel - 0x1000
Contains all kernel functions
Compile a stub (.s) file with all functions to link to in the main application.
Create a header file to link functions to main application.
Module 2:
User/update - 0x0000/0x0800
Contains all user functions, and kernel wrappers from module 1
Link the stub file into the makefile like any other C/++ file.
Link the header into the source that calls on those functions.
Load the module at the start (checking for errors).
Run the wrapped functions in place of the kernel ones.
A word of advice, create a checkFunc function, just to make sure linking has worked correctly:
then when you load the module, run checkFunc, and see if it returns 0x5034, if it returns <0 then an error has occured, it if returns 0x5034 then linking has worked correctly.Code:int checkFunc()
{
return 0x5034;
}
...0x5034 only has value to me, you can use whatever you like above 0. (0x5034 = P4 in ascii).
-Aura
Is there any way I can create a temp file that exists only in RAM? I looked at tmpnam function, but I'm wondering if it creates a copy on the device. I'm trying to create an OTP system before I move on to something else and specifically need no data to be written before the encryption or after the decryption, but I want to be able to launch the decrypted file in whatever application it should be launched from.
The late binding goes in the exports file correct? Just to make sure, it goes something like this:
or does it go with syslib?Code:PSP_EXPORT_START(STUBNAME, 0, 0x4009)
-Aura
Edit:
Just wrote a test to confirm what I previously thought about tmpnam. Ran the program, paused, remove my SD card, continued the application and it gave me errors that the volume doesn't exist. I need a method that means the plain text files only exists in RAM and never get written to the drive.
I did have the thought though that it might just have to believe that its writing to the SD card to exist, so if anyone could confirm this I'd be happy, if not is there any cross platform libraries that do supply this ability?
Just keep a buffer in ram, modify it to your liking, then when you need to save it, just write the whole thing to the memory card.
Hi I followed: http://www.psp-programming.com/code/...heport-lesson1
But it doesn't seem to work :Cry:
http://pastebin.com/m4741ad73
@_dysfunctional:
I want to be able to open the document in other programs though, such as a text editor or image viewer, something like that so a temp file seemed best. Either way I found a method using ramfs on Linux.
@basfreak:
Two problems I noticed, one, your makefile is building an elf, you want a prx, use BUILD_PRX = 1. The second is building a prx gives you 32kb of heap, not enough to run a program like this. The HEAP_SIZE_KB macro will fix this, just give yourself a few mb and you should be good to go.
-Aura
Still only displays:
FPS: 1578
till
FPS: 1580
:(
Code:#include "main.h"
PSP_MODULE_INFO("Lesson1", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
PSP_HEAP_SIZE_KB(20480);
void *dList; // display List, used by sceGUStart
void *fbp0; // frame buffer
int fps = 0; // for calculating the frames per second
char fpsDisplay[100];
u32 tickResolution;
u64 fpsTickNow;
u64 fpsTickLast;
Vertex __attribute__((aligned(16))) triangle[3] =
{
{ GU_COLOR( 1.0f, 1.0f, 1.0f, 0.0f ), 0.0f, 1.0f, 0.0f }, // top point
{ GU_COLOR( 1.0f, 1.0f, 1.0f, 0.0f ), 1.0f,-1.0f, 0.0f }, // left point
{ GU_COLOR( 1.0f, 1.0f, 1.0f, 0.0f ),-1.0f,-1.0f, 0.0f } // right point
};
Vertex __attribute__((aligned(16))) quad[4] =
{
{ GU_COLOR( 1.0f, 1.0f, 1.0f, 0.0f ),-1.0f, 1.0f, 0.0f }, // top-left point
{ GU_COLOR( 1.0f, 1.0f, 1.0f, 0.0f ), 1.0f, 1.0f, 0.0f }, // top-right point
{ GU_COLOR( 1.0f, 1.0f, 1.0f, 0.0f ),-1.0f,-1.0f, 0.0f }, // bottom-left point
{ GU_COLOR( 1.0f, 1.0f, 1.0f, 0.0f ), 1.0f,-1.0f, 0.0f } // bottom-right point
};
void FPS( void )
{
fps++;
sceRtcGetCurrentTick( &fpsTickNow );
if( ((fpsTickNow - fpsTickLast)/((float)tickResolution)) >= 1.0f )
{
fpsTickLast = fpsTickNow;
sprintf( fpsDisplay, "FPS: %d", 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 );
sceGuShadeModel( GU_SMOOTH );
sceGuEnable( GU_CULL_FACE );
sceGuEnable( GU_CLIP_PLANES );
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 ) );
sceGuClearDepth(0);
}
void DrawScene( void )
{
sceGuStart( GU_DIRECT, dList );
// clear screen
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
sceGumMatrixMode(GU_MODEL);
sceGumLoadIdentity();
{
ScePspFVector3 move = { 3.0f, 0.0f, 0.0f };
sceGumTranslate( &move );
}
// Draw Triangle
sceGumDrawArray( GU_TRIANGLES, GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,
3, 0, triangle );
sceGuFinish();
sceGuSync(0,0);
}
int main(int argc, char **argv)
{
pspDebugScreenInit();
SetupCallbacks();
sceRtcGetCurrentTick( &fpsTickLast );
tickResolution = sceRtcGetTickResolution();
dList = memalign( 16, 640 );
fbp0 = 0;
InitGU();
SetupProjection();
while( 1 )
{
DrawScene();
FPS();
//sceDisplayWaitVblankStart();
fbp0 = sceGuSwapBuffers();
}
sceGuTerm(); // Terminating the Graphics System
// Free Memory
free( dList );
free( fbp0 );
sceKernelExitGame();
return 0;
}
Oh, this part:Code:TARGET = LessonOne
OBJS = ./main.o
INCDIR =
LIBDIR =
LDFLAGS =
LIBS = -lpspgum -lpspgu -lpsprtc -lstdc++ -lm
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Lesson1
PSPSDK = $(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
./main.o: ./main.cpp
$(CXX) $(CXXFLAGS) -c ./main.cpp -o ./main.o
What does the brackets around the move variables do?Code:sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
sceGumMatrixMode(GU_MODEL);
sceGumLoadIdentity();
{
ScePspFVector3 move = { 3.0f, 0.0f, 0.0f };
sceGumTranslate( &move );
}
// Draw Triangle
Ty:Punk:
Off the top of my head I can't see any mistakes, it sounds like the image is being drawn off screen, if being drawn at all. Try changing:
to:Code:ScePspFVector3 move = { 3.0f, 0.0f, 0.0f };
to keep it centered(ish, can't remember exactly how it works).Code:ScePspFVector3 move = { 0.0f, 0.0f, 0.0f };
As for what the { } means, move is an array and you're initialising it with 3 values, its then being fed into sceGumTranslate which moves it on the drawing position on the screen by {X, Y, Z}, similar to glTranslatef(X, Y, Z).
Have you done any OGL stuff on the PC? If not I'd suggest playing around with it first and get a feel for 3D developing, then move to GU once you have an understanding of how things work; DirectX/OGL/GU is harder than most 2D libraries to learn so it'd be worth your time learning on the PC where mistakes are easier to rectify.
-Aura
Hmm, okay.
But I actually meant the { after loadIdentity.
The curly-brackets that separate the two lines you are talking about simply put them in a new scope.
Also, ScePspFVector3 is not an array, it's a structure.
Additionally, a PRX has 64kb of heap by default.
As for your actual problem, try moving the polygon back by translating it a bit on the z axis.
Like:
PHP-Code:ScePspFVector3 move;
move.x = 3.0f;
move.y = 0.0f;
move.z = 3.0f; // Or -3.0f, I can't remember which direction is positive on the z axis on the PSP.
sceGumTranslate(&move);
Haha, sorry I didn't realise.
Its a scope; any variable declared in a scope is removed from the stack at the end of that scope, for example:
Its handy if you need to work with a large string or a set of variables, but only want to use it for a small period of time.Code:int intA;
int newFunc()
{
//this function can access intA as its a global
}
int main()
{
int intB = 1;
//we can access intA and intB here
{
int intC;
//this scope can access intA, intB and intC
{
int intD;
//here we can access intA, intB, intC
} //when we've reached this intD is no longer availabe
}
//we can access intA and intB here, but not intC as it no longer exists
{
int intC;
//we can reuse the variable here as it was removed at the end of the scope
}
if(intB == 1)
{
char string[256];
//string is available in this scope
}
//string is no longer available here
}
I think _dysfunctional is right as well, I hadn't thought about the Z axis. Negative is closer towards us and positive is futher away though, so the possitive is correct... and yeah, ignore my dumb comment on the array, an array would be something like char string[256];
-Aura
I want to create a basic file transfer and chat client in C/++, but I'm not sure where to start from. I believe I need to use sockets, but I can't find a good guide as they all seem to be totally different from each other. Are sockets cross platform? If so do any of you know a good tutorial on sockets?
-Aura
im pretty sure that theres a sample in the sdk that sends a string over adhoc to a second psp :tup:
I think he meant from PC to PC, although this is in the PSP Development Forum:o
Yeah I meant for PC-PC transfers... its a PSP development forum but a C/++ thread, and hey, saves me signing up to some other website for 1 question... plus I've come to trust the opinions of quite a few devs on here, even if their method seems awkward at first.
-Aura
Auraomega, http://beej.us/guide/bgnet/
Try to finish most of the tutorial and memorize some basic functions and structures. If you can do that, then you will find network programming a piece of cake ;) . If you can't, there's always the .NET framework.
Gah, my head hurts so bad. I think I see aComa coming.
Ok, so I have this square. That rotates in a circle when I press R. It rotates fine, but I am trying to use oslibprintf to print the current angle as it rotates. (to help me debug)
It's rotating fine with this
But this is how I am trying to print it. I really don't know exactly what to write. I thought %i displays the variable (read something like that in a tut,)Code:if (osl_keys->held.R)
{
square_t->angle++;
}
My compiler gives me an error on this line saying : warning: format '%i' expects type 'int', but argument 3 has type 'double'Code:oslPrintf_xy(20,20, " Rotation Degree: %i",square_t->angle);
Use %f.
See http://www.cplusplus.com/reference/c...io/printf.html for more information, including what %i is actually for.
Ok, well, I used f%, and it still doesn't work. So I'm thinking there might be another problem. Maybe my print command is in the wrong place?
and what are all the initializations that i need before it?
edit:
aha. yeah. it was in the wrong place. it's working now. thanks
-=Double Post Merge =-
Ok, This is probably and easy one.
I'm trying to change the position on my sprite when the value of my function is between 1 and 22
if (square_t->angle = >1 && <22 ) sprite_position = URIGHT;
All I really wanna know is how I should write the bolded part?
Code:if ( ( square_t->angle >= 1 ) && ( square_t->angle < 22 ) )
sprite_position = URIGHT;