See Slasher's thread here: http://forums.ps2dev.org/viewtopic.php?t=6124Zitat:
Zitat von Cheater
Printable View
See Slasher's thread here: http://forums.ps2dev.org/viewtopic.php?t=6124Zitat:
Zitat von Cheater
My CYGWIN says ERROR: Make sure you have GNU 'make' installed. Any ideas?
How do i clear the screen to be red?
with graphics.c?Zitat:
Zitat von psphacker12.
clearScreen(color);
No, fillScreenRect(RGB(255, 0, 0), 0, 0, 480, 272);Zitat:
Zitat von waterbottle
The fillScreen doesn't actually clear it with the color you specified. Just have a look at the function, you'll see that the color parameter isn't used.
That is the slowest possible way of doing it and I would avoid it at all costs.Zitat:
Zitat von homer
Yes the clearScreen() function in the graphics.c is missing a line.
If you're not using graphics.c, or change the clearScreen() function to this if you are:Code:sceGuClearColor(GU_RGBA(255, 0, 0, 255));
sceGuClearDepth(0);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
Code:void clearScreen(Color color)
{
if (!initialized) return;
guStart();
sceGuClearDepth(0);
sceGuClearColor(color);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
sceGuFinish();
sceGuSync(0, 0);
}
Hi,
I'm trying to get a little client/server-application running (whereas the PSP is the client). Therefor I'm using a codeexample I got from a german tutorial. Unfortunately the compiler tells me
Line 72 is "if ((addr = inet_addr( argv[1])) != INADDR_NONE) {" and the whole code (just ignore the german comments, I can remove them if they are annoying):Zitat:
main.c: In function 'main':
main.c:72: error: 'INADDR_NONE' undeclared (first use in this function)
main.c:72: error: (Each undeclared identifier is reported only once
main.c:72: error: for each function it appears in.)
main.c:116:2: warning: no newline at end of file
make: *** [main.o] Error 1
Spoiler for client code:
I just don't know with what to replace INADDR_NONE...
PS: Coloured version of the code here under "Der Client" ("The Client")
Code:#define INADDR_NONE ((unsigned long) -1)
You need a blank line at the end of your code.Zitat:
Zitat von Lukeson
It works, I'll just trust you that this is the right value... however, thank you!Zitat:
#define INADDR_NONE ((unsigned long) -1)
Really? Why?Zitat:
You need a blank line at the end of your code.
It wont even compile without it..:tup:Zitat:
Zitat von Lukeson
Why the hell would you need a blank line... >.>
Anyways, I have a problem getting my simple 3D "app" to display. I'm using PSPGL. Here's the code (I'm not going to include the psp-setup.c file)Code:#include <stdlib.h> // needed in order to have "exit" function @@@
#include <GL/glut.h> // Header File For The GLUT Library
#include <GL/gl.h> // Header File For The OpenGL32 Library
#include <GL/glu.h> // Header File For The GLu32 Library
#include <math.h>
#include <stdio.h>
#define MAX_PARTICLES 100
struct PARTICLES {
float life;
float fade;
float x;
float y;
float z;
float xi;
float yi;
float zi;
};
PARTICLES particle[MAX_PARTICLES];
int loop;
float V;
float Angle;
/* The number of our GLUT window */
int window;
/* A general OpenGL initialization function. Sets all of the initial parameters. */
void InitGL(int Width, int Height) // We call this right after our OpenGL window is created.
{
//glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black
glLoadIdentity(); // Reset The Projection Matrix
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glShadeModel(GL_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
for( loop = 0; loop < MAX_PARTICLES; loop++) {
particle[loop].life = 1.0;
particle[loop].fade = (rand()%100)/1000.0 + 0.05;
V = rand()%25;
Angle = rand()%360;
particle[loop].x = 0;
particle[loop].y = 0;
particle[loop].z = 0;
particle[loop].xi = sin(Angle)*V;
particle[loop].yi = cos(Angle)*V;
particle[loop].zi = (((rand()%10)-5)/10)*V;
}
}
/* The function called when our window is resized (which shouldn't happen, because we're fullscreen) */
void ReSizeGLScene(int Width, int Height)
{
if (Height==0) // Prevent A Divide By Zero If The Window Is Too Small
Height=1;
glViewport(0, 0, Width, Height); // Reset The Current Viewport And Perspective Transformation
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f,(float)Width/(float)Height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
}
/* The main drawing function. */
void DrawGLScene()
{
//MUST ADD BLENDING
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity(); // Reset The View
glTranslatef(0,0,-15);
for(loop = 0; loop < MAX_PARTICLES; loop++) {
float x;
float y;
float z;
x = particle[loop].x;
y = particle[loop].y;
z = particle[loop].z;
glColor4f(.5f,.5f,1.f,particle[loop].life);
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(1,1); glVertex3f( x + 0.2f, y + 0.2f, z );
glTexCoord2f(0,1); glVertex3f( x - 0.2f, y + 0.2f, z );
glTexCoord2f(1,0); glVertex3f( x - 0.2f, y - 0.2f, z );
glTexCoord2f(0,0); glVertex3f(x-0.2f,y-0.2f,z);
glEnd();
particle[loop].x += (particle[loop].xi/250);
particle[loop].y += (particle[loop].yi/250);
particle[loop].z += (particle[loop].zi/250);
// Slow down the particles
particle[loop].xi*=.975;
particle[loop].yi*=.975;
particle[loop].zi*=.975;
particle[loop].life-=particle[loop].fade; // Reduce Particles Life By 'Fade'
if (particle[loop].life<0.05f) // If Particle Is Burned Out
{
particle[loop].life=1.0f; // Give It New Life
particle[loop].fade=float(rand()%100)/7500 + 0.0075f; // Random Fade Value
particle[loop].x= 0; // Center On X Axis
particle[loop].y= 0; // Center On Y Axis
particle[loop].z= 0; // Center On Z Axis
V = (float((rand()%9))+1);
Angle = float(rand()%360);
particle[loop].xi = sin(Angle) * V;
particle[loop].yi = cos(Angle) * V;
particle[loop].zi = ((rand()%10)-5)/5;
}
}
}
/* The function called whenever a key is pressed. */
void keyPressed(unsigned char key, int x, int y)
{
switch (key) {
case 'd': /* delta, triangle */
break;
case 'o': /* round */
break;
case 'q': /* square*/
break;
case 'x': /* cross */
break;
case 'n': /* key with the music note */
break;
case 's': /* select */
break;
case 'a': /* startbutton */ /* If START is pressed, kill everything. */
/* exit the program...normal termination. */
exit(0);
default:
;
}
}
/* The function called whenever a key is released. */
void keyReleased(unsigned char key, int x, int y)
{
switch (key) {
case 'd': /* delta, triangle */
break;
case 'o': /* round */
break;
case 'q': /* square*/
break;
case 'x': /* cross */
break;
case 'n': /* key with the music note */
break;
case 's': /* select */
break;
case 'a': /* startbutton */
break;
default:
;
}
}
/* The function called whenever a special key is pressed. */
void specialKeyPressed(int key, int x, int y)
{
switch (key) {
case GLUT_KEY_UP: // pad arrow up
break;
case GLUT_KEY_DOWN: // pad arrow down
break;
case GLUT_KEY_LEFT: // pad arrow left
break;
case GLUT_KEY_RIGHT: // pad arrow right
break;
case GLUT_KEY_HOME: // home
break;
default:
break;
}
}
/* The function called whenever a special key is released. */
void specialKeyReleased(int key, int x, int y)
{
switch (key) {
case GLUT_KEY_UP: // pad arrow up
break;
case GLUT_KEY_DOWN: // pad arrow down
break;
case GLUT_KEY_LEFT: // pad arrow left
break;
case GLUT_KEY_RIGHT: // pad arrow right
break;
case GLUT_KEY_HOME: // home
break;
default:
break;
}
}
/* The function called whenever the joystick is moved. */
void joystickMoved (unsigned int buttonMask, int x, int y, int z)
{
if (abs(x) > 150) // dead zone
{
// use x value
}
if (abs(y) > 150) // dead zone
{
// use y value
}
}
/* The function called whenever the triggers are pressed. */
void triggerHandle (int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON) { // left trigger...
if (state == GLUT_DOWN) { // ...is pressed
}
if (state == GLUT_UP) { // ...is released
}
}
if (button == GLUT_RIGHT_BUTTON) { // right trigger...
if (state == GLUT_DOWN) { // ...is pressed
}
if (state == GLUT_DOWN) { // ...is released
}
}
}
/* main function */
int main(int argc, char **argv)
{
/* Initialize GLUT state - glut will take any command line arguments that pertain to it or
X Windows - look at its documentation at http://reality.sgi.com/mjk/spec3/spec3.html */
glutInit(&argc, argv);
/* Select type of Display mode:
Double buffer
RGBA color
Alpha components supported
Depth buffer */
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);
/* get a 640 x 480 window */
glutInitWindowSize(480, 272);
/* the window starts at the upper left corner of the screen */
glutInitWindowPosition(0, 0);
/* Open a window */
window = glutCreateWindow("Jeff Molofee's GL Code Tutorial ... NeHe '99");
/* Register the function to do all our OpenGL drawing. */
glutDisplayFunc(&DrawGLScene);
/* Even if there are no events, redraw our gl scene. */
glutIdleFunc(&DrawGLScene);
/* Register the function called when our window is resized. */
glutReshapeFunc(&ReSizeGLScene);
/* Register the function called when the keyboard is pressed. */
glutKeyboardFunc(&keyPressed);
/* Register the function called when the keyboard is released. */
glutKeyboardUpFunc(&keyReleased);
/* Register the function called when special keys (arrows, page down, etc) are pressed. */
glutSpecialFunc(&specialKeyPressed);
/* Register the function called when special keys (arrows, page down, etc) are released. */
glutSpecialUpFunc(&specialKeyReleased);
/* Register the function called when joystick is moved. */
glutJoystickFunc(&joystickMoved, 0); // 0 = Joystick polling interval in milliseconds
/* Register the function called when Trigger_left or Trigger_right is pressed */
glutMouseFunc(&triggerHandle);
/* Initialize our window. */
InitGL(480, 272);
/* Start Event Processing Engine */
glutMainLoop();
return (0);
}
Bronx - add glutSwapBuffers(); at the end of your drawing. Oh and nice to see you are using PSPGL ;)
And yeah, you SHOULD have an extra line at hte bottom of your source, complier complains about it :\
this wont compile
Code:#include <pspdisplay.h>
#include <pspgu.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <stdio.h>
#include "graphics.h"
#define printf pspDebugScreenPrintf
#define dprint pspDebugScreenPrintf
PSP_MODULE_INFO("???", 0, 1, 1);
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int main(void) {
pspDebugScreenInit();
SetupCallbacks();
SceCtrlData pad;
initGraphics();
sceGuInit();
sceCtrlSetSamplingCycle(0);
sceCtrlPeekBufferPositive(&pad, 1);
while (1) {
char buffer[200]
bool rn0 = 0;
int rand() {
if (pad.Buttons != 0){
if(pad.Buttons & PSP_CTRL_CROSS) {
rn0=rand()%10000;
}
}
if (rn0 != 0) {
pspDebugScreenPrintf("Press 'X' to start.");
}
pspDebugScreenSetXY(0, 2);
pspDebugScreenClear();
fillScreenRect(RGB(255, 0, 0), 0, 0, 480, 272);
pspDebugScreenSetTextColor(0x00000000);
pspDebugScreenPrintf("Generated Integer:%d",rn0);
sceDisplayWaitVblankStart();
sceKernelSleepThread();
}
return 1;
}
Spoiler for Errors:
Thanks SG57 :) it worked! But it's tremedously small, do you have any idea how to enlarge it?
Bronx - Dont translate so far in the distance, change the -15 to -1, should work fine
psphacker - For one, you are using both debug console + gu and without properly setting the debug console framebuffer address to the gu's, itll flicker. To solve this, use the pre-made printTextScreen functions for printing, as well as remove the sceKernelSleepThread call since that make sthe current thread fall asleep stopping EVERYthing besides the homebutton from working (software wise). Oh and you need to flipScreen() at hte end of hte while(1) loop.
O.o, duh... I feel stupid, lol
Um can you give me an example of the printTextScreen(); function?Zitat:
Zitat von SG57
You need a semi-colon at the end of this line:
Should be:Code:char buffer[200]
Code:char buffer[200];
but when i compile it keeps telling me `rn0 (undeclared)'Zitat:
Zitat von Insomniac197
Learn C.
There are no booleans in C.
Can glTranslate() and glColor4f() take variables as arguements? I tried it so if blah was pressed a variable that held the number for red decreased or increased and I placed that variable in glColor4f's first arguement, but it didn't work... I also tried the same idea for the glTranslate and it als didn't work... :/
i changed it fromZitat:
Zitat von Insomniac197
toCode:bool rn0 = 0;
and it still doesnt work so idk =\Code:int rn0 = 0;
What? Basic C knowledge would lead to you knowing you can pass a variable as an argument. You probaby dont know the values for colors...
0.0f = no intensity
1.0f = full intensity
that variable must be a float and can't go above 1.0 and vice versa with 0. I still dont quite get what you mean though, sorry :(
psphacker - Best way to 'replicate' a boolean in C is to:
You also could make an enumerator, but i find it best to do it all during hte pre-processing stage (or w/e its called, sorry ).Code:#define true 1
#define false !true
#define bool int
Or just rename main.c to main.cpp, and add -lstdc++ to the libs section in the makefile, and you can use the bool enumerator/data type.
No, I know rgba, and I did have it as a float. so I had this basically:Then I altered the switch statement for the controls to say if blah was pressed those vars would increase or decrease. And it didn't work. And I did the same concept with the translate func but declared the vars as int, and that didn't work either.Code:float red = 0.0;
float green = 0.0;
float blue = 0.0;
glColor4f(red, green, blue, particle[loop].life);
Hi
I'm now trying to create a simple server (using windows), but if I use "Microsoft Visual C++ 2005 express" with the "Microsoft Platform SDK" (i installed the SDK just like it's written here), he always tells me
when I try to compile. Using Dev-C++ he gives me a list of errors likeZitat:
fatal error C1083: File (Include) cannot be opened: "winsock.h": No such file or directory
Can anyone help me?Zitat:
[Linker error] undefined reference to `[email protected]'
[Linker error] undefined reference to `[email protected]'
[Linker error] undefined reference to `[email protected]'
[Linker error] undefined reference to `[email protected]'
[Linker error] undefined reference to `[email protected]'
and so on
edit:
Oh, the code (if you, for some reason, wanna see it):
Spoiler for code:
As SG57 already said, something such as:
will suffice.Code:typedef enum {FALSE = 0, TRUE = 1} bool;
Bronx - I still havent a clue, but some things to try... Try moving the glColor4f into the glBegin and glEnd, else try removing the texcoordinates that are mapped for some reason (?). I dont see a texture being binded, so i dunno.
ok, Ill try it :) Thanks
This is my revised code.
Spoiler for Code:
When I compile it just keeps saying this.
Spoiler for Errors:
Try that...Code:#include <pspdisplay.h>
#include <pspgu.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <stdio.h>
#include "graphics.h"
#define printf pspDebugScreenPrintf
#define dprint pspDebugScreenPrintf
#define true 1
#define false !true
#define bool int
PSP_MODULE_INFO("???", 0, 1, 1);
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int i;
bool rn0 = 0;
int rand() {
sceCtrlPeekBufferPositive(&pad, 1);
if (pad.Buttons != 0){
if(pad.Buttons & PSP_CTRL_CROSS) {
rn0=rand()%10000; //generates random number
}
}
if (rn0==0) {
pspDebugScreenSetXY(0,2);
pspDebugScreenPrintf("Press 'X' to start"); //prints text to the screen
} else {
pspDebugScreenSetXY(0, 2); //setting up our X and Y coordinates
pspDebugScreenClear(); //clears screen
pspDebugScreenSetBackColor(0x00FF0000);
for(i=0;i<65;i++) {
for(z=0;z<36;z++) {
printf(" ");
}
}
pspDebugScreenSetTextColor(0x00000000); //sets text color with HEX
pspDebugScreenPrintf("Generated Integer:%d",rn0); //prints text to the screen
}
}
int main(void) { //main functions
pspDebugScreenInit();
SetupCallbacks();
SceCtrlData pad;
while (1) {
//while loop
rand();
}
return 0;
}
what are you trying to do with the
int rand() {
line in the middle of your main function?
you should probally delete that.
on a side note. sceCtrlPeekBufferPositive (&pad, 1);
should be inside your while loop.
and the if (pad.Buttons != 0){ check is completly unecesarry.
hm now i get this errorCode:#include <pspdisplay.h>
#include <pspgu.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include "graphics.h"
#define printf pspDebugScreenPrintf
#define dprint pspDebugScreenPrintf
#define true 1
#define false !true
#define bool int
PSP_MODULE_INFO("???", 0, 1, 1);
//Standard callbacks
int exit_callback(int arg1, int arg2, void *common) {
sceKernelExitGame();
return 0;
}
int CallbackThread(SceSize args, void *argp) {
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int SetupCallbacks(void) {
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if(thid >= 0) {
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
int i;
bool rn0 = 0;
int rand() {
sceCtrlPeekBufferPositive(&pad, 1);
srand(sceKernelLibcTime(NULL));
if (pad.Buttons != 0){
if(pad.Buttons & PSP_CTRL_CROSS) {
rn0=rand()%10000; //generates random number
}
}
if (rn0 != 0) {
pspDebugScreenSetXY(0,2);
pspDebugScreenPrintf("Press 'X' to start"); //prints text to the screen
} else {
pspDebugScreenSetXY(0, 2); //sets up our X and Y coordinates
pspDebugScreenClear(); //clears screen
pspDebugScreenSetBackColor(0x00FF0000); //sets screen color with HEX
pspDebugScreenSetTextColor(0x00000000); //sets text color with HEX
pspDebugScreenPrintf("Generated Integer:%d",rn0); //prints text to the screen
}
}
int main(void) {
//main functions
pspDebugScreenInit();
SetupCallbacks();
SceCtrlData pad;
while (1) {
//while loop
rand();
}
return 0;
}
It keeps sayind 'pad' is undeclared. hmm weird.Code:[email protected] ~
$ cd /pspdev
[email protected] /pspdev
$ make
psp-gcc -I. -I/usr/psp/sdk/include -O2 -G0 -Wall -c -o main.o main.c
main.c : In function 'rand':
main.c(48) : error: 'pad' undeclared (first use in this function)
main.c(48) : error: (Each undeclared identifier is reported only once
main.c(48) : error: for each function it appears in.)
main.c : In function 'main':
main.c(76) : warning: unused variable 'pad'
make: *** [main.o] Error 1
[email protected] /pspdev
$
you forgotten to ad this:
SceCtrlData pad;
-= Double Post =-
Zitat:
Zitat von homer
not working it does again , x=1,2,3,4,
it only have to do x=1 and x=2if you press again:Cry:
try thisZitat:
Zitat von hallo007
Code:inline void vermenigvuldigen()
{
int upPressed = FALSE; // This initializes "upPressed" //
int downPressed = FALSE;
printf("Druk op pijltje naar boven/beneden om de waarde van het eerste getal te veranderen :%i\n",x);
printf("Druk op pijltje naar links/rechts om de waarde van het tweede getal te veranderen :%i\n",y);
while(1) {
sceCtrlReadBufferPositive (&pad, 1);//start controls
if(pad.Buttons & PSP_CTRL_UP) {
if (!upPressed) {
x++;
pspDebugScreenClear();
upPressed = TRUE;
}
}
else {
upPressed = FALSE;
}
if(pad.Buttons & PSP_CTRL_DOWN) {
if (!downPressed) {
x--;
pspDebugScreenClear();
downPressed = TRUE;
}
}
else {
downPressed = FALSE;
}
if(pad.Buttons & PSP_CTRL_RIGHT) {
y++;
pspDebugScreenClear();
}
if(pad.Buttons & PSP_CTRL_LEFT) {
y--;
pspDebugScreenClear();
}
if(pad.Buttons & PSP_CTRL_CROSS) {
pspDebugScreenClear();
printf("het product is: %i\n",x*y);
menu();
}
if(pad.Buttons & PSP_CTRL_TRIANGLE) {
printf(" deze functie is nog niet af");
vermenigvuldigen();
}
}
}
so the prob is repating something
thnx!!
does anyone have a link to download the JPEG viewer lib?
Jpeg's on a PSP is really slow, I would suggest using PNG's. However, GeMP 3.3 has a jpeg viewer, you can download the source code here Source (it's in image.c)Zitat:
Zitat von psphacker12.
So does FileAssistant's Source =-\
would this restart my game??
Code:if(pad.Buttons & PSP_CTRL_CROSS) {
break;
}