Add more samples

This commit is contained in:
Luke Benstead 2021-04-07 15:43:31 +01:00
parent d2f8741fcc
commit 89031cfaba
3 changed files with 27 additions and 15 deletions

View File

@ -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)

View File

@ -8,11 +8,21 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#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" */

View File

@ -6,13 +6,14 @@
Load A PVR Texture to the PVR using Open GL
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <kos.h>
#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 */