You are not logged in.
I'm having some problems to compile GRRLIB 3.0 in a C++ project. With previous version it worked ok, but now, i'm having some weird problems.
I used the Makefile of GRRLIB 3.0 (and added 2 more libs at the end for the sound)
Everything is included but ...
I have to change from GRRLIB.c to GRRLIB.cpp (yes, thats strange, but it there're any .cpp file on the project, .c files are ignored and not included :___()
If i leave it as GRRLIB.c EVERY function give me a "undefined reference to GRRLIB_nameOfTheFuncion"
When i rename it to GRRLIB.cpp then
I have to update the last line of GRRLIB_LoadTexture with
return (u8 *)my_texture;
(just notice the casting)
But then only "some functions" are giving me problems
GameView.o: In function `GameView::clearScreen()': /home/conejo/devkitpro/MKAE/source/GameView.cpp:412: undefined reference to `GRRLIB_FillScreen(unsigned int)' GameView.o: In function `GameView::drawCrosshair()': /home/conejo/devkitpro/MKAE/source/GameView.cpp:406: undefined reference to `GRRLIB_DrawImg(float, float, unsigned short, unsigned short, unsigned char*, float, float, float, unsigned char)' GameView.o: In function `GameView::drawBackground(MKAE_IMG)': /home/conejo/devkitpro/MKAE/source/GameView.cpp:375: undefined reference to `GRRLIB_DrawImg(float, float, unsigned short, unsigned short, unsigned char*, float, float, float, unsigned char)' /home/conejo/devkitpro/MKAE/source/GameView.cpp:376: undefined reference to `GRRLIB_DrawImg(float, float, unsigned short, unsigned short, unsigned char*, float, float, float, unsigned char)' GameView.o: In function `GameView::drawSprites()': /home/conejo/devkitpro/MKAE/source/GameView.cpp:87: undefined reference to `GRRLIB_DrawImg(float, float, unsigned short, unsigned short, unsigned char*, float, float, float, unsigned char)' /home/conejo/devkitpro/MKAE/source/GameView.cpp:105: undefined reference to `GRRLIB_DrawImg(float, float, unsigned short, unsigned short, unsigned char*, float, float, float, unsigned char)' GameView.o: In function `GameView::waitForFrame()': /home/conejo/devkitpro/MKAE/source/GameView.cpp:58: undefined reference to `GRRLIB_FillScreen(unsigned int)' collect2: ld returned 1 exit status make[1]: *** [/home/conejo/devkitpro/MKAE/boot.elf] Error 1 make[1]: Debido a los errores, el objetivo `/home/conejo/devkitpro/MKAE/boot.dol' no se reconstruyó. make: *** [build] Error 2
Of course i use GRRLIB_Start, _Render, _InitVideo & _LoadTexture... but only FillScreen & DrawImg are giving me problems.
In fact if i go to GRRLIB.h is giving me this warning
/home/conejo/devkitpro/MKAE/source/GRRLIB/GRRLIB.h: At global scope: /home/conejo/devkitpro/MKAE/source/GRRLIB/GRRLIB.h:21: warning: inline function 'void GRRLIB_FillScreen(u32)' used but never defined /home/conejo/devkitpro/MKAE/source/GRRLIB/GRRLIB.h:34: warning: inline function 'void GRRLIB_DrawImg(f32, f32, u16, u16, u8*, float, float, f32, u8)' used but never defined
(and with GRRLIB_Line but i don't use it)
If i delete the "inline" from the functions it compiles, but then a black screen appear when i run it (and the wiimote disconnect)
So, i don't know what could be...
Offline
To make it work in a CPP project, instead of renaming the file to .cpp put:
extern "C" { #include "GRRLIB/GRRLIB.h" }
I deleted all the inline too to make it work.
So it can work with C++ project.
I'm having a problem similar to yours, I think it's because the function GRRLIB_LoadTexture is in a loop, try not call it several times for the same memory allocation. Don't forget if you do a malloc you need free or if you use new you need a delete.
Offline
Download the latest version (3.0.1a) it fixed my problem.
Look carefully at the examples now, they don't use any malloc anymore because GRRLIB_LoadTexture is using memalign. But don't forget to free the pointer when the texture is not needed anymore.
Offline
ummm same problem...
i'm doing something like
u8 *beer_img = GRRLIB_LoadTexture(beer); u8 *sito_img = GRRLIB_LoadTexture(sito); u8 *crosshair_img = GRRLIB_LoadTexture(crosshair); u8 *fondo_img = GRRLIB_LoadTexture(fondo); Object ob; ob.id = 1; ob.img.image = beer_img; ob.img.width = 64; ob.img.height = 64;
And similar to the rest of the images...
Offline
Object it's a structure or a class?
What is: ob.img.image is it a u8 *?
If yes why don't you load load the texture directly to it:
ob.img.image = GRRLIB_LoadTexture(beer);
Offline
Object is a class
img is a struct to hold image data, width & heigth (some other stuff as center, and in a future a bitmap for pifxel-perfect collisions)
i declare and object (ob) declare its properties, and then add it to a list (vector type) to managed all objects on screen.
In fact, i don't know why i'm doing it in that way (lol) It's just like :
Object ob; ob.var1 = value1a; ob.var2 = value2a; ob.var3 = value3a; objectsList.addObjectToList(ob); //reutilice the same object ob.var1 = value1b; ob.var2 = value2b; ob.var3 = value3b; objectsList.addObjectToList(ob)
I'm NOT copying the pointers, with previous GGRLIB (1.6) it works fine... so it should work now
At the weekend (sorry, i have to come back to my country T___T) i will try to start from "scratch" (no images >> one image hardcoded >> two images hardcoded >> the rest of the system) because with no compilation errors & no "code dump" its hard to find why it's crashing.
Thanks for the advice ^___^
Offline