mirror of
https://github.com/aap/librw.git
synced 2025-12-19 08:59:51 +00:00
Changed naming convention and clean up somewhat. ps2 test no longer links :(
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
namespace rw {
|
||||
namespace gl {
|
||||
|
||||
GLint linkProgram(GLint vertshader, GLint fragshader);
|
||||
GLint compileShader(const char **src, int count, int type);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "rwtest.h"
|
||||
|
||||
namespace rw {
|
||||
namespace gl {
|
||||
|
||||
GLint
|
||||
@@ -59,3 +60,4 @@ compileShader(const char **src, int count, int type)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,21 +9,21 @@ Camera *camera;
|
||||
GLint program;
|
||||
GLuint vbo;
|
||||
|
||||
Rw::Clump *clump;
|
||||
rw::Clump *clump;
|
||||
|
||||
char *filename;
|
||||
|
||||
void
|
||||
renderAtomic(Rw::Atomic *atomic)
|
||||
renderAtomic(rw::Atomic *atomic)
|
||||
{
|
||||
using namespace Rw;
|
||||
using namespace rw;
|
||||
static GLenum prim[] = {
|
||||
GL_TRIANGLES, GL_TRIANGLE_STRIP
|
||||
};
|
||||
Geometry *geo = atomic->geometry;
|
||||
if(!(geo->geoflags & Geometry::NATIVE))
|
||||
Gl::Instance(atomic);
|
||||
Gl::InstanceDataHeader *inst = (Gl::InstanceDataHeader*)geo->instData;
|
||||
gl::instance(atomic);
|
||||
gl::InstanceDataHeader *inst = (gl::InstanceDataHeader*)geo->instData;
|
||||
MeshHeader *meshHeader = geo->meshHeader;
|
||||
|
||||
Frame *frm = atomic->frame;
|
||||
@@ -34,10 +34,10 @@ renderAtomic(Rw::Atomic *atomic)
|
||||
glVertexAttrib4f(3, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib3f(2, 0.0f, 0.0f, 0.0f);
|
||||
if(inst->vbo == 0 && inst->ibo == 0)
|
||||
Gl::UploadGeo(geo);
|
||||
gl::uploadGeo(geo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, inst->vbo);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, inst->ibo);
|
||||
Gl::SetAttribPointers(inst);
|
||||
gl::setAttribPointers(inst);
|
||||
|
||||
uint64 offset = 0;
|
||||
for(uint32 i = 0; i < meshHeader->numMeshes; i++){
|
||||
@@ -50,7 +50,7 @@ renderAtomic(Rw::Atomic *atomic)
|
||||
color[3] = col[3] / 255.0f;
|
||||
glUniform4fv(glGetUniformLocation(program, "matColor"),
|
||||
1, color);
|
||||
Rw::Gl::Texture *tex =(Rw::Gl::Texture*)mesh->material->texture;
|
||||
rw::gl::Texture *tex =(rw::gl::Texture*)mesh->material->texture;
|
||||
if(tex)
|
||||
tex->bind(0);
|
||||
else
|
||||
@@ -92,9 +92,9 @@ render(void)
|
||||
glDisableVertexAttribArray(0);
|
||||
glDisableVertexAttribArray(3);
|
||||
|
||||
for(Rw::uint32 i = 0; i < clump->numAtomics; i++){
|
||||
for(rw::uint32 i = 0; i < clump->numAtomics; i++){
|
||||
char *name = PLUGINOFFSET(char, clump->atomicList[i]->frame,
|
||||
Rw::NodeNameOffset);
|
||||
gta::nodeNameOffset);
|
||||
if(strstr(name, "_dam") || strstr(name, "_vlo"))
|
||||
continue;
|
||||
renderAtomic(clump->atomicList[i]);
|
||||
@@ -145,12 +145,12 @@ init(void)
|
||||
"}\n"
|
||||
"#endif\n";
|
||||
const char *srcarr[] = { "#define VERTEX", shadersrc };
|
||||
GLint vertshader = gl::compileShader(srcarr, 2, GL_VERTEX_SHADER);
|
||||
GLint vertshader = rw::gl::compileShader(srcarr, 2, GL_VERTEX_SHADER);
|
||||
assert(vertshader != 0);
|
||||
srcarr[0] = "#define FRAGMENT";
|
||||
GLint fragshader = gl::compileShader(srcarr, 2, GL_FRAGMENT_SHADER);
|
||||
GLint fragshader = rw::gl::compileShader(srcarr, 2, GL_FRAGMENT_SHADER);
|
||||
assert(fragshader != 0);
|
||||
program = gl::linkProgram(vertshader, fragshader);
|
||||
program = rw::gl::linkProgram(vertshader, fragshader);
|
||||
assert(program != 0);
|
||||
|
||||
GLfloat vertarray[] = {
|
||||
@@ -181,31 +181,31 @@ init(void)
|
||||
camera->setTarget(Vec3(0.0f, 0.0f, 0.0f));
|
||||
camera->setPosition(Vec3(0.0f, 5.0f, 0.0f));
|
||||
|
||||
Rw::CurrentTexDictionary = new Rw::TexDictionary;
|
||||
// Rw::Image::setSearchPath("/home/aap/gamedata/ps2/gtasa/models/gta3_archive/txd_extracted/");
|
||||
// Rw::Image::setSearchPath("/home/aap/gamedata/ps2/gtavc/MODELS/gta3_archive/txd_extracted/");
|
||||
Rw::Image::setSearchPath(
|
||||
rw::currentTexDictionary = new rw::TexDictionary;
|
||||
// rw::Image::setSearchPath("/home/aap/gamedata/ps2/gtasa/models/gta3_archive/txd_extracted/");
|
||||
// rw::Image::setSearchPath("/home/aap/gamedata/ps2/gtavc/MODELS/gta3_archive/txd_extracted/");
|
||||
rw::Image::setSearchPath(
|
||||
"/home/aap/gamedata/ps2/gta3/MODELS/gta3_archive/txd_extracted/;//home/aap/gamedata/ps2/gtavc/MODELS/gta3_archive/txd_extracted/;/home/aap/gamedata/ps2/gtasa/models/gta3_archive/txd_extracted/");
|
||||
//"D:\\rockstargames\\ps2\\gtavc\\MODELS\\gta3_archive\\txd_extracted\\;D:\\rockstargames\\ps2\\gtasa\\models\\gta3_archive\\txd_extracted\\");
|
||||
Rw::Gl::RegisterNativeRaster();
|
||||
Rw::RegisterMaterialRightsPlugin();
|
||||
Rw::RegisterMatFXPlugin();
|
||||
Rw::RegisterAtomicRightsPlugin();
|
||||
Rw::RegisterHAnimPlugin();
|
||||
Rw::RegisterNodeNamePlugin();
|
||||
Rw::RegisterBreakableModelPlugin();
|
||||
Rw::RegisterExtraVertColorPlugin();
|
||||
Rw::Ps2::RegisterADCPlugin();
|
||||
Rw::RegisterSkinPlugin();
|
||||
Rw::RegisterNativeDataPlugin();
|
||||
// Rw::Ps2::RegisterNativeDataPlugin();
|
||||
Rw::RegisterMeshPlugin();
|
||||
rw::gl::registerNativeRaster();
|
||||
rw::registerMaterialRightsPlugin();
|
||||
rw::registerMatFXPlugin();
|
||||
rw::registerAtomicRightsPlugin();
|
||||
rw::registerHAnimPlugin();
|
||||
gta::registerNodeNamePlugin();
|
||||
gta::registerBreakableModelPlugin();
|
||||
gta::registerExtraVertColorPlugin();
|
||||
rw::ps2::registerADCPlugin();
|
||||
rw::registerSkinPlugin();
|
||||
rw::registerNativeDataPlugin();
|
||||
// rw::ps2::registerNativeDataPlugin();
|
||||
rw::registerMeshPlugin();
|
||||
|
||||
Rw::StreamFile in;
|
||||
rw::StreamFile in;
|
||||
if(in.open(filename, "rb") == NULL)
|
||||
printf("couldn't open file\n");
|
||||
Rw::FindChunk(&in, Rw::ID_CLUMP, NULL, NULL);
|
||||
clump = Rw::Clump::streamRead(&in);
|
||||
rw::findChunk(&in, rw::ID_CLUMP, NULL, NULL);
|
||||
clump = rw::Clump::streamRead(&in);
|
||||
assert(clump);
|
||||
in.close();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
CC=ee-gcc
|
||||
CXX=ee-g++
|
||||
AS=ee-g++
|
||||
LD=ee-g++
|
||||
LD=ee-g++ -v
|
||||
DVPAS=ee-dvp-as
|
||||
|
||||
LINK=-T$(PS2SDK)/ee/startup/linkfile
|
||||
LINK=-T$(PS2SDK)/ee/startup/linkfile $(PS2SDK)/ee/startup/crt0.o
|
||||
#LINK=-T$(PS2SDK)/ee/startup/linkfile $(PS2DEV)/ee/lib/gcc-lib/ee/3.2.2/crti.o $(PS2DEV)/ee/lib/gcc-lib/ee/3.2.2/crtbegin.o $(PS2SDK)/ee/startup/crt0.o
|
||||
LIBPATH=-L$(PS2SDK)/ee/lib
|
||||
INCPATH=-I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I$(HOME)/src/librw
|
||||
LIBS=$(HOME)/src/librw/librw-ps2.a -lc -lc -lkernel -lmf # g++ throws one -lc away, why? (unless -nostdlib)
|
||||
#LIBS=-nostdlib $(HOME)/src/librw/librw-ps2.a -lc -lkernel -lmf -lstdc++ -lm -lc -lgcc -lgcc $(PS2DEV)/ee/lib/gcc-lib/ee/3.2.2/crtend.o $(PS2DEV)/ee/lib/gcc-lib/ee/3.2.2/crtn.o
|
||||
|
||||
CFLAGS = -c -Wall -nostdlib -fno-common -DPS2_EE $(INCPATH)
|
||||
ASFLAGS = -c -xassembler-with-cpp
|
||||
@@ -20,8 +22,7 @@ HEADER=dma.h ee_regs.h gif.h gs.h mips_regs.h ps2.h math.h mesh.h
|
||||
OBJ=$(C_SRC:.cpp=.o) $(S_SRC:.s=.o) vu.o defaultpipe.o skinpipe.o
|
||||
|
||||
$(OUT).elf: $(OBJ) $(HEADER)
|
||||
$(LD) $(LDFLAGS) $(PS2SDK)/ee/startup/crt0.o \
|
||||
$(LINK) $(OBJ) $(LIBS) -o $(OUT).elf
|
||||
$(LD) $(LDFLAGS) $(LINK) $(OBJ) $(LIBS) -o $(OUT).elf
|
||||
|
||||
.cpp.o: $(HEADER)
|
||||
$(CXX) $(CFLAGS) $< -o $@
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
//#include <cstdio>
|
||||
//#include <cstring>
|
||||
//#define _USE_MATH_DEFINES
|
||||
//#include <cmath>
|
||||
//#include <cassert>
|
||||
#include <fstream>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <rw.h>
|
||||
#include <src/gtaplg.h>
|
||||
|
||||
#include "ps2.h"
|
||||
#include "dma.h"
|
||||
#include "gif.h"
|
||||
@@ -9,9 +16,6 @@
|
||||
#include "math.h"
|
||||
#include "mesh.h"
|
||||
|
||||
#include <rw.h>
|
||||
#include <src/gtaplg.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
extern uint32 MyDmaPacket[];
|
||||
@@ -26,21 +30,21 @@ extern uint32 geometryCall[];
|
||||
extern uint32 defaultPipe[];
|
||||
extern uint32 skinPipe[];
|
||||
|
||||
Rw::Clump *clump;
|
||||
rw::Clump *clump;
|
||||
|
||||
void
|
||||
drawAtomic(Rw::Atomic *atomic)
|
||||
drawAtomic(rw::Atomic *atomic)
|
||||
{
|
||||
Rw::Geometry *geo = atomic->geometry;
|
||||
rw::Geometry *geo = atomic->geometry;
|
||||
assert(geo->instData != NULL);
|
||||
Rw::Ps2::InstanceDataHeader *instData =
|
||||
(Rw::Ps2::InstanceDataHeader*)geo->instData;
|
||||
rw::ps2::InstanceDataHeader *instData =
|
||||
(rw::ps2::InstanceDataHeader*)geo->instData;
|
||||
|
||||
atomic->frame->updateLTM();
|
||||
matMult(vuMat, atomic->frame->ltm);
|
||||
for(int i = 0; i < instData->numMeshes; i++){
|
||||
if(instData->instanceMeshes[i].arePointersFixed == 0)
|
||||
Rw::Ps2::fixDmaOffsets(&instData->instanceMeshes[i]);
|
||||
rw::ps2::fixDmaOffsets(&instData->instanceMeshes[i]);
|
||||
geometryCall[1] = (uint32)instData->instanceMeshes[i].data;
|
||||
|
||||
vuGIFtag[0] = MAKE_GIF_TAG(0,1,1,0xC,0,2);
|
||||
@@ -49,9 +53,9 @@ drawAtomic(Rw::Atomic *atomic)
|
||||
vuMatcolor[1] = 1.0f;
|
||||
vuMatcolor[2] = 1.0f;
|
||||
vuMatcolor[3] = 0.5f;
|
||||
Rw::Skin *skin =
|
||||
*PLUGINOFFSET(Rw::Skin*, geo, Rw::SkinGlobals.offset);
|
||||
if(Rw::SkinGlobals.offset && skin){
|
||||
rw::Skin *skin =
|
||||
*PLUGINOFFSET(rw::Skin*, geo, rw::skinGlobals.offset);
|
||||
if(rw::skinGlobals.offset && skin){
|
||||
geometryCall[3] = 0x020000DC;
|
||||
mpgCall[1] = (uint32)skinPipe;
|
||||
}else{
|
||||
@@ -90,7 +94,7 @@ draw(void)
|
||||
|
||||
for(int i = 0; i < clump->numAtomics; i++){
|
||||
char *name = PLUGINOFFSET(char, clump->atomicList[i]->frame,
|
||||
Rw::NodeNameOffset);
|
||||
gta::nodeNameOffset);
|
||||
if(strstr(name, "_dam") || strstr(name, "_vlo"))
|
||||
continue;
|
||||
matCopy(m, vuMat);
|
||||
@@ -119,19 +123,19 @@ main()
|
||||
gsInit();
|
||||
printf("hallo\n");
|
||||
|
||||
Rw::RegisterMaterialRightsPlugin();
|
||||
Rw::RegisterMatFXPlugin();
|
||||
Rw::RegisterAtomicRightsPlugin();
|
||||
Rw::RegisterNodeNamePlugin();
|
||||
Rw::RegisterBreakableModelPlugin();
|
||||
Rw::RegisterExtraVertColorPlugin();
|
||||
Rw::Ps2::RegisterADCPlugin();
|
||||
Rw::RegisterSkinPlugin();
|
||||
Rw::RegisterNativeDataPlugin();
|
||||
// Rw::Ps2::RegisterNativeDataPlugin();
|
||||
Rw::RegisterMeshPlugin();
|
||||
rw::registerMaterialRightsPlugin();
|
||||
rw::registerMatFXPlugin();
|
||||
rw::registerAtomicRightsPlugin();
|
||||
gta::registerNodeNamePlugin();
|
||||
gta::registerBreakableModelPlugin();
|
||||
gta::registerExtraVertColorPlugin();
|
||||
rw::ps2::registerADCPlugin();
|
||||
rw::registerSkinPlugin();
|
||||
rw::registerNativeDataPlugin();
|
||||
// rw::ps2::registerNativeDataPlugin();
|
||||
rw::registerMeshPlugin();
|
||||
|
||||
// Rw::StreamFile in;
|
||||
// rw::StreamFile in;
|
||||
// in.open("host:player-vc-ps2.dff", "rb");
|
||||
|
||||
// FILE *cf = fopen("host:player-vc-ps2.dff", "rb");
|
||||
@@ -139,25 +143,25 @@ main()
|
||||
// FILE *cf = fopen("host:admiral-ps2.dff", "rb");
|
||||
assert(cf != NULL);
|
||||
fseek(cf, 0, SEEK_END);
|
||||
Rw::uint32 len = ftell(cf);
|
||||
rw::uint32 len = ftell(cf);
|
||||
fseek(cf, 0, SEEK_SET);
|
||||
Rw::uint8 *data = new Rw::uint8[len];
|
||||
rw::uint8 *data = new rw::uint8[len];
|
||||
fread(data, len, 1, cf);
|
||||
fclose(cf);
|
||||
Rw::StreamMemory in;
|
||||
rw::StreamMemory in;
|
||||
in.open(data, len);
|
||||
|
||||
printf("opened file\n");
|
||||
Rw::FindChunk(&in, Rw::ID_CLUMP, NULL, NULL);
|
||||
rw::findChunk(&in, rw::ID_CLUMP, NULL, NULL);
|
||||
printf("found chunk\n");
|
||||
clump = Rw::Clump::streamRead(&in);
|
||||
clump = rw::Clump::streamRead(&in);
|
||||
printf("read file\n");
|
||||
in.close();
|
||||
printf("closed file\n");
|
||||
delete[] data;
|
||||
|
||||
data = new Rw::uint8[256*1024];
|
||||
Rw::StreamMemory out;
|
||||
data = new rw::uint8[256*1024];
|
||||
rw::StreamMemory out;
|
||||
out.open(data, 0, 256*1024);
|
||||
clump->streamWrite(&out);
|
||||
// cf = fopen("host:out-ps2.dff", "wb");
|
||||
@@ -167,7 +171,7 @@ main()
|
||||
out.close();
|
||||
delete[] data;
|
||||
|
||||
// Rw::StreamFile out;
|
||||
// rw::StreamFile out;
|
||||
// out.open("host:out-ps2.dff", "wb");
|
||||
// c->streamWrite(&out);
|
||||
// out.close();
|
||||
@@ -178,9 +182,9 @@ main()
|
||||
vuOffset[1] = 2048.0f;
|
||||
|
||||
for(int i = 0; i < clump->numAtomics; i++){
|
||||
Rw::Atomic *a = clump->atomicList[i];
|
||||
rw::Atomic *a = clump->atomicList[i];
|
||||
char *name =
|
||||
PLUGINOFFSET(char, a->frame, Rw::NodeNameOffset);
|
||||
PLUGINOFFSET(char, a->frame, gta::nodeNameOffset);
|
||||
printf("%s\n", name);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#include "math.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user