aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xCHANGELOG.TXT2
-rw-r--r--hge/hge_impl.h1
-rw-r--r--hge/system.cpp22
-rw-r--r--main.cpp1
4 files changed, 24 insertions, 2 deletions
diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT
index 44ee83d..caf8588 100755
--- a/CHANGELOG.TXT
+++ b/CHANGELOG.TXT
@@ -12,6 +12,8 @@ Pre-Released versions:
Bump version!
New assessment level "density test"...
New assessment level "pinball"...
+Add screen shot. Press S for a screen shot.
+Fix the upside down screen shot output.
0.9.0-0_PR (b78)
First two assessment levels.
diff --git a/hge/hge_impl.h b/hge/hge_impl.h
index e09a321..7361274 100644
--- a/hge/hge_impl.h
+++ b/hge/hge_impl.h
@@ -339,6 +339,7 @@ public:
//int _format_id(D3DFORMAT fmt);
void _SetBlendMode(int blend);
void _SetProjectionMatrix(int width, int height);
+ int _flipSDLSurface(int pitch, int height, void* image_pixels);
// Audio
diff --git a/hge/system.cpp b/hge/system.cpp
index 915ffe1..b7c112c 100644
--- a/hge/system.cpp
+++ b/hge/system.cpp
@@ -675,7 +675,8 @@ void CALL HGE_Impl::System_Snapshot(const char *filename)
SDL_Surface *screen = SDL_GetVideoSurface();
SDL_Surface *surface = SDL_CreateRGBSurface(SDL_SWSURFACE, screen->w, screen->h, 24, rmask, gmask, bmask, 0);
pOpenGLDevice->glReadPixels(0, 0, screen->w, screen->h, GL_RGB, GL_UNSIGNED_BYTE, surface->pixels);
- STUBBED("image is probably upside down");
+ //flip the image so that it won't be upside down...
+ _flipSDLSurface(surface->pitch,surface->h,surface->pixels);
SDL_SaveBMP(surface, filename);
SDL_FreeSurface(surface);
}
@@ -897,5 +898,22 @@ bool HGE_Impl::_ProcessSDLEvent(const SDL_Event &e)
return true;
}
-
+int HGE_Impl::_flipSDLSurface(int pitch, int height, void* image_pixels)
+{
+ int index;
+ void* temp_row;
+ int height_div_2;
+
+ temp_row=(void *)malloc(pitch);
+ assert(temp_row);
+ height_div_2 = (int) (height * .5);
+ for(index = 0; index < height_div_2; index++)
+ {
+ memcpy((Uint8 *)temp_row,(Uint8 *)(image_pixels)+pitch*index,pitch);
+ memcpy((Uint8 *)(image_pixels)+pitch*index,(Uint8 *)(image_pixels)+pitch*(height-index-1),pitch);
+ memcpy((Uint8 *)(image_pixels)+pitch*(height-index-1),temp_row,pitch);
+ }
+ free(temp_row);
+ return 0;
+}
// end of system_unix.cpp ...
diff --git a/main.cpp b/main.cpp
index 7224a6c..5c351f3 100644
--- a/main.cpp
+++ b/main.cpp
@@ -810,6 +810,7 @@ bool FrameFunc()
fnt->printf(5, 150, HGETEXT_LEFT, "Multiplier: %.2lf",mult);
}
}
+ if(hge->Input_GetKeyStateEx(HGEK_S)==HGEKST_HIT)hge->System_Snapshot();
hge->Gfx_EndScene();
return false;
}