mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 14:11:15 +02:00
- added ability to specify scaled image size of screenshots in g3d viewer example:
./megaglest_g3dviewer --load-unit=techs/megapack/factions/romans/units/catapult,attack_skill --auto-screenshot=resize-1024x768
This commit is contained in:
@@ -199,9 +199,9 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
|
|||||||
printf("\n \t\t of the optional settings:");
|
printf("\n \t\t of the optional settings:");
|
||||||
printf("\n \t\ttransparent, enable_grid, enable_wireframe,");
|
printf("\n \t\ttransparent, enable_grid, enable_wireframe,");
|
||||||
printf("\n \t\tenable_normals, disable_grid, disable_wireframe,");
|
printf("\n \t\tenable_normals, disable_grid, disable_wireframe,");
|
||||||
printf("\n \t\tdisable_normals, saveas-<filename>");
|
printf("\n \t\tdisable_normals, saveas-<filename>, resize-wxh");
|
||||||
printf("\n \t\texample:");
|
printf("\n \t\texample:");
|
||||||
printf("\n %s %s=transparent,disable_grid,saveas-test.png %s=techs/megapack/factions/tech/units/battle_machine/models/battle_machine_dying.g3d",extractFileFromDirectoryPath(argv0).c_str(),(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_AUTO_SCREENSHOT]),(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_MODEL]));
|
printf("\n %s %s=transparent,disable_grid,saveas-test.png,resize-800x600 %s=techs/megapack/factions/tech/units/battle_machine/models/battle_machine_dying.g3d",extractFileFromDirectoryPath(argv0).c_str(),(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_AUTO_SCREENSHOT]),(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_MODEL]));
|
||||||
|
|
||||||
// "================================================================================"
|
// "================================================================================"
|
||||||
printf("\n%s=x",(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_PARTICLE]));
|
printf("\n%s=x",(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_PARTICLE]));
|
||||||
@@ -950,6 +950,22 @@ void MainWindow::onMenumFileToggleScreenshotTransparent(wxCommandEvent &event) {
|
|||||||
|
|
||||||
void MainWindow::saveScreenshot() {
|
void MainWindow::saveScreenshot() {
|
||||||
try {
|
try {
|
||||||
|
std::pair<int,int> overrideSize(0,0);
|
||||||
|
for(unsigned int i = 0; i < autoScreenShotParams.size(); ++i) {
|
||||||
|
if(_strnicmp(autoScreenShotParams[i].c_str(),"resize-",7) == 0) {
|
||||||
|
printf("Screenshot option [%s]\n",autoScreenShotParams[i].c_str());
|
||||||
|
|
||||||
|
string resize = autoScreenShotParams[i];
|
||||||
|
resize = resize.erase(0,7);
|
||||||
|
vector<string> values;
|
||||||
|
Tokenize(resize,values,"x");
|
||||||
|
overrideSize.first = strToInt(values[0]);
|
||||||
|
overrideSize.second = strToInt(values[1]);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int autoSaveScreenshotIndex = -1;
|
int autoSaveScreenshotIndex = -1;
|
||||||
for(unsigned int i = 0; i < autoScreenShotParams.size(); ++i) {
|
for(unsigned int i = 0; i < autoScreenShotParams.size(); ++i) {
|
||||||
if(_strnicmp(autoScreenShotParams[i].c_str(),"saveas-",7) == 0) {
|
if(_strnicmp(autoScreenShotParams[i].c_str(),"saveas-",7) == 0) {
|
||||||
@@ -967,7 +983,7 @@ void MainWindow::saveScreenshot() {
|
|||||||
FILE *f= fopen(saveAsFilename.c_str(), "rb");
|
FILE *f= fopen(saveAsFilename.c_str(), "rb");
|
||||||
#endif
|
#endif
|
||||||
if(f == NULL) {
|
if(f == NULL) {
|
||||||
renderer->saveScreen(saveAsFilename.c_str());
|
renderer->saveScreen(saveAsFilename.c_str(),&overrideSize);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(f) {
|
if(f) {
|
||||||
@@ -1002,7 +1018,7 @@ void MainWindow::saveScreenshot() {
|
|||||||
FILE *f= fopen(path.c_str(), "rb");
|
FILE *f= fopen(path.c_str(), "rb");
|
||||||
#endif
|
#endif
|
||||||
if(f == NULL) {
|
if(f == NULL) {
|
||||||
renderer->saveScreen(path);
|
renderer->saveScreen(path,&overrideSize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -483,7 +483,7 @@ void Renderer::setAlphaColor(float alpha) {
|
|||||||
//printf("#3.1 The framebuffer uses %d bit(s) per the alpha component\n", alpha_bits);
|
//printf("#3.1 The framebuffer uses %d bit(s) per the alpha component\n", alpha_bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::saveScreen(const string &path) {
|
void Renderer::saveScreen(const string &path,std::pair<int,int> *overrideSize) {
|
||||||
Pixmap2D *pixmapScreenShot = new Pixmap2D(width, height, 4);
|
Pixmap2D *pixmapScreenShot = new Pixmap2D(width, height, 4);
|
||||||
//glFinish();
|
//glFinish();
|
||||||
|
|
||||||
@@ -494,6 +494,10 @@ void Renderer::saveScreen(const string &path) {
|
|||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
|
if(overrideSize != NULL && overrideSize->first > 0 && overrideSize->second > 0) {
|
||||||
|
pixmapScreenShot->Scale(GL_RGBA,overrideSize->first,overrideSize->second);
|
||||||
|
}
|
||||||
|
|
||||||
pixmapScreenShot->save(path);
|
pixmapScreenShot->save(path);
|
||||||
delete pixmapScreenShot;
|
delete pixmapScreenShot;
|
||||||
}
|
}
|
||||||
|
@@ -157,7 +157,7 @@ public:
|
|||||||
|
|
||||||
void setBackgroundColor(float red, float green, float blue);
|
void setBackgroundColor(float red, float green, float blue);
|
||||||
void setAlphaColor(float alpha);
|
void setAlphaColor(float alpha);
|
||||||
void saveScreen(const string &path);
|
void saveScreen(const string &path,std::pair<int,int> *overrideSize);
|
||||||
bool hasActiveParticleSystem(ParticleSystem::ParticleSystemType typeName) const;
|
bool hasActiveParticleSystem(ParticleSystem::ParticleSystemType typeName) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -916,20 +916,30 @@ Pixmap2D::~Pixmap2D() {
|
|||||||
|
|
||||||
void Pixmap2D::Scale(int format, int newW, int newH) {
|
void Pixmap2D::Scale(int format, int newW, int newH) {
|
||||||
int useComponents = this->getComponents();
|
int useComponents = this->getComponents();
|
||||||
|
int originalW = w;
|
||||||
|
int originalH = h;
|
||||||
uint8 *newpixels= new uint8[newW * newH * useComponents];
|
uint8 *newpixels= new uint8[newW * newH * useComponents];
|
||||||
|
|
||||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||||
int error = gluScaleImage( format,
|
int error = gluScaleImage( format,
|
||||||
w, h, GL_UNSIGNED_BYTE, pixels,
|
w, h, GL_UNSIGNED_BYTE, pixels,
|
||||||
newW, newH, GL_UNSIGNED_BYTE, newpixels);
|
newW, newH, GL_UNSIGNED_BYTE, newpixels);
|
||||||
if(error != GL_NO_ERROR) {
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
|
if(error == GL_NO_ERROR) {
|
||||||
init(newW,newH,this->components);
|
init(newW,newH,this->components);
|
||||||
pixels = newpixels;
|
pixels = newpixels;
|
||||||
|
|
||||||
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Scaled image from [%d x %d] to [%d x %d]\n",originalW,originalH,w,h);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assertGl();
|
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
|
||||||
|
printf("ERROR Scaling image from [%d x %d] to [%d x %d] error: %d [%s]\n",originalW,originalH,w,h,error,errorString);
|
||||||
|
|
||||||
|
GLenum glErr = error;
|
||||||
|
assertGlWithErrorNumber(glErr);
|
||||||
}
|
}
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user