Commit ba82240f authored by Edward Vigmond's avatar Edward Vigmond
Browse files

fixed PNG output. Define ONSCREEN_DUMP if you are having trouble with

offscreen dumps.
parent 3e5d460d
......@@ -3,7 +3,7 @@ HOSTMACHINE := $(shell uname)
FLTK_INC := $(shell fltk-config --use-gl --cxxflags)
FLTK_LD_FLAGS := $(shell fltk-config --use-images --use-gl --ldflags)
COMMON_LIBS = -lpng -lpthread -lm -lz
COMMON_INC = -I. -O0 -g -DOBJ_CLASS -D_REENTRANT -MMD -DNOMINMAX
COMMON_INC = -I. -O0 -g -DOBJ_CLASS -D_REENTRANT -MMD -DNOMINMAX
ifeq ($(HOSTMACHINE),Darwin)
LIBS = $(FLTK_LD_FLAGS) $(COMMON_LIBS)
......
......@@ -20,7 +20,6 @@
PNGwrite :: PNGwrite( FILE *out )
{
/*
fp = out;
width = height = 0;
ctype = PNG_COLOR_TYPE_RGB;
......@@ -41,7 +40,6 @@ PNGwrite :: PNGwrite( FILE *out )
}
setjmp(png_jmpbuf(png_ptr));
png_init_io(png_ptr, fp);
*/
}
PNGwrite :: ~PNGwrite( void )
......@@ -49,7 +47,7 @@ PNGwrite :: ~PNGwrite( void )
int PNGwrite :: write( void *data )
{
/*setjmp(png_jmpbuf(png_ptr));
setjmp(png_jmpbuf(png_ptr));
png_set_IHDR( png_ptr, info_ptr, width, height, colour_depth, ctype,
interlace_type, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
......@@ -77,6 +75,5 @@ int PNGwrite :: write( void *data )
png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
fclose( fp );
return 1;
*/
}
......@@ -31,9 +31,13 @@ int intcomp( const void *a, const void *b );
/* dump the frame buffer into a file */
void write_frame( string fname, int w, int h, TBmeshWin *tbwm )
{
#ifdef ONSCREEN_DUMP
GLubyte* buffer = new GLubyte[4*w*h];
#else
static int oldw=-1, oldh;
static GLubyte* buffer;
static GLuint fb, color_rb, depth_rb;
#endif
FILE *out = fopen( fname.c_str(), "w" );
PNGwrite* pngimg = new PNGwrite( out );
......@@ -41,6 +45,7 @@ void write_frame( string fname, int w, int h, TBmeshWin *tbwm )
pngimg->depth( 8*sizeof(GLubyte) );
pngimg->colour_type( PNG_COLOR_TYPE_RGB_ALPHA );
#ifndef ONSCREEN_DUMP
if( oldw==-1 || oldw!=w || oldh!=h ) {
if( oldw != -1 ) {
......@@ -93,13 +98,18 @@ void write_frame( string fname, int w, int h, TBmeshWin *tbwm )
tbwm->invalidate();
tbwm->draw();
#endif
glReadBuffer(GL_BACK);
glReadPixels(0,0,w,h,GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid *)buffer);
pngimg->write( buffer );
delete pngimg;
#ifdef ONSCREEN_DUMP
delete[] buffer;
#else
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
#endif
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment