mirror of
https://github.com/aap/librw.git
synced 2025-12-18 16:39:51 +00:00
texture mapping in ps2 test
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
@@ -347,7 +346,7 @@ static int32
|
||||
getSizeEnvMat(void *object, int32 offset, int32)
|
||||
{
|
||||
EnvMat *env = *PLUGINOFFSET(EnvMat*, object, offset);
|
||||
return env ? sizeof(EnvStream) : -1;
|
||||
return env ? (int)sizeof(EnvStream) : -1;
|
||||
}
|
||||
|
||||
// Specular mat
|
||||
@@ -417,7 +416,7 @@ static int32
|
||||
getSizeSpecMat(void *object, int32 offset, int32)
|
||||
{
|
||||
SpecMat *spec = *PLUGINOFFSET(SpecMat*, object, offset);
|
||||
return spec ? sizeof(SpecStream) : -1;
|
||||
return spec ? (int)sizeof(SpecStream) : -1;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
@@ -10,12 +9,6 @@
|
||||
#include "rwplugin.h"
|
||||
#include "rwobjects.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#define PACKED_STRUCT __attribute__((__packed__))
|
||||
#else
|
||||
#define PACKED_STRUCT
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace rw {
|
||||
@@ -291,6 +284,9 @@ Image::getFilename(const char *name)
|
||||
#ifndef RW_PS2
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
#define PACKED_STRUCT
|
||||
#else
|
||||
#define PACKED_STRUCT __attribute__((__packed__))
|
||||
#endif
|
||||
struct PACKED_STRUCT TGAHeader
|
||||
{
|
||||
@@ -319,9 +315,12 @@ readTGA(const char *afilename)
|
||||
filename = Image::getFilename(afilename);
|
||||
if(filename == NULL)
|
||||
return NULL;
|
||||
StreamFile file;
|
||||
assert(file.open(filename, "rb") != NULL);
|
||||
uint32 length;
|
||||
uint8 *data = getFileContents(filename, &length);
|
||||
assert(data != NULL);
|
||||
free(filename);
|
||||
StreamMemory file;
|
||||
file.open(data, length);
|
||||
file.read(&header, sizeof(header));
|
||||
|
||||
assert(header.imageType == 1 || header.imageType == 2);
|
||||
@@ -380,6 +379,7 @@ readTGA(const char *afilename)
|
||||
}
|
||||
|
||||
file.close();
|
||||
delete[] data;
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
@@ -311,4 +310,18 @@ found:
|
||||
return i;
|
||||
}
|
||||
|
||||
uint8*
|
||||
getFileContents(char *name, uint32 *len)
|
||||
{
|
||||
FILE *cf = fopen(name, "rb");
|
||||
assert(cf != NULL);
|
||||
fseek(cf, 0, SEEK_END);
|
||||
*len = ftell(cf);
|
||||
fseek(cf, 0, SEEK_SET);
|
||||
uint8 *data = new uint8[*len];
|
||||
fread(data, *len, 1, cf);
|
||||
fclose(cf);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
37
src/rwbase.h
37
src/rwbase.h
@@ -1,15 +1,31 @@
|
||||
#ifndef RW_PS2
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
namespace rw {
|
||||
|
||||
/* get rid of the stupid _t */
|
||||
typedef int8_t int8;
|
||||
typedef int16_t int16;
|
||||
typedef int32_t int32;
|
||||
typedef int64_t int64;
|
||||
typedef uint8_t uint8;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
typedef uintptr_t uintptr;
|
||||
#ifdef RW_PS2
|
||||
typedef char int8;
|
||||
typedef short int16;
|
||||
typedef int int32;
|
||||
typedef long long int64;
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned int uint32;
|
||||
typedef unsigned long long uint64;
|
||||
typedef unsigned int uintptr;
|
||||
#else
|
||||
/* get rid of the stupid _t */
|
||||
typedef int8_t int8;
|
||||
typedef int16_t int16;
|
||||
typedef int32_t int32;
|
||||
typedef int64_t int64;
|
||||
typedef uint8_t uint8;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint64_t uint64;
|
||||
typedef uintptr_t uintptr;
|
||||
#endif
|
||||
|
||||
typedef float float32;
|
||||
typedef int32 bool32;
|
||||
@@ -165,4 +181,5 @@ bool readChunkHeaderInfo(Stream *s, ChunkHeaderInfo *header);
|
||||
bool findChunk(Stream *s, uint32 type, uint32 *length, uint32 *version);
|
||||
|
||||
int32 findPointer(void *p, void **list, int32 num);
|
||||
uint8 *getFileContents(char *name, uint32 *len);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user