From 89031cfaba05dd6b09272e56f3ca43f97161d015 Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Wed, 7 Apr 2021 15:43:31 +0100 Subject: [PATCH] Add more samples --- CMakeLists.txt | 1 + samples/multitexture_arrays/main.c | 24 ++++++++++++++++------- samples/multitexture_arrays/pvr-texture.c | 17 ++++++++-------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 786a87a..eebf8ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,4 +53,5 @@ add_executable(depth_funcs_alpha_testing samples/depth_funcs_alpha_testing/main. add_executable(depth_funcs_ortho samples/depth_funcs_ortho/main.c) add_executable(lights samples/lights/main.c) add_executable(mipmap samples/mipmap/main.c) +add_executable(multitexture_arrays samples/multitexture_arrays/main.c samples/multitexture_arrays/pvr-texture.c) diff --git a/samples/multitexture_arrays/main.c b/samples/multitexture_arrays/main.c index 58bf860..1d2345e 100644 --- a/samples/multitexture_arrays/main.c +++ b/samples/multitexture_arrays/main.c @@ -8,11 +8,21 @@ */ #include +#include +#include -#include "gl.h" -#include "glu.h" -#include "glkos.h" -#include "glext.h" +#include "GL/gl.h" +#include "GL/glu.h" +#include "GL/glkos.h" +#include "GL/glext.h" + +#ifdef __DREAMCAST__ +#define IMAGE1_FILENAME "/rd/wp001vq.pvr" +#define IMAGE2_FILENAME "/rd/FlareWS_256.pvr" +#else +#define IMAGE1_FILENAME "samples/multitexture_arrays/romdisk/wp001vq.pvr" +#define IMAGE2_FILENAME "samples/multitexture_arrays/romdisk/FlareWS_256.pvr" +#endif /* Load a PVR texture - located in pvr-texture.c */ extern GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap); @@ -91,7 +101,7 @@ void RenderCallback(GLuint texID0, GLuint texID1) { glDisableClientState(GL_VERTEX_ARRAY); } -extern uint8 romdisk[]; +extern uint8_t romdisk[]; KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { @@ -105,8 +115,8 @@ int main(int argc, char **argv) { glLoadIdentity(); /* Load two PVR textures to OpenGL */ - GLuint texID0 = glTextureLoadPVR("/rd/wp001vq.pvr", 0, 0); - GLuint texID1 = glTextureLoadPVR("/rd/FlareWS_256.pvr", 0, 0); + GLuint texID0 = glTextureLoadPVR(IMAGE1_FILENAME, 0, 0); + GLuint texID1 = glTextureLoadPVR(IMAGE2_FILENAME, 0, 0); while(1) { /* Draw the "scene" */ diff --git a/samples/multitexture_arrays/pvr-texture.c b/samples/multitexture_arrays/pvr-texture.c index 66b16d7..5524312 100644 --- a/samples/multitexture_arrays/pvr-texture.c +++ b/samples/multitexture_arrays/pvr-texture.c @@ -6,13 +6,14 @@ Load A PVR Texture to the PVR using Open GL */ +#include +#include +#include -#include - -#include "gl.h" -#include "glu.h" -#include "glkos.h" -#include "glext.h" +#include "GL/gl.h" +#include "GL/glu.h" +#include "GL/glkos.h" +#include "GL/glext.h" #define PVR_HDR_SIZE 0x20 #define MAX(x, y) ((x > y) ? x : y) @@ -51,8 +52,8 @@ static GLuint _glGetMipmapDataSize(GLuint width, GLuint height) { glMipMap should be passed as 1 if Open GL should calculate the Mipmap levels, 0 otherwise */ GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap) { FILE *tex = NULL; - uint16 *TEX0 = NULL; - uint8 HDR[PVR_HDR_SIZE]; + uint16_t *TEX0 = NULL; + uint8_t HDR[PVR_HDR_SIZE]; GLuint texID, texSize, texW, texH, texFormat; /* Open the PVR texture file, and get its file size */