On the old version of KGL, I used the following code to load a given texture :
Code: Select all
#include <kos.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <pcx/pcx.h>
void loadtxr(const char *fn, GLuint *txr, int *w, int *h ) {
kos_img_t img;
pvr_ptr_t txaddr;
if(pcx_to_img(fn, &img) < 0) {
printf("can't load %s\n", fn);
return;
}
txaddr = pvr_mem_malloc(img.w * img.h * 2);
*w = img.w ;
*h = img.h ;
pvr_txr_load_kimg(&img, txaddr, PVR_TXRLOAD_INVERT_Y);
kos_img_free(&img, 0);
glGenTextures(1, txr);
glBindTexture(GL_TEXTURE_2D, *txr);
glKosTex2D(GL_RGB565_TWID, img.w, img.h, txaddr);
}
Code: Select all
jaerder@jaerder-G50V ~/development/Projectos Software/vidfdc/dreamcast $ make
rm -f bin/main.elf romdisk.*
/home/jaerder/development/Tools/dreamcast/kallistios/utils/genromfs/genromfs -f romdisk.img -d romdisk -v -x .svn
0 rom 53f23e19 [0xffffffff, 0xffffffff] 37777777777, sz 0, at 0x0
1 . [0x817 , 0xde0013 ] 0040755, sz 0, at 0x20
1 .. [0x817 , 0xde0002 ] 0040755, sz 0, at 0x40 [link to 0x20 ]
1 exporter_t.xml [0x817 , 0xde011d ] 0100644, sz 2464, at 0x60
1 piramid.mtl [0x817 , 0xde0147 ] 0100644, sz 279, at 0xa20
1 bw.pcx [0x817 , 0xde0135 ] 0100644, sz 78181, at 0xb60
1 checkerboard.pcx [0x817 , 0xde003f ] 0100644, sz 4993, at 0x13cf0
1 teste.obj [0x817 , 0xde0037 ] 0100644, sz 887, at 0x150b0
1 piramid.obj [0x817 , 0xde012e ] 0100644, sz 859, at 0x15450
1 font_2.fnt [0x817 , 0xde0104 ] 0100644, sz 15848, at 0x157d0
1 plane.obj [0x817 , 0xde0038 ] 0100644, sz 555, at 0x195e0
1 teste.xml_x [0x817 , 0xde004e ] 0100644, sz 1802, at 0x19830
1 hex.obj [0x817 , 0xde0123 ] 0100644, sz 3374, at 0x19f60
1 monkey.obj [0x817 , 0xde003d ] 0100644, sz 99318, at 0x1acb0
1 font.png [0x817 , 0xde001c ] 0100644, sz 17671, at 0x330d0
1 crate.pcx [0x817 , 0xde002c ] 0100644, sz 66451, at 0x37600
1 font_2.png [0x817 , 0xde0103 ] 0100644, sz 61359, at 0x479c0
1 font.fnt [0x817 , 0xde001b ] 0100644, sz 15907, at 0x56990
/home/jaerder/development/Tools/dreamcast/kallistios/utils/bin2o/bin2o romdisk.img romdisk romdisk.o
kos-cc -o bin/main.elf src/main.o src/data_estructures.o src/dc_render.o src/obj_loader.o src/asset_loader.o src/pcx_loader.o src/xml_parser.o src/fnt_parser.o src/png_loader.o src/procedural.o romdisk.o -L/home/jaerder/development/Tools/dreamcast/kallistios/lib -lgl -lpcx -lkosutils -lexpat -lpng -lz -lm -Wl,--start-group -lkallisti -lc -lgcc -Wl,--end-group
src/pcx_loader.o: In function `loadtxr':
/home/jaerder/development/Projectos Software/vidfdc/dreamcast/src/pcx_loader.c:24: undefined reference to `_glKosTex2D'
src/png_loader.o: In function `loadpng':
/home/jaerder/development/Projectos Software/vidfdc/dreamcast/src/png_loader.c:24: undefined reference to `_glKosTex2D'
collect2: error: ld returned 1 exit status
make: *** [bin/main.elf] Error 1
jaerder@jaerder-G50V ~/development/Projectos Software/vidfdc/dreamcast $
But my confusion is on the fmt member of the kos_img_t struct.
As specified on http://gamedev.allusion.net/docs/kos-cu ... ource.html do seem not match the specs defined on http://sourceforge.net/p/cadcdev/libgl/ ... clude/gl.h or http://gamedev.allusion.net/docs/kos-cu ... vr_8h.html.
Therefore if I wish to make a texture available via glTexImage2D() i would be inclided to do
Code: Select all
#include <kos.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <pcx/pcx.h>
void loadtxr(const char *fn, GLuint *txr, int *w, int *h ) {
kos_img_t img;
pvr_ptr_t txaddr;
if(pcx_to_img(fn, &img) < 0) {
printf("can't load %s\n", fn);
return;
}
txaddr = pvr_mem_malloc(img.w * img.h * 2);
*w = img.w ;
*h = img.h ;
pvr_txr_load_kimg(&img, txaddr, PVR_TXRLOAD_INVERT_Y);
glGenTextures(1, txr);
glBindTexture(GL_TEXTURE_2D, *txr);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
img.w,img.h, 0,
img.fmt, GL_RGB, img.data);
kos_img_free(&img, 0);
}
Any recommendations on what may be the best method for texture loading ?
[EDIT]
The code mentioned above does , indeed, NOT work.
PH3N0N,
Code: Select all
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
Also, did the coords on Othographic projection change compared to the old KGL / KGL-X ?