mirror of
https://github.com/glest/glest-source.git
synced 2025-08-19 06:31:19 +02:00
- some decent render improvement for surface terrain rendering (combined willvar's layer idea with visible quad, but no using vbo's at this point only vertex arrays)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "vec.h"
|
||||
#include "types.h"
|
||||
#include <map>
|
||||
#include "checksum.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::string;
|
||||
@@ -27,6 +28,7 @@ using Shared::Platform::int32;
|
||||
using Shared::Platform::uint32;
|
||||
using Shared::Platform::uint64;
|
||||
using Shared::Platform::float32;
|
||||
using Shared::Util::Checksum;
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
@@ -188,6 +190,7 @@ protected:
|
||||
int components;
|
||||
uint8 *pixels;
|
||||
string path;
|
||||
Checksum crc;
|
||||
|
||||
public:
|
||||
//constructor & destructor
|
||||
@@ -210,6 +213,8 @@ public:
|
||||
void deletePixels();
|
||||
string getPath() const { return path;}
|
||||
uint64 getPixelByteCount() const;
|
||||
|
||||
Checksum * getCRC() { return &crc; }
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
@@ -223,6 +228,8 @@ protected:
|
||||
int components;
|
||||
uint8 *pixels;
|
||||
string path;
|
||||
Checksum crc;
|
||||
|
||||
public:
|
||||
//constructor & destructor
|
||||
Pixmap2D();
|
||||
@@ -289,6 +296,8 @@ public:
|
||||
string getPath() const { return path;}
|
||||
uint64 getPixelByteCount() const;
|
||||
|
||||
Checksum * getCRC() { return &crc; }
|
||||
|
||||
private:
|
||||
bool doDimensionsAgree(const Pixmap2D *pixmap);
|
||||
};
|
||||
@@ -306,6 +315,7 @@ protected:
|
||||
int slice;
|
||||
uint8 *pixels;
|
||||
string path;
|
||||
Checksum crc;
|
||||
|
||||
public:
|
||||
//constructor & destructor
|
||||
@@ -333,6 +343,8 @@ public:
|
||||
void deletePixels();
|
||||
string getPath() const { return path;}
|
||||
uint64 getPixelByteCount() const;
|
||||
|
||||
Checksum * getCRC() { return &crc; }
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
@@ -353,6 +365,7 @@ public:
|
||||
protected:
|
||||
Pixmap2D faces[6];
|
||||
string path[6];
|
||||
Checksum crc;
|
||||
|
||||
public:
|
||||
//init
|
||||
@@ -370,6 +383,8 @@ public:
|
||||
void deletePixels();
|
||||
string getPath(int face) const { return path[face];}
|
||||
uint64 getPixelByteCount() const;
|
||||
|
||||
Checksum * getCRC() { return &crc; }
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -90,6 +90,8 @@ public:
|
||||
virtual void setForceCompressionDisabled(bool value) { forceCompressionDisabled = value;}
|
||||
virtual bool getForceCompressionDisabled() const {return forceCompressionDisabled;}
|
||||
|
||||
virtual uint32 getCRC() = 0;
|
||||
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
@@ -112,6 +114,7 @@ public:
|
||||
virtual int getTextureWidth() const {return pixmap.getW();}
|
||||
virtual int getTextureHeight() const {return -1;}
|
||||
|
||||
virtual uint32 getCRC() { return pixmap.getCRC()->getSum(); }
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
@@ -133,6 +136,8 @@ public:
|
||||
|
||||
virtual int getTextureWidth() const {return pixmap.getW();}
|
||||
virtual int getTextureHeight() const {return pixmap.getH();}
|
||||
|
||||
virtual uint32 getCRC() { return pixmap.getCRC()->getSum(); }
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
@@ -154,6 +159,8 @@ public:
|
||||
|
||||
virtual int getTextureWidth() const {return pixmap.getW();}
|
||||
virtual int getTextureHeight() const {return pixmap.getH();}
|
||||
|
||||
virtual uint32 getCRC() { return pixmap.getCRC()->getSum(); }
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
@@ -175,6 +182,8 @@ public:
|
||||
|
||||
virtual int getTextureWidth() const {return -1;}
|
||||
virtual int getTextureHeight() const {return -1;}
|
||||
|
||||
virtual uint32 getCRC() { return pixmap.getCRC()->getSum(); }
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
@@ -85,6 +85,13 @@ struct TargaFileHeader{
|
||||
const int tgaUncompressedRgb= 2;
|
||||
const int tgaUncompressedBw= 3;
|
||||
|
||||
void CalculatePixelsCRC(uint8 *pixels,uint64 pixelByteCount, Checksum &crc) {
|
||||
// crc = Checksum();
|
||||
// for(uint64 i = 0; i < pixelByteCount; ++i) {
|
||||
// crc.addByte(pixels[i]);
|
||||
// }
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
// class PixmapIoTga
|
||||
// =====================================================
|
||||
@@ -732,12 +739,14 @@ void Pixmap1D::init(int components){
|
||||
this->w= -1;
|
||||
this->components= components;
|
||||
pixels= NULL;
|
||||
CalculatePixelsCRC(pixels,0, crc);
|
||||
}
|
||||
|
||||
void Pixmap1D::init(int w, int components){
|
||||
this->w= w;
|
||||
this->components= components;
|
||||
pixels= new uint8[(std::size_t)getPixelByteCount()];
|
||||
CalculatePixelsCRC(pixels,0, crc);
|
||||
}
|
||||
|
||||
uint64 Pixmap1D::getPixelByteCount() const {
|
||||
@@ -765,6 +774,7 @@ void Pixmap1D::load(const string &path) {
|
||||
throw runtime_error("Unknown pixmap extension: " + extension);
|
||||
}
|
||||
this->path = path;
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
void Pixmap1D::loadBmp(const string &path) {
|
||||
@@ -862,6 +872,7 @@ void Pixmap2D::init(int components) {
|
||||
this->components= components;
|
||||
deletePixels();
|
||||
pixels= NULL;
|
||||
CalculatePixelsCRC(pixels,0, crc);
|
||||
}
|
||||
|
||||
void Pixmap2D::init(int w, int h, int components) {
|
||||
@@ -876,6 +887,7 @@ void Pixmap2D::init(int w, int h, int components) {
|
||||
throw runtime_error(szBuf);
|
||||
}
|
||||
pixels= new uint8[(std::size_t)getPixelByteCount()];
|
||||
CalculatePixelsCRC(pixels,0, crc);
|
||||
}
|
||||
|
||||
uint64 Pixmap2D::getPixelByteCount() const {
|
||||
@@ -909,6 +921,7 @@ void Pixmap2D::Scale(int format, int newW, int newH) {
|
||||
assertGl();
|
||||
}
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
Pixmap2D* Pixmap2D::loadPath(const string& path) {
|
||||
@@ -917,6 +930,7 @@ Pixmap2D* Pixmap2D::loadPath(const string& path) {
|
||||
Pixmap2D *pixmap = FileReader<Pixmap2D>::readPath(path);
|
||||
if(pixmap != NULL) {
|
||||
pixmap->path = path;
|
||||
CalculatePixelsCRC(pixmap->pixels,pixmap->getPixelByteCount(), pixmap->crc);
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
@@ -925,6 +939,7 @@ void Pixmap2D::load(const string &path) {
|
||||
//printf("Loading Pixmap2D [%s]\n",path.c_str());
|
||||
|
||||
FileReader<Pixmap2D>::readPath(path,this);
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
this->path = path;
|
||||
}
|
||||
|
||||
@@ -1024,6 +1039,7 @@ void Pixmap2D::setPixel(int x, int y, const uint8 *value) {
|
||||
int index = (w*y+x)*components+i;
|
||||
pixels[index]= value[i];
|
||||
}
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
void Pixmap2D::setPixel(int x, int y, const float32 *value) {
|
||||
@@ -1031,16 +1047,19 @@ void Pixmap2D::setPixel(int x, int y, const float32 *value) {
|
||||
int index = (w*y+x)*components+i;
|
||||
pixels[index]= static_cast<uint8>(value[i]*255.f);
|
||||
}
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
void Pixmap2D::setComponent(int x, int y, int component, uint8 value) {
|
||||
int index = (w*y+x)*components+component;
|
||||
pixels[index] = value;
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
void Pixmap2D::setComponent(int x, int y, int component, float32 value) {
|
||||
int index = (w*y+x)*components+component;
|
||||
pixels[index]= static_cast<uint8>(value*255.f);
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
//vector set
|
||||
@@ -1049,6 +1068,7 @@ void Pixmap2D::setPixel(int x, int y, const Vec3f &p) {
|
||||
int index = (w*y+x)*components+i;
|
||||
pixels[index]= static_cast<uint8>(p.ptr()[i]*255.f);
|
||||
}
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
void Pixmap2D::setPixel(int x, int y, const Vec4f &p) {
|
||||
@@ -1056,11 +1076,13 @@ void Pixmap2D::setPixel(int x, int y, const Vec4f &p) {
|
||||
int index = (w*y+x)*components+i;
|
||||
pixels[index]= static_cast<uint8>(p.ptr()[i]*255.f);
|
||||
}
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
void Pixmap2D::setPixel(int x, int y, float p) {
|
||||
int index = (w*y+x)*components;
|
||||
pixels[index]= static_cast<uint8>(p*255.f);
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
void Pixmap2D::setPixels(const uint8 *value){
|
||||
@@ -1069,6 +1091,7 @@ void Pixmap2D::setPixels(const uint8 *value){
|
||||
setPixel(i, j, value);
|
||||
}
|
||||
}
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
void Pixmap2D::setPixels(const float32 *value){
|
||||
@@ -1077,6 +1100,7 @@ void Pixmap2D::setPixels(const float32 *value){
|
||||
setPixel(i, j, value);
|
||||
}
|
||||
}
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
void Pixmap2D::setComponents(int component, uint8 value){
|
||||
@@ -1086,6 +1110,7 @@ void Pixmap2D::setComponents(int component, uint8 value){
|
||||
setComponent(i, j, component, value);
|
||||
}
|
||||
}
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
void Pixmap2D::setComponents(int component, float32 value){
|
||||
@@ -1095,6 +1120,7 @@ void Pixmap2D::setComponents(int component, float32 value){
|
||||
setComponent(i, j, component, value);
|
||||
}
|
||||
}
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
float splatDist(Vec2i a, Vec2i b){
|
||||
@@ -1180,6 +1206,8 @@ void Pixmap2D::copy(const Pixmap2D *sourcePixmap){
|
||||
throw runtime_error("Pixmap2D::copy() dimensions must agree");
|
||||
}
|
||||
memcpy(pixels, sourcePixmap->getPixels(), w*h*sourcePixmap->getComponents());
|
||||
this->path = sourcePixmap->path;
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
void Pixmap2D::subCopy(int x, int y, const Pixmap2D *sourcePixmap){
|
||||
@@ -1197,6 +1225,7 @@ void Pixmap2D::subCopy(int x, int y, const Pixmap2D *sourcePixmap){
|
||||
setPixel(i+x, j+y, pixel);
|
||||
}
|
||||
}
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
|
||||
delete [] pixel;
|
||||
}
|
||||
@@ -1236,6 +1265,7 @@ void Pixmap3D::init(int w, int h, int d, int components){
|
||||
this->d= d;
|
||||
this->components= components;
|
||||
pixels= new uint8[(std::size_t)getPixelByteCount()];
|
||||
CalculatePixelsCRC(pixels,0, crc);
|
||||
}
|
||||
|
||||
uint64 Pixmap3D::getPixelByteCount() const {
|
||||
@@ -1248,6 +1278,7 @@ void Pixmap3D::init(int d, int components){
|
||||
this->d= d;
|
||||
this->components= components;
|
||||
pixels= NULL;
|
||||
CalculatePixelsCRC(pixels,0, crc);
|
||||
}
|
||||
|
||||
void Pixmap3D::init(int components) {
|
||||
@@ -1256,6 +1287,7 @@ void Pixmap3D::init(int components) {
|
||||
this->d= -1;
|
||||
this->components= components;
|
||||
pixels= NULL;
|
||||
CalculatePixelsCRC(pixels,0, crc);
|
||||
}
|
||||
|
||||
void Pixmap3D::deletePixels() {
|
||||
@@ -1283,6 +1315,7 @@ void Pixmap3D::loadSlice(const string &path, int slice) {
|
||||
throw runtime_error("Unknown pixmap extension: "+extension);
|
||||
}
|
||||
this->path = path;
|
||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||
}
|
||||
|
||||
void Pixmap3D::loadSlicePng(const string &path, int slice) {
|
||||
|
Reference in New Issue
Block a user