mirror of https://github.com/aap/librw.git
some bug fixes
This commit is contained in:
parent
2cffb3f494
commit
b1c3c1dca8
|
@ -572,7 +572,7 @@ rasterFromImage(Raster *raster, Image *image)
|
||||||
case Raster::C1555:
|
case Raster::C1555:
|
||||||
out[0] = in[0];
|
out[0] = in[0];
|
||||||
out[1] = in[1];
|
out[1] = in[1];
|
||||||
in += 2;
|
in += inc;
|
||||||
out += 2;
|
out += 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,8 +295,8 @@ setFilterMode(uint32 stage, int32 filter)
|
||||||
// TODO: mip mapping
|
// TODO: mip mapping
|
||||||
if(rwStateCache.texstage[stage].filter != (Texture::FilterMode)filter){
|
if(rwStateCache.texstage[stage].filter != (Texture::FilterMode)filter){
|
||||||
rwStateCache.texstage[stage].filter = (Texture::FilterMode)filter;
|
rwStateCache.texstage[stage].filter = (Texture::FilterMode)filter;
|
||||||
setSamplerState(0, D3DSAMP_MAGFILTER, filterConvMap_NoMIP[filter]);
|
setSamplerState(stage, D3DSAMP_MAGFILTER, filterConvMap_NoMIP[filter]);
|
||||||
setSamplerState(0, D3DSAMP_MINFILTER, filterConvMap_NoMIP[filter]);
|
setSamplerState(stage, D3DSAMP_MINFILTER, filterConvMap_NoMIP[filter]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ setAddressU(uint32 stage, int32 addressing)
|
||||||
{
|
{
|
||||||
if(rwStateCache.texstage[stage].addressingU != (Texture::Addressing)addressing){
|
if(rwStateCache.texstage[stage].addressingU != (Texture::Addressing)addressing){
|
||||||
rwStateCache.texstage[stage].addressingU = (Texture::Addressing)addressing;
|
rwStateCache.texstage[stage].addressingU = (Texture::Addressing)addressing;
|
||||||
setSamplerState(0, D3DSAMP_ADDRESSU, addressConvMap[addressing]);
|
setSamplerState(stage, D3DSAMP_ADDRESSU, addressConvMap[addressing]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ setAddressV(uint32 stage, int32 addressing)
|
||||||
{
|
{
|
||||||
if(rwStateCache.texstage[stage].addressingV != (Texture::Addressing)addressing){
|
if(rwStateCache.texstage[stage].addressingV != (Texture::Addressing)addressing){
|
||||||
rwStateCache.texstage[stage].addressingV = (Texture::Addressing)addressing;
|
rwStateCache.texstage[stage].addressingV = (Texture::Addressing)addressing;
|
||||||
setSamplerState(0, D3DSAMP_ADDRESSV, addressConvMap[addressing]);
|
setSamplerState(stage, D3DSAMP_ADDRESSV, addressConvMap[addressing]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -236,6 +236,44 @@ setAddressV(uint32 stage, int32 addressing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setRasterStageOnly(uint32 stage, Raster *raster)
|
||||||
|
{
|
||||||
|
bool32 alpha;
|
||||||
|
if(raster != rwStateCache.texstage[stage].raster){
|
||||||
|
rwStateCache.texstage[stage].raster = raster;
|
||||||
|
setActiveTexture(GL_TEXTURE0+stage);
|
||||||
|
if(raster){
|
||||||
|
assert(raster->platform == PLATFORM_GL3);
|
||||||
|
Gl3Raster *natras = PLUGINOFFSET(Gl3Raster, raster, nativeRasterOffset);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, natras->texid);
|
||||||
|
|
||||||
|
rwStateCache.texstage[stage].filter = (rw::Texture::FilterMode)natras->filterMode;
|
||||||
|
rwStateCache.texstage[stage].addressingU = (rw::Texture::Addressing)natras->addressU;
|
||||||
|
rwStateCache.texstage[stage].addressingV = (rw::Texture::Addressing)natras->addressV;
|
||||||
|
|
||||||
|
alpha = natras->hasAlpha;
|
||||||
|
}else{
|
||||||
|
glBindTexture(GL_TEXTURE_2D, whitetex);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
alpha = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(stage == 0){
|
||||||
|
if(alpha != rwStateCache.textureAlpha){
|
||||||
|
rwStateCache.textureAlpha = alpha;
|
||||||
|
if(!rwStateCache.vertexAlpha){
|
||||||
|
(alpha ? glEnable : glDisable)(GL_BLEND);
|
||||||
|
setAlphaTest(alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setRasterStage(uint32 stage, Raster *raster)
|
setRasterStage(uint32 stage, Raster *raster)
|
||||||
{
|
{
|
||||||
|
@ -288,16 +326,14 @@ setRasterStage(uint32 stage, Raster *raster)
|
||||||
void
|
void
|
||||||
setTexture(int32 stage, Texture *tex)
|
setTexture(int32 stage, Texture *tex)
|
||||||
{
|
{
|
||||||
if(tex == nil){
|
if(tex == nil || tex->raster == nil){
|
||||||
setRasterStage(stage, nil);
|
setRasterStage(stage, nil);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(tex->raster){
|
setRasterStageOnly(stage, tex->raster);
|
||||||
setFilterMode(stage, tex->getFilter());
|
setFilterMode(stage, tex->getFilter());
|
||||||
setAddressU(stage, tex->getAddressU());
|
setAddressU(stage, tex->getAddressU());
|
||||||
setAddressV(stage, tex->getAddressV());
|
setAddressV(stage, tex->getAddressV());
|
||||||
}
|
|
||||||
setRasterStage(stage, tex->raster);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -49,6 +49,7 @@ instance(rw::ObjPipeline *rwpipe, Atomic *atomic)
|
||||||
for(uint32 i = 0; i < header->numMeshes; i++){
|
for(uint32 i = 0; i < header->numMeshes; i++){
|
||||||
findMinVertAndNumVertices(mesh->indices, mesh->numIndices,
|
findMinVertAndNumVertices(mesh->indices, mesh->numIndices,
|
||||||
&inst->minVert, &inst->numVertices);
|
&inst->minVert, &inst->numVertices);
|
||||||
|
assert(inst->minVert != 0xFFFFFFFF);
|
||||||
inst->numIndex = mesh->numIndices;
|
inst->numIndex = mesh->numIndices;
|
||||||
inst->material = mesh->material;
|
inst->material = mesh->material;
|
||||||
inst->vertexAlpha = 0;
|
inst->vertexAlpha = 0;
|
||||||
|
@ -200,6 +201,7 @@ defaultInstanceCB(Geometry *geo, InstanceDataHeader *header)
|
||||||
int n = header->numMeshes;
|
int n = header->numMeshes;
|
||||||
InstanceData *inst = header->inst;
|
InstanceData *inst = header->inst;
|
||||||
while(n--){
|
while(n--){
|
||||||
|
assert(inst->minVert != 0xFFFFFFFF);
|
||||||
inst->vertexAlpha = instColor(VERT_RGBA,
|
inst->vertexAlpha = instColor(VERT_RGBA,
|
||||||
verts + a->offset + a->stride*inst->minVert,
|
verts + a->offset + a->stride*inst->minVert,
|
||||||
geo->colors + inst->minVert,
|
geo->colors + inst->minVert,
|
||||||
|
|
|
@ -378,6 +378,7 @@ Image::unindex(void)
|
||||||
}
|
}
|
||||||
this->free();
|
this->free();
|
||||||
this->depth = ndepth;
|
this->depth = ndepth;
|
||||||
|
this->bpp = ndepth < 8 ? 1 : ndepth/8;
|
||||||
this->stride = nstride;
|
this->stride = nstride;
|
||||||
this->setPixels(npixels);
|
this->setPixels(npixels);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,10 +44,16 @@ findMinVertAndNumVertices(uint16 *indices, uint32 numIndices, uint32 *minVert, i
|
||||||
max = *indices;
|
max = *indices;
|
||||||
indices++;
|
indices++;
|
||||||
}
|
}
|
||||||
|
uint32 num = max - min + 1;
|
||||||
|
// if mesh is empty, this can happen
|
||||||
|
if(min > max){
|
||||||
|
min = 0;
|
||||||
|
num = 0;
|
||||||
|
}
|
||||||
if(minVert)
|
if(minVert)
|
||||||
*minVert = min;
|
*minVert = min;
|
||||||
if(numVertices)
|
if(numVertices)
|
||||||
*numVertices = max - min + 1;
|
*numVertices = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue