mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-04 02:24:00 +00:00
cleanup #2, no functional changes
This commit is contained in:
parent
8f524279b3
commit
58df545ec8
4 changed files with 15 additions and 144 deletions
138
BBGE/Core.cpp
138
BBGE/Core.cpp
|
@ -1465,7 +1465,7 @@ void Core::run(float runTime)
|
||||||
{
|
{
|
||||||
doScreenshot = false;
|
doScreenshot = false;
|
||||||
|
|
||||||
saveScreenshotTGA(getScreenshotFilename());
|
saveScreenshot(getScreenshotFilename());
|
||||||
prepScreen(0);
|
prepScreen(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2612,146 +2612,14 @@ unsigned char *Core::grabCenteredScreenshot(int w, int h)
|
||||||
return grabScreenshot(core->width/2 - w/2, core->height/2 - h/2, w, h);
|
return grabScreenshot(core->width/2 - w/2, core->height/2 - h/2, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
// takes a screen shot and saves it to a TGA image
|
// takes a screen shot and saves it to a TGA or PNG image
|
||||||
int Core::saveScreenshotTGA(const std::string &filename)
|
int Core::saveScreenshot(const std::string &filename)
|
||||||
{
|
{
|
||||||
int w = getWindowWidth(), h = getWindowHeight();
|
int w = getWindowWidth(), h = getWindowHeight();
|
||||||
unsigned char *imageData = grabCenteredScreenshot(w, h);
|
unsigned char *imageData = grabCenteredScreenshot(w, h);
|
||||||
return tgaSave(filename.c_str(),w,h,32,imageData);
|
return tgaSave(filename.c_str(),w,h,32,imageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::saveCenteredScreenshotTGA(const std::string &filename, int sz)
|
|
||||||
{
|
|
||||||
int w=sz, h=sz;
|
|
||||||
int hsm = (w * 3.0f) / 4.0f;
|
|
||||||
unsigned char *imageData = grabCenteredScreenshot(w, hsm);
|
|
||||||
|
|
||||||
int imageDataSize = sizeof(unsigned char) * w * hsm * 4;
|
|
||||||
int tgaImageSize = sizeof(unsigned char) * w * h * 4;
|
|
||||||
unsigned char *tgaImage = new unsigned char[tgaImageSize];
|
|
||||||
memcpy(tgaImage, imageData, imageDataSize);
|
|
||||||
memset(tgaImage + imageDataSize, 0, tgaImageSize - imageDataSize);
|
|
||||||
delete[] imageData;
|
|
||||||
|
|
||||||
int savebits = 32;
|
|
||||||
tgaSave(filename.c_str(),w,h,savebits,tgaImage);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Core::saveSizedScreenshotTGA(const std::string &filename, int sz, int crop34)
|
|
||||||
{
|
|
||||||
debugLog("saveSizedScreenshot");
|
|
||||||
|
|
||||||
int w, h;
|
|
||||||
unsigned char *imageData;
|
|
||||||
w = sz;
|
|
||||||
h = sz;
|
|
||||||
float fsz = (float)sz;
|
|
||||||
|
|
||||||
unsigned int size = sizeof(unsigned char) * w * h * 3;
|
|
||||||
imageData = (unsigned char *)malloc(size);
|
|
||||||
|
|
||||||
float wbit = fsz;
|
|
||||||
float hbit = ((fsz)*(3.0f/4.0f));
|
|
||||||
|
|
||||||
int width = core->width-1;
|
|
||||||
int height = core->height-1;
|
|
||||||
int diff = 0;
|
|
||||||
|
|
||||||
if (crop34)
|
|
||||||
{
|
|
||||||
width = int((core->height*4.0f)/3.0f);
|
|
||||||
diff = (core->width - width)/2;
|
|
||||||
width--;
|
|
||||||
}
|
|
||||||
|
|
||||||
float zx = wbit/(float)width;
|
|
||||||
float zy = hbit/(float)height;
|
|
||||||
|
|
||||||
float copyw = w*(1/zx);
|
|
||||||
float copyh = h*(1/zy);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::ostringstream os;
|
|
||||||
os << "wbit: " << wbit << " hbit: " << hbit << std::endl;
|
|
||||||
os << "zx: " << zx << " zy: " << zy << std::endl;
|
|
||||||
os << "w: " << w << " h: " << h << std::endl;
|
|
||||||
os << "width: " << width << " height: " << height << std::endl;
|
|
||||||
os << "copyw: " << copyw << " copyh: " << copyh << std::endl;
|
|
||||||
debugLog(os.str());
|
|
||||||
|
|
||||||
glRasterPos2i(0, 0);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
debugLog("pixel zoom");
|
|
||||||
glPixelZoom(zx,zy);
|
|
||||||
glFlush();
|
|
||||||
|
|
||||||
glPixelZoom(1,1);
|
|
||||||
debugLog("copy pixels");
|
|
||||||
glCopyPixels(diff, 0, width, height, GL_COLOR);
|
|
||||||
glFlush();
|
|
||||||
|
|
||||||
debugLog("read pixels");
|
|
||||||
glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)imageData);
|
|
||||||
glFlush();
|
|
||||||
|
|
||||||
int savebits = 24;
|
|
||||||
debugLog("saving bpp");
|
|
||||||
tgaSave(filename.c_str(),w,h,savebits,imageData);
|
|
||||||
|
|
||||||
debugLog("pop");
|
|
||||||
|
|
||||||
|
|
||||||
debugLog("done");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Core::save64x64ScreenshotTGA(const std::string &filename)
|
|
||||||
{
|
|
||||||
int w, h;
|
|
||||||
unsigned char *imageData;
|
|
||||||
|
|
||||||
// compute width and heidth of the image
|
|
||||||
//w = xmax - xmin;
|
|
||||||
//h = ymax - ymin;
|
|
||||||
w = 64;
|
|
||||||
h = 64;
|
|
||||||
|
|
||||||
// allocate memory for the pixels
|
|
||||||
imageData = (unsigned char *)malloc(sizeof(unsigned char) * w * h * 4);
|
|
||||||
|
|
||||||
// read the pixels from the frame buffer
|
|
||||||
|
|
||||||
//glReadPixels(xmin,ymin,xmax,ymax,GL_RGBA,GL_UNSIGNED_BYTE, (GLvoid *)imageData);
|
|
||||||
glPixelZoom(64.0f/(float)getVirtualWidth(), 48.0f/(float)getVirtualHeight());
|
|
||||||
glCopyPixels(0, 0, getVirtualWidth(), getVirtualHeight(), GL_COLOR);
|
|
||||||
|
|
||||||
glReadPixels(0,0,64,64,GL_RGBA,GL_UNSIGNED_BYTE, (GLvoid *)imageData);
|
|
||||||
|
|
||||||
|
|
||||||
unsigned char *c = imageData;
|
|
||||||
for (int x=0; x < w; x++)
|
|
||||||
{
|
|
||||||
for (int y=0; y< h; y++)
|
|
||||||
{
|
|
||||||
c += 3;
|
|
||||||
(*c) = 255;
|
|
||||||
c ++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// save the image
|
|
||||||
tgaSave(filename.c_str(),64,64,32,imageData);
|
|
||||||
glPixelZoom(1,1);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// saves an array of pixels as a TGA image (frees the image data passed in)
|
// saves an array of pixels as a TGA image (frees the image data passed in)
|
||||||
int Core::tgaSave( const char *filename,
|
int Core::tgaSave( const char *filename,
|
||||||
short int width,
|
short int width,
|
||||||
|
|
|
@ -361,10 +361,7 @@ public:
|
||||||
|
|
||||||
unsigned char *grabScreenshot(int x, int y, int w, int h);
|
unsigned char *grabScreenshot(int x, int y, int w, int h);
|
||||||
unsigned char *grabCenteredScreenshot(int w, int h);
|
unsigned char *grabCenteredScreenshot(int w, int h);
|
||||||
int saveScreenshotTGA(const std::string &filename);
|
int saveScreenshot(const std::string &filename);
|
||||||
void save64x64ScreenshotTGA(const std::string &filename);
|
|
||||||
void saveSizedScreenshotTGA(const std::string &filename, int sz, int crop34);
|
|
||||||
void saveCenteredScreenshotTGA(const std::string &filename, int sz);
|
|
||||||
|
|
||||||
bool minimized;
|
bool minimized;
|
||||||
std::string getEnqueuedJumpState();
|
std::string getEnqueuedJumpState();
|
||||||
|
@ -461,7 +458,7 @@ public:
|
||||||
|
|
||||||
int tgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
|
int tgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
|
||||||
int zgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
|
int zgaSave(const char *filename, short int width, short int height, unsigned char pixelDepth, unsigned char *imageData);
|
||||||
|
int pngSave(const char *filename, unsigned width, unsigned height, unsigned char *data);
|
||||||
volatile int dbg_numThreadDecoders;
|
volatile int dbg_numThreadDecoders;
|
||||||
|
|
||||||
virtual void onBackgroundUpdate();
|
virtual void onBackgroundUpdate();
|
||||||
|
|
|
@ -42,7 +42,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT = NULL;
|
PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT = NULL;
|
||||||
PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT = NULL;
|
PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT = NULL;
|
||||||
PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT = NULL;
|
PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT = NULL;
|
||||||
PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FrameBuffer::FrameBuffer()
|
FrameBuffer::FrameBuffer()
|
||||||
|
@ -151,7 +150,6 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen)
|
||||||
glFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)SDL_GL_GetProcAddress("glFramebufferTexture3DEXT");
|
glFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)SDL_GL_GetProcAddress("glFramebufferTexture3DEXT");
|
||||||
glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)SDL_GL_GetProcAddress("glFramebufferRenderbufferEXT");
|
glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)SDL_GL_GetProcAddress("glFramebufferRenderbufferEXT");
|
||||||
glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameterivEXT");
|
glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameterivEXT");
|
||||||
glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)SDL_GL_GetProcAddress("glGenerateMipmapEXT");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !glIsRenderbufferEXT || !glBindRenderbufferEXT || !glDeleteRenderbuffersEXT ||
|
if( !glIsRenderbufferEXT || !glBindRenderbufferEXT || !glDeleteRenderbuffersEXT ||
|
||||||
|
@ -159,7 +157,7 @@ bool FrameBuffer::init(int width, int height, bool fitToScreen)
|
||||||
!glIsFramebufferEXT || !glBindFramebufferEXT || !glDeleteFramebuffersEXT ||
|
!glIsFramebufferEXT || !glBindFramebufferEXT || !glDeleteFramebuffersEXT ||
|
||||||
!glGenFramebuffersEXT || !glCheckFramebufferStatusEXT || !glFramebufferTexture1DEXT ||
|
!glGenFramebuffersEXT || !glCheckFramebufferStatusEXT || !glFramebufferTexture1DEXT ||
|
||||||
!glFramebufferTexture2DEXT || !glFramebufferTexture3DEXT || !glFramebufferRenderbufferEXT||
|
!glFramebufferTexture2DEXT || !glFramebufferTexture3DEXT || !glFramebufferRenderbufferEXT||
|
||||||
!glGetFramebufferAttachmentParameterivEXT || !glGenerateMipmapEXT )
|
!glGetFramebufferAttachmentParameterivEXT)
|
||||||
{
|
{
|
||||||
debugLog("One or more EXT_framebuffer_object functions were not found");
|
debugLog("One or more EXT_framebuffer_object functions were not found");
|
||||||
return false;
|
return false;
|
||||||
|
@ -292,7 +290,6 @@ void FrameBuffer::resetOpenGL()
|
||||||
glFramebufferTexture3DEXT = NULL;
|
glFramebufferTexture3DEXT = NULL;
|
||||||
glFramebufferRenderbufferEXT = NULL;
|
glFramebufferRenderbufferEXT = NULL;
|
||||||
glGetFramebufferAttachmentParameterivEXT = NULL;
|
glGetFramebufferAttachmentParameterivEXT = NULL;
|
||||||
glGenerateMipmapEXT = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,11 @@
|
||||||
#define GLAPIENTRY
|
#define GLAPIENTRY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "glext.h"
|
||||||
|
|
||||||
|
|
||||||
|
PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT = NULL;
|
||||||
|
|
||||||
unsigned g_dbg_numRenderCalls = 0; // extern
|
unsigned g_dbg_numRenderCalls = 0; // extern
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +53,10 @@ bool lookup_all_glsyms()
|
||||||
if (!lookup_glsym(#fn, (void **) &p##fn)) retval = false;
|
if (!lookup_glsym(#fn, (void **) &p##fn)) retval = false;
|
||||||
#include "OpenGLStubs.h"
|
#include "OpenGLStubs.h"
|
||||||
#undef GL_FUNC
|
#undef GL_FUNC
|
||||||
|
|
||||||
|
// optional functions
|
||||||
|
glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)SDL_GL_GetProcAddress("glGenerateMipmapEXT");
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -64,6 +71,8 @@ void unload_all_glsyms()
|
||||||
#include "OpenGLStubs.h"
|
#include "OpenGLStubs.h"
|
||||||
#undef GL_FUNC
|
#undef GL_FUNC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
glGenerateMipmapEXT = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue