Zeige Ergebnis 8.761 bis 8.790 von 10174
C/C++ Programming Help Thread
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; This is one big fat request, I haven't even seen an attempt at code....
-
07-30-2008, 05:33 AM #8761Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
This is one big fat request, I haven't even seen an attempt at code.
-
07-30-2008, 06:48 AM #8762QJ Gamer Bronze
- Registriert seit
- Apr 2008
- Ort
- Ireland
- Beiträge
- 978
- Points
- 6.517
- Level
- 52
- Downloads
- 0
- Uploads
- 0
I don't want you guys to code it ;) i just want to know away to do it.
EDIT:
There is only one problem now Thanks.
-
07-30-2008, 08:59 AM #8763
-
07-30-2008, 09:32 AM #8764QJ Gamer Bronze
- Registriert seit
- Apr 2008
- Ort
- Ireland
- Beiträge
- 978
- Points
- 6.517
- Level
- 52
- Downloads
- 0
- Uploads
- 0
Yeah i will try something like that out thanks :)
-
07-30-2008, 02:42 PM #8765Banned from QJ for LIFE
- Registriert seit
- Jul 2006
- Beiträge
- 1.557
- Points
- 10.957
- Level
- 69
- Downloads
- 0
- Uploads
- 0
I know it is a bit noobish to ask but i haven't ever checked this for PSP so;
What gfx libraries does the PSP support?
SDL OpenGL OpenGL 2.0 etc.
P.s wasn't sure where to ask this but since there used in c and c++ stuff not lua i may as well ask here.
-
07-30-2008, 03:33 PM #8766No longer a community member.
- Registriert seit
- Dec 2005
- Beiträge
- 22
- Points
- 46.662
- Level
- 100
- Downloads
- 0
- Uploads
- 0
-
07-30-2008, 05:20 PM #8767Banned from QJ for LIFE
- Registriert seit
- Jul 2006
- Beiträge
- 1.557
- Points
- 10.957
- Level
- 69
- Downloads
- 0
- Uploads
- 0
I was wondering more about the OpenGl tbh because i was hoping when i have finished learning how to make things for the Pandora (Different to the battery thing) it will be easy to port the stuff to the PSP to.
I guessed from one of the recent posts it does some form but does it support the official OpenGL? (and 2.0)
-
07-30-2008, 05:55 PM #8768QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
it's not opengl it's called pspgu, although their is a port of opengl it is recommended not to use the port and instead to make your program use pspgu, ask xfactor, jj_calvin, or IWN about it for more information i can only give you some even with me using it, if you want to know more hop onto irc, server: freenode room: #psp-programming=-)
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
07-30-2008, 06:08 PM #8769Developer

- Registriert seit
- Jul 2006
- Beiträge
- 262
- Points
- 11.815
- Level
- 71
- Downloads
- 0
- Uploads
- 0
These are fairly good tutorials for PSPGU, and they are based on OpenGL tutorials:
http://www.skistovel.com/index.php?page=tutorials-psp
Even though the method of managing the display list appears to be coded incorrectly, it is still more than enough to get started with PSPGU.
Or you might want to check on OSLib for PSP. I've never used it but I've heard it is nice and renders images fast.
Whatever you do, just don't use old, poorly written graphics.c and graphics.h from LuaPlayer. There are very many things wrong with the way things are rendered with that code.
-
07-31-2008, 02:10 AM #8770QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Unless you code your stuff with SDL, porting won't be as easily possible. The pandora uses OpenGL|ES 2.0, while the PSP only has an inofficial OpenGL-alike library that supports the basic features of OpenGL 1.6. Even if pspgl were a complete OpenGL 2.0 implementation, it would be impossible to just switch from OpenGL|ES to OpenGL. They're different in many things.
You might as well just write your game for both platforms native graphics libraries - OpenGL|ES 2.0 and pspgu (not pspgl), which in turn is already very OpenGL alike and if you know basic OpenGL you will also know pspgu in no time.Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.
-
07-31-2008, 02:08 PM #8771QJ Gamer Blue
- Registriert seit
- Dec 2007
- Ort
- dfgd
- Beiträge
- 66
- Points
- 4.008
- Level
- 40
- Downloads
- 0
- Uploads
- 0
tables
hi all, well considering this is a c/c++ programming help thread, ill take advantage of it!
wellim new to C codin been doing lua n i have been a c coder for about 4 hours lol and im stuck already, well str8 to the point . . .
How can u create a table in c?
coz in lua u just put
table = { name = "luke",age = 18 }
or
table = {}
table[1] = { name = "luke", age = 18}
table[2] = { name = "jfjfsf", age = 65 }
but how can u create tables like that in c?
i need a table to hold likeplayer data, AI data etc
does anybody know?
thankyou
Luke
-
07-31-2008, 03:03 PM #8772QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Look/Google for array of structs.
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
07-31-2008, 03:37 PM #8773QJ Gamer Blue
- Registriert seit
- Dec 2007
- Ort
- dfgd
- Beiträge
- 66
- Points
- 4.008
- Level
- 40
- Downloads
- 0
- Uploads
- 0
well i did what u said and i search and i have no idea what im looking for?!
all i need is for someone to tell me how to create a table in c that can hold data or point me to information on how to do it etc but no offence like but look/google for array of tables, ima newby i said tht i duno what im lookin for lol bit more info if u will.
luke
-
07-31-2008, 04:04 PM #8774QJ Gamer Blue
- Registriert seit
- Apr 2008
- Beiträge
- 497
- Points
- 4.268
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Dude first result in google, when I searched, this isn't a tut, but it's an example of one in C.
http://mail.python.org/pipermail/tut...ay/005957.html
:) lol hope it helps
-
07-31-2008, 04:05 PM #8775
- Registriert seit
- Apr 2008
- Beiträge
- 47
- Points
- 2.658
- Level
- 31
- Downloads
- 0
- Uploads
- 0
There are no 'tables' in C. You have to build your own. When I need a size-conscious array I do this:
Then to declare an array I say:Code:typdef struct { int* values; int size; } sizedIntArray;
Then when I add something:Code:sizedIntArray my_array; my_array.size = 0; //Set the size of the array my_array.values = (int*)malloc(0); //Make malloc aware of the array location
Removing a value from the end is similar and removing a value from the beginning/middle can be done by manually shifting later values down and then removing the last value. You can refer to an item at a specific index by 'my_array.values[?]' where ? is the index you want.Code:my_array.size++; //increase the size by 1 my_array.values = (int*)realloc(my_array.values, my_array.size * sizeof(int)); //allocate more memory for the array
As for tables used as dictionaries, you'll need to create an array of structs. Make a typedef struct and then create an array of them:
That's an array of 10 people. Each one is a 'Person'. Each person has a 'name', an 'age', and a 'gender'. The first person is set up there so you can see how to refer to it.Code:typedef struct { char name[50]; unsigned int age; int gender; } Person; Person my_array[10]; my_array[0].age = 30; my_array[0].gender = 1; //male sprintf(my_array[0].name, "Mr. Bob");Geändert von Khatharr (07-31-2008 um 04:18 PM Uhr)
-
07-31-2008, 04:10 PM #8776QJ Gamer Blue
- Registriert seit
- Dec 2007
- Ort
- dfgd
- Beiträge
- 66
- Points
- 4.008
- Level
- 40
- Downloads
- 0
- Uploads
- 0
ye i saw that to had a look at it i was just confused lol
i did try n make a table in my code but i just got loads of errors, i did . . .
struct player
{
char name;
int X;
int Y;
}
then in my main code i put
player.name = "luke";
player.X = 45;
player.Y = 65;
but i think ive got that allwrong lol but worth a try i just dont know what to do i dont want to make loads of variables holding all the data coz id have tones, but i dont have any idea how to make a struct! :Argh:
luke
-
07-31-2008, 04:27 PM #8777QJ Gamer Blue
- Registriert seit
- Dec 2007
- Ort
- dfgd
- Beiträge
- 66
- Points
- 4.008
- Level
- 40
- Downloads
- 0
- Uploads
- 0
-
07-31-2008, 04:34 PM #8778QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
If are at the stage where you can't tell what results to look for because you don't understand the terminology, you are jumping too far ahead and you need to 'fall back' a bit.
Look for tutorials on Arrays. Once you have understood how arrays work then look for tutorials on structs in C (C++ structs are slightly different). Once you have understood how to use structs, then you can put the two together to make an array of structs.[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
07-31-2008, 06:59 PM #8779QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
well if your just looking for an array, not a structure as Khatharr said it's fairly simple:
another way:Code:int array[] = { 1, 2, 3}; <-- similar to how lua does it
than theirs the pointer methodCode:int array[3]; array[0] = 1; array[1] = 2; array[2] = 3;
arrays are farly simple, and at this point i suggest learning more about arrays before you jump into structures as Khatharr pointed you toCode:#include <malloc.h> int *array = (int*)malloc(sizeof(int)*3); <--creates room for the array(in this case 3 spots are created) array[0] = 1; array[1] = 2; array[2] = 3; free(array) <--free the memory up
also Khatharr why did you make the gender an unsigned int, seems a tad un-needed(and something that can confuse him since he's still fairly new)Geändert von slicer4ever (08-01-2008 um 03:18 AM Uhr)
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
07-31-2008, 07:51 PM #8780QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- USA SC/NC
- Beiträge
- 699
- Points
- 5.712
- Level
- 48
- Downloads
- 0
- Uploads
- 0
[CODE]Random Facts:
irc://irc.malloc.us #wtf #**********
[/CODE]
[SIZE="6"][FONT="Century Gothic"][COLOR="Blue"][URL="http://forums.**********.net"]http://forums.**********.net[/URL][/COLOR][/FONT][/SIZE]
-
07-31-2008, 08:22 PM #8781QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
true, but i don't think it was necessary imo, anywho must have over looked it as gender my bad
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
07-31-2008, 08:25 PM #8782QJ Gamer Green
- Registriert seit
- Sep 2006
- Ort
- 3.03OE-C
- Beiträge
- 1.098
- Points
- 9.134
- Level
- 64
- Downloads
- 0
- Uploads
- 0
i used a PNG file to make a background and i am wanting that to go away when i push a button, and then go to another background with a sprite on it. my main problem is getting rid of the first one, i tried using oslClr() since im using OSlib but that only seems to work with text. how do i get rid of it?
CuRrEnT fIrMwArE [SIZE="3"][FONT="Times New Roman"][COLOR="Red"][B][I][U]3.90 M33-2 SLIM TA-085V2 with TimeMachine 0.1[/U][/I][/B][/COLOR][/FONT][/SIZE]
[WIP] Trogdor! (ON HOLD converting to LUA, but almost caught up)
-
07-31-2008, 08:31 PM #8783
- Registriert seit
- Apr 2008
- Beiträge
- 47
- Points
- 2.658
- Level
- 31
- Downloads
- 0
- Uploads
- 0
-
07-31-2008, 08:33 PM #8784QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
true, good call i guess
zero check your thread1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
08-01-2008, 02:50 AM #8785QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
08-01-2008, 03:17 AM #8786QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
ahh my bad, forgot to free the memory
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
08-01-2008, 07:54 AM #8787QJ Gamer Green
- Registriert seit
- Sep 2006
- Ort
- 3.03OE-C
- Beiträge
- 1.098
- Points
- 9.134
- Level
- 64
- Downloads
- 0
- Uploads
- 0
image loading
i am still pretty confused on my question, i think its because of the way my code is set up. but here is most of my code
the places in bold are the areas i am dealing with. the first bold is the place that i am loading my first image which works, but i want to overlap that with a second pic and a sprite with a button command. so i go to the second bold part and try to put this in.Code://OSlib header file #include <oslib/oslib.h> //Necessary to create eboot PSP_MODULE_INFO("Sample", 0, 1, 1); PSP_MAIN_THREAD_ATTR(THRE AD_ATTR_USER | THREAD_ATTR_VFPU); //declaration of the pointers of our images OSL_IMAGE *background, *videlectrix, *sprite; //definitions #define DOWN 0 #define UP 35 #define RIGHT 70 #define LEFT 105 //variables int sprite_position; int sprite_march; //function declarations void Buttons(); void SpriteAnimate(); int main() { //Initialization of the Oslib library oslInit(0); //Initialization of the graphics mode oslInitGfx(OSL_PF_8888, 1); //Sets the transparency color (pink) oslSetTransparentColor(RG B(255,0,255)); //loads our images into memory background = oslLoadImageFile("backgro und.png", OSL_IN_RAM, OSL_PF_5551); sprite = oslLoadImageFile("sprite. png", OSL_IN_RAM, OSL_PF_5551); videlectrix = oslLoadImageFile("videlec trix.png", OSL_IN_RAM, OSL_PF_5551); //Disables the transpaent color (pink) oslDisableTransparentColo r(); //verification that all files are present if (!background || !sprite || !videlectrix) oslDebug("It is impossible to load one or more of the images that are required in this program. Please make sure you have all the files required in the eboot folder"); //Sets the sprite's original position on the screen sprite->x = 155; sprite->y = 95; sprite_position = DOWN; //main while loop while (!osl_quit) { //To be able to draw on the screen oslStartDrawing(); //calls the Buttons() function Buttons(); //Draw the images to the screen oslDrawImage(videlectrix) ; //Ends drawing mode oslEndDrawing(); //Synchronizes the screen oslSyncFrame(); } //Terminate the program oslEndGfx(); oslQuit(); return 0; } void Buttons() { //initiate the PSP's buttons oslReadKeys(); if (osl_keys->held.down) { //Sprite movement sprite->y += 2; //Sets the sprite's position on the spritesheet sprite_position = DOWN; //Calls the SpriteAnimate() function SpriteAnimate(); } if (osl_keys->held.up) { sprite->y -= 2; sprite_position = UP; SpriteAnimate(); } if (osl_keys->held.right) { sprite->x += 2; sprite_position = RIGHT; SpriteAnimate(); } if (osl_keys->held.left) { sprite->x -= 2; sprite_position = LEFT; SpriteAnimate(); } //If a button is not pressed if (!osl_keys->held.value) { //Start the variable over for when a button is pressed again sprite_march = 0; //Sets the sprite's direction oslSetImageTileSize(sprit e,0,sprite_position,22,35 ); } } void SpriteAnimate() { //Moves the sprite in the row that it is in sprite_march++; //Moves the sprite constantly oslSetImageTileSize(sprit e,(sprite_march * 22),sprite_position,22,35 ); //resets the sprite movement in that row if (sprite_march == 6) sprite_march = 0; }
but it just doesnt work. what am i doing wrong?Code:if (osl_keys->held.cross) { //Draw the images to the screen oslDrawImage(background); oslDrawImage(sprite); }CuRrEnT fIrMwArE [SIZE="3"][FONT="Times New Roman"][COLOR="Red"][B][I][U]3.90 M33-2 SLIM TA-085V2 with TimeMachine 0.1[/U][/I][/B][/COLOR][/FONT][/SIZE]
[WIP] Trogdor! (ON HOLD converting to LUA, but almost caught up)
-
08-01-2008, 07:59 AM #8788QJ Gamer Blue
- Registriert seit
- Dec 2007
- Ort
- dfgd
- Beiträge
- 66
- Points
- 4.008
- Level
- 40
- Downloads
- 0
- Uploads
- 0
well thats gd coz i read it n wa like unsigned :S
lookd it up n it means --a value that can only be positive therefore it cannot be a negative number-- :humped:
also say i created an array n then i wanted to free that array so i have more memory would i do this . . .
int array[3];
array[0] = 1;
array[1] = 2;
array[2] = 3;
free(array) or would it be free(array[3]) also to free a variable would i just set it to NULL or free(variable).
just wondering
luke
-
08-01-2008, 09:15 AM #8789QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
no free only works on things that you malloc
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
08-01-2008, 09:21 AM #8790QJ Gamer Silver

- Registriert seit
- Jan 2006
- Ort
- Germany
- Beiträge
- 926
- Points
- 14.087
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Just don't deal with dynamic memory allocation alltogether for the time being... you're still missing on basic C syntax and programming techniques which is much more important to learn. As long as you declare variables like you did, you don't have to care about freeing the memory.
And never ever call free upon an object that you didn't explicitly allocate with malloc() before.
PS: And please try to write at least halfway proper english. It's a nuisance to read your writing.Raphs board rules #31: Excessive use of punctuation is either a sign of a lesser ego or a small mind. Avoid it if you don't want to look like a total moron.
Raphs board rules #17: When you need to ask whether you are capable of doing something, you are not.
Raphs board rules #2: Exploits aren't found by changing version numbers, blindly merging data into a file or turning your PSP upside down.
Raphs board rules #1: If you have no clue how exploits work, don't come up with ideas about them.


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum