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; wow, i feel like an idiot, i didn't even read his full post and he had already created an answer, ...
-
11-14-2008, 08:57 AM #9211QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
wow, i feel like an idiot, i didn't even read his full post and he had already created an answer, and yauster, thanks for the input
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
-
11-14-2008, 09:30 AM #9212
When I compile anything with Minpspw on Vista Ultimate , it doesn't work , the whole system freezes , I can't click anything and I have to restart it.
PLEASE HELP !!!!
-
11-15-2008, 10:18 AM #9213
I just can't seem to get this data structure to compile.
Donot ask me "What are you trying to do? "Code:struct SColor { union { unsigned int ARGB; struct { unsigned char A; unsigned char R; unsigned char G; unsigned char B; }; }; };
-
11-15-2008, 10:36 AM #9214QJ Gamer Silver
- Registriert seit
- Sep 2006
- Ort
- Perth, Scotland
- Beiträge
- 1.094
- Points
- 8.475
- Level
- 62
- Downloads
- 0
- Uploads
- 0
-
11-15-2008, 05:12 PM #9215
- Registriert seit
- May 2008
- Beiträge
- 46
- Points
- 2.561
- Level
- 30
- Downloads
- 0
- Uploads
- 0
-
11-15-2008, 06:18 PM #9216QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
What is better, c or C++ to learn first? I wanted to start programing, but I don't know what one to learn. I don't want to learn both either.
AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
11-15-2008, 07:06 PM #9217QJ Gamer Blue
- Registriert seit
- Jul 2007
- Beiträge
- 296
- Points
- 3.795
- Level
- 38
- Downloads
- 0
- Uploads
- 0
-
11-15-2008, 07:25 PM #9218
-
11-15-2008, 08:04 PM #9219QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
11-15-2008, 08:17 PM #9220QJ Gamer Blue
Achievements:
- Registriert seit
- Aug 2008
- Beiträge
- 26
- Points
- 2.426
- Level
- 29
- Downloads
- 0
- Uploads
- 0
-
11-15-2008, 08:24 PM #9221
Geändert von Mr305 (11-15-2008 um 08:30 PM Uhr) Grund: Automerged Doublepost
-
11-15-2008, 08:58 PM #9222QJ Gamer Blue
- Registriert seit
- Jul 2007
- Beiträge
- 296
- Points
- 3.795
- Level
- 38
- Downloads
- 0
- Uploads
- 0
No, sounds more like it can't find where SColor is defined, make sure you are including the proper headers for it. Also, with the code you have posted it's hard to tell, paste more of the program so we can narrow it down.
-
11-15-2008, 09:28 PM #9223
- Registriert seit
- May 2008
- Beiträge
- 46
- Points
- 2.561
- Level
- 30
- Downloads
- 0
- Uploads
- 0
No, you need to use like this:
or redefine SColor as:Code:void ColorBlend(struct SColor Src, struct SColor Dest) { //NOTHING here }
then:Code:typedef struct SColor { union { unsigned int ARGB; struct { unsigned char A; unsigned char R; unsigned char G; unsigned char B; }; }; } SColor;
can work.Code:void ColorBlend( SColor Src, SColor Dest) { //NOTHING here }
Read up more about structs.
EDIT:
It is imperative to know the difference between:
Code:// With TAG struct mytag { int member; }; struct mytag somevar; somevar.member = 1;Code:// With VAR struct { int member; } myvar; myvar.member = 1;Code:// With TAG and VAR struct mytag { int member; } myvar; myvar.member = 1; struct mytag anothervar; anothervar.member = 1;Code:// As TYPE typedef struct { int member; } mytype; mytype somevar; somevar.member = 1;These are C basics and any adequate book should teach this.Code:// As TYPE with TAG typedef struct mytag { int member; } mytype; struct mytag var1; mytype var2;Geändert von pspersanonymous (11-15-2008 um 09:57 PM Uhr)
-
11-15-2008, 09:33 PM #9224QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- USA SC/NC
- Beiträge
- 699
- Points
- 5.712
- Level
- 48
- Downloads
- 0
- Uploads
- 0
typedef struct{
// ...
}SColor;[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]
-
11-23-2008, 08:07 PM #9225I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I'm using a class to hold some random info, but when I access one classes data it gives me the last classes data instead, I'm just wondering if this is normal behaviour?
I thought each classes data was supposed to be seperate? But from what I'm seeing its not so...Code:class blah { private: int meh; public: ... }; ... int main() { blah a; blah b; /* code to setup meh for a and b to be different, but meh for a becomes what meh for b is*/ ... }
-Aura
-
11-24-2008, 03:20 AM #9226Bush Programmer

- Registriert seit
- Nov 2005
- Beiträge
- 3.658
- Points
- 60.149
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Hi,
Has anyone got a file browser working with Intrafont they'd like to share?
I tried converting this one:
http://www.psp-programming.com/forum...ic,1333.0.html
works fine for me in debug screen,
but with Intrafont, it's printing the first page only, and then freezing.
My code is in the last page of that thread there.
Cheers, Art.
-
11-24-2008, 03:30 AM #9227QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
@Auraomega: Then there is something wrong with the code you haven't shown. Post the minimal code needed to produce the bug you are describing.
Gives:Code:#include <iostream> using namespace std; class blah { private: int meh; public: int GetMeh() const { return meh; } void SetMeh( int aInt ) { meh = aInt; } }; int main() { blah a; blah b; a.SetMeh( 10 ); b.SetMeh( 20 ); cout << "a: " << a.GetMeh() << " b: " << b.GetMeh() << endl; }
Code:a: 10 b: 20
[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]
-
11-24-2008, 05:15 AM #9228I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Sorry for the vague discription, it was 4:30 am when I post that...
After some work today I noticed that the data isn't being written to the same place, but almost the same place. I'm partly following the NeHe tutorials on OpenGL, this is the problem code:
When I run the displayTexture function for all 3 objects, it gives the following output:Code:AUX_RGBImageRec *loadBMP(char *fileName) //as taken from NeHe's tutorials -> http://nehe.gamedev.net { FILE* image; if(!fileName) return NULL; image = fopen(fileName, "r"); if(image) { fclose(image); return auxDIBImageLoad(fileName); } return NULL; } class icon { private: unsigned int texture; public: icon(char* fileName); void drawIcon(); void displayTexture() { FILE* fp; fp = fopen("output.txt", "a"); fprintf(fp, "Texture - 0x%08X\n", texture); } }; icon::icon(char* fileName) { texture = 0; AUX_RGBImageRec *textureImage; memset(textureImage, 0, sizeof(void*)*1); textureImage = loadBMP(fileName); iconActive = false; if(textureImage) { glGenTextures(3, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gluBuild2DMipmaps(GL_TEXTURE_2D, 3, textureImage->sizeX, textureImage->sizeY, GL_RGB, GL_UNSIGNED_BYTE, textureImage->data); } }
Texture - 0x00000006
Texture - 0x00000009
Texture - 0x00000007
I guess this would be why the last image loaded is the only one that shows up (hence why I thought it was writing to the same area). I'm just not sure how to go about solving this?
Thanks again.
-Aura
-
11-24-2008, 08:13 AM #9229QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Are you saying that you have 3 different instances of icon that have 3 different textures but when it comes to rendering, they all show the same texture?
Edit:
Shouldn't:
Be:Code:glGenTextures(3, &texture);
Given:Code:glGenTextures(1, &texture);
http://www.opengl.org/documentation/...ntextures.html[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]
-
11-24-2008, 10:09 AM #9230QJ Gamer Blue
- Registriert seit
- Jul 2007
- Beiträge
- 296
- Points
- 3.795
- Level
- 38
- Downloads
- 0
- Uploads
- 0
- GLaux is insanely outdated. I would suggest picking a better image loading library, such as DevIL or SOIL.
- You open a file to print the address (in displayTexture()), but you never close the file.
- OpenGL textures are just integers, there is no need to print them as hex.
- "memset(textureImage, 0, sizeof(void*)*1);", This basically means "memset(textureImage, 0, 4);" or "textureImage = NULL". The last one is prefered. memset() should be used for data that is already allocated.
- yaustar is correct. You are trying to generate 3 textures into space that will only allow one.
-
11-24-2008, 10:42 AM #9231I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Thanks yaustar, that works, I copied that function from another project which for some reason required 3.
@_dysfunctional
1. I don't use GLaux, I use a GLaux replacement that was sent to me on Gamedev
2. Meh... it was 4:30 and it was just a hacky addition to see if could solve the problem
3. Above comment
4. Thanks I wasn't aware of that, I just assumed there was some reason to work that way because of the tutorials.
-Aura
-
11-24-2008, 12:35 PM #9232QJ Gamer Blue
- Registriert seit
- Jul 2007
- Beiträge
- 296
- Points
- 3.795
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Stop copying code! You'll never learn!
I highly suggest going and buying a nice (hard-copy) book on C++. You can find a list of books here (put together by yaustar).
-
11-24-2008, 04:10 PM #9233I'm back!

- Registriert seit
- Feb 2007
- Ort
- England
- Beiträge
- 902
- Points
- 8.236
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Lol it was my own code from a few months back, I just never got very far in OGL and decided to start again from scratch, but grabbed that function and a few others from some old code to save on typing.
When Christmas is out the way and I have some money I plan on buying a book on C++ and C#, but until then its hard to justify the expence on a hobby.
-Aura
-
11-24-2008, 05:44 PM #9234QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
If money is an issue, then read Thinking in C++ which is a free eBook.
More online resources can be found here.[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]
-
11-26-2008, 12:10 AM #9235Bush Programmer

- Registriert seit
- Nov 2005
- Beiträge
- 3.658
- Points
- 60.149
- Level
- 100
- Downloads
- 0
- Uploads
- 0
What is the quickest way to tell if an integer is evenly divisible by a given number (say 20)?
I know about the mod (modulus), but not sure if it's used with integers.
so with 20 as the example, I'd want to know when the said integer was 20,40,60,80,100,120, etc.
If the MOD operand does work with inegers, I guess it's just .... i = (x mod 20); if (i == 0) {yay!}
Cheers, Art.
-
11-26-2008, 01:11 AM #9236
yes i also believe this works
if ((x mod 20) == 0) { stuffz }
-
11-26-2008, 01:19 AM #9237Bush Programmer

- Registriert seit
- Nov 2005
- Beiträge
- 3.658
- Points
- 60.149
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Thanks, would have been easy to test I suppose.. laziness!
-
11-26-2008, 03:45 PM #9238
- Registriert seit
- May 2008
- Beiträge
- 46
- Points
- 2.561
- Level
- 30
- Downloads
- 0
- Uploads
- 0
Yep, except the mod operand is the percent symbol, so properly it would be:
Code:if ((x%20) == 0) { // 'x' is evenly divisible by 20 }
-
11-26-2008, 07:56 PM #9239QJ Gamer Bronze
- Registriert seit
- Aug 2008
- Ort
- thugz mansion
- Beiträge
- 875
- Points
- 5.594
- Level
- 48
- Downloads
- 0
- Uploads
- 0
Does anyone know if theres a list of all the known functions that come in the standered sdk that can be used on the psp.
The only ones i know right know is:
scekernelexit();<-- allows quick exit
setupcallbacks(); <-- Allows home menu to be displayed
ide like to get a list but the one i really wanna know is the one that turns on and off the psp screen.
also in basic there was something called subs wich were like apps inside of apps where you can put everything in one source is there something like that for c/c++
ooh as an example of what im talking.
Code:declare sub main declare sub thq sub main print "hello qj.net this is an example" input "are you a noob" ; yesno if yesno = YEAH then sub thq elseif yesno = Naw then print "thats good for you" end if end sub sub thq cls print "noobs are cool =}" end sub main
Zitat von SuperBatXS
-
11-26-2008, 08:46 PM #9240QJ Gamer Blue
- Registriert seit
- Jul 2007
- Beiträge
- 296
- Points
- 3.795
- Level
- 38
- Downloads
- 0
- Uploads
- 0
You obviously have no knowledge of C or C++, so before you even touch the PSP, I would suggest you go buy a nice book on C++ and download the Visual C++ Express. Get used to it, program on the PC for a while. Once you actually understand C++, you'll understand that you can just look in the SDK headers to find the function you want. Of course, without any knowledge of C++, it won't make any sense now. So, get to it, get reading.


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