added snapshot for tinygl driver
This commit is contained in:
parent
b061c7a539
commit
94b05cfdaa
6 changed files with 33 additions and 6 deletions
2
driver.h
2
driver.h
|
@ -81,7 +81,7 @@ public:
|
||||||
|
|
||||||
virtual void drawDepthBitmap(int x, int y, int w, int h, char *data) = 0;
|
virtual void drawDepthBitmap(int x, int y, int w, int h, char *data) = 0;
|
||||||
|
|
||||||
virtual void getSnapshot(int x, int y, int w, int h, char **data, int flags) = 0;
|
virtual Bitmap *getScreenshot(int w, int h) = 0;
|
||||||
virtual void enableDim(int x, int y, int w, int h) = 0;
|
virtual void enableDim(int x, int y, int w, int h) = 0;
|
||||||
virtual void disableDim(int x, int y, int w, int h) = 0;
|
virtual void disableDim(int x, int y, int w, int h) = 0;
|
||||||
|
|
||||||
|
|
|
@ -689,7 +689,8 @@ void DriverGL::destroyTextBitmap(TextObjectHandle *handle) {
|
||||||
delete[] (GLuint *)handle->texIds;
|
delete[] (GLuint *)handle->texIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriverGL::getSnapshot(int x, int y, int w, int h, char **data, int flags) {
|
Bitmap *DriverGL::getScreenshot(int w, int h) {
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriverGL::drawDim() {
|
void DriverGL::drawDim() {
|
||||||
|
|
|
@ -65,7 +65,7 @@ public:
|
||||||
void drawDepthBitmap(int x, int y, int w, int h, char *data);
|
void drawDepthBitmap(int x, int y, int w, int h, char *data);
|
||||||
void drawBitmap();
|
void drawBitmap();
|
||||||
|
|
||||||
void getSnapshot(int x, int y, int w, int h, char **data, int flags);
|
Bitmap *getScreenshot(int w, int h);
|
||||||
void enableDim(int x, int y, int w, int h) { _dim = true; }
|
void enableDim(int x, int y, int w, int h) { _dim = true; }
|
||||||
void disableDim(int x, int y, int w, int h) { _dim = false; }
|
void disableDim(int x, int y, int w, int h) { _dim = false; }
|
||||||
|
|
||||||
|
|
|
@ -473,7 +473,22 @@ void DriverTinyGL::destroyTextBitmap(TextObjectHandle *handle) {
|
||||||
SDL_FreeSurface((SDL_Surface *)handle->surface);
|
SDL_FreeSurface((SDL_Surface *)handle->surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriverTinyGL::getSnapshot(int x, int y, int w, int h, char **data, int flags) {
|
Bitmap *DriverTinyGL::getScreenshot(int w, int h) {
|
||||||
|
uint16 *buffer = new uint16[w * h];
|
||||||
|
assert(buffer);
|
||||||
|
|
||||||
|
float step_x = 640.0 / w;
|
||||||
|
float step_y = 480.0 / h;
|
||||||
|
int step = 0;
|
||||||
|
for (float y = 0; y < 479; y += step_y) {
|
||||||
|
for (float x = 0; x < 639; x += step_x) {
|
||||||
|
buffer[step++] = *((uint16 *)(_screen->pixels) + (int)y * 640 + (int)x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Bitmap *screenshot = new Bitmap((char *)buffer, w, h, "screenshot");
|
||||||
|
delete []buffer;
|
||||||
|
return screenshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriverTinyGL::drawDim() {
|
void DriverTinyGL::drawDim() {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
void drawDepthBitmap(int x, int y, int w, int h, char *data);
|
void drawDepthBitmap(int x, int y, int w, int h, char *data);
|
||||||
void drawBitmap();
|
void drawBitmap();
|
||||||
|
|
||||||
void getSnapshot(int x, int y, int w, int h, char **data, int flags);
|
Bitmap *getScreenshot(int w, int h);
|
||||||
void enableDim(int x, int y, int w, int h) { _dim = true; }
|
void enableDim(int x, int y, int w, int h) { _dim = true; }
|
||||||
void disableDim(int x, int y, int w, int h) { _dim = false; }
|
void disableDim(int x, int y, int w, int h) { _dim = false; }
|
||||||
|
|
||||||
|
|
13
lua.cpp
13
lua.cpp
|
@ -1312,6 +1312,8 @@ static void luaFileFindFirst() {
|
||||||
std::string dir_strWin32 = path;
|
std::string dir_strWin32 = path;
|
||||||
g_searchFile = FindFirstFile(dir_strWin32.c_str(), &g_find_file_data);
|
g_searchFile = FindFirstFile(dir_strWin32.c_str(), &g_find_file_data);
|
||||||
g_firstFind = true;
|
g_firstFind = true;
|
||||||
|
if (g_searchFile == INVALID_HANDLE_VALUE)
|
||||||
|
g_searchFile = NULL;
|
||||||
#else
|
#else
|
||||||
g_searchFile = opendir(path);
|
g_searchFile = opendir(path);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1532,7 +1534,7 @@ static void menuHandler() {
|
||||||
* a lot of the operations necessary to use the menu
|
* a lot of the operations necessary to use the menu
|
||||||
*/
|
*/
|
||||||
bool menuChanged = false, sliderChanged = false;
|
bool menuChanged = false, sliderChanged = false;
|
||||||
switch(key) {
|
switch (key) {
|
||||||
case SDLK_ESCAPE:
|
case SDLK_ESCAPE:
|
||||||
{
|
{
|
||||||
lua_Object close = getTableFunction(menuTable, "cancel");
|
lua_Object close = getTableFunction(menuTable, "cancel");
|
||||||
|
@ -1881,6 +1883,15 @@ static void GetCurrentScript() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ScreenShot() {
|
static void ScreenShot() {
|
||||||
|
int width = check_int(1);
|
||||||
|
int height = check_int(2);
|
||||||
|
|
||||||
|
Bitmap *screenshot = g_driver->getScreenshot(width, height);
|
||||||
|
if (screenshot) {
|
||||||
|
lua_pushusertag(screenshot, MKID('VBUF'));
|
||||||
|
} else {
|
||||||
|
lua_pushnil();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SubmitSaveGameData() {
|
static void SubmitSaveGameData() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue