JGE++ question

Anything related to the PSP (homebrews, plugins, hacking, news,...) can go here
furiousone
Posts: 61
Joined: Sat Oct 31, 2009 10:30 pm

Re: JGE++ question

Post by furiousone »

Thanks for the response. I'm still not quite sure if I want to just have one class MapObj that would have tons of variables and some would be kinda useless, unless the object is of a specific type, or have a number of classes that extend MapObj, but then most of them would have only a few attributes and methods on top of MapObj. Anyway, I guess I'll just have to figure it out.
furiousone
Posts: 61
Joined: Sat Oct 31, 2009 10:30 pm

Re: JGE++ question

Post by furiousone »

Man, I have no idea what's happening. Here's what I'm trying to do:
I have a file texture_path.txt, where i have a line with the name of the map object and the next line is the location of the corresponding texture. Somehow the following code works just fine on Windows.

Code: Select all

		string text_path;
		char filename[4096];
		JRenderer* renderer = JRenderer::GetInstance();

		std::ifstream file("Res/texture_path.txt");
		while( getline( file, text_path ) )
		{
			if(text_path == name)
			{
				//get the next line
				getline( file, text_path );
				break;
			}
		}
		file.close();
		if (text_path[text_path.size()-1] == '\r') text_path.erase(text_path.size()-1); 
		sprintf(filename, "%s", text_path.c_str());
		JTexture* map_res_texture = renderer->LoadTexture(filename);
However on PSP it gives the me following garbage. It means that its loading something, but something is not right here. I cant think of what though, cause if the filename was wrong, then the PSP would just crash because it would not find the file. Any ideas?
P.S. the heros' textures loaded fine only because i have explicitly pointed them to the location of the .png file.
Attachments

[The extension png has been deactivated and can no longer be displayed.]

wololo
Site Admin
Posts: 3728
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: JGE++ question

Post by wololo »

your loading code looks fine, but maybe the display code is not. I think recently Jean found a discrepancy in the way Quad objects work in JGE on the PSP and windows. There's some kind of "autorepeat" mode set for the PSP or something like that. Be sure to set a correct width and height when creating the Quad based on the texture.
furiousone
Posts: 61
Joined: Sat Oct 31, 2009 10:30 pm

Re: JGE++ question

Post by furiousone »

The thing is, if I put something like

Code: Select all

JTexture* map_res_texture = renderer->LoadTexture("Sprites/minihero/000.png");
There is no problem. I mean if I put it at exactly the same location. That's what's weird. Also, if i create a map like

Code: Select all

map<string,string> MapPath;
and use it like:

Code: Select all

JTexture* map_res_texture = renderer->LoadTexture(MapPath[name].c_str());
It also works just fine.
furiousone
Posts: 61
Joined: Sat Oct 31, 2009 10:30 pm

Re: JGE++ question

Post by furiousone »

Ok, I've figured out what was wrong. It was the carriage return at the end of the line, that's why you would never get a match and only the last line in the text file would be loaded as a texture for every object on the map. Phew!
Locked