Commit 5b7403e6 authored by vigmond's avatar vigmond
Browse files

Antialiasing with OSMESA.

parent dabaae39
Pipeline #3273 passed with stages
in 2 minutes and 5 seconds
......@@ -2,18 +2,17 @@
# define GL_GLEXT_PROTOTYPES
# include <GL/osmesa.h>
#elif defined(__APPLE__)
# define GL_SILENCE_DEPRECATION
# include <OpenGL/gl3.h>
# define GL_SILENCE_DEPRECATION
# include <OpenGL/gl3.h>
#else
# if defined(WIN32)
# define GLEW_STATIC 1
# endif
# include <GL/glew.h>
# if defined(WIN32)
# define GLEW_STATIC 1
# endif
# include <GL/glew.h>
static bool initglew = false;
#define USE_FBO
#endif
#define USE_FBO // antialiasing
//#define USE_FLTK_IMG
#include "Frame.h"
......@@ -76,18 +75,15 @@ Frame :: Frame( TBmeshWin *t ) : _tbwm(t)
}
/** constructor to fill buffer with current screen contents */
Frame :: Frame( TBmeshWin *t, int w, int h, bool fa ) : _tbwm(t), _full_alpha(fa)
Frame :: Frame( TBmeshWin *t, int w, int h, bool fa ) :_tbwm(t),_w(w),_h(h),
_full_alpha(fa), _buffer(new GLubyte[w*h*4])
{
#ifdef OSMESA
_w = w;
_h = h;
_buffer = new GLubyte[w*h*4];
if (!OSMesaMakeCurrent((OSMesaContext)(_tbwm->context()), _buffer, GL_UNSIGNED_BYTE, w, h)) {
std::cout << "Failed OSMesaMakeCurrent" << std::endl;
throw 1;
}
#elif !defined(OSMESA) && !defined(__APPLE__)
#elif !defined(__APPLE__)
if( !initglew ) {
initglew = true;
GLenum err = glewInit();
......@@ -96,11 +92,15 @@ Frame :: Frame( TBmeshWin *t, int w, int h, bool fa ) : _tbwm(t), _full_alpha(fa
}
}
#endif
#ifdef USE_FBO
make_framebuffer( w, h, _fbms, _color_rbms, _depth_rbms, true );
make_framebuffer( w, h, _fb, _color_rb, _depth_rb );
#endif
fill_buffer( w, h, true );
#ifdef OSMESA
#elif defined(USE_FLTK_IMG)
#else
#if defined(USE_FBO)
glBindFramebuffer(GL_FRAMEBUFFER, 0); // restore the display
#endif //OSMESA
}
......@@ -272,8 +272,7 @@ Frame::fill_buffer( int w, int h, bool alpha )
_h = h;
_buffer = new GLubyte[w*h*4];
#ifdef OSMESA
#elif defined(USE_FBO)
#if defined(USE_FBO)
make_framebuffer( w, h, _fbms, _color_rbms, _depth_rbms, true );
make_framebuffer( w, h, _fb, _color_rb, _depth_rb );
#endif //OSMESA
......@@ -306,14 +305,16 @@ Frame::fill_buffer( int w, int h, bool alpha )
#ifdef USE_FBO
glBindFramebuffer(GL_READ_FRAMEBUFFER, _fbms);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _fb);
#ifndef OSMESA
glDrawBuffer(GL_BACK);
#endif //OSMESA
glBlitFramebuffer( 0, 0, w, h, 0, 0, w, h, GL_COLOR_BUFFER_BIT, GL_NEAREST );
glBindFramebuffer(GL_FRAMEBUFFER, _fb);
#elif defined(USE_FLTK_IMG)
return;
#else
glReadBuffer(GL_BACK);
#endif
#endif //USE_FBO
if( _tbwm->transBgd() || alpha ){
glReadPixels(0,0,w,h,GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid *)_buffer);
......
......@@ -29,7 +29,8 @@ class Frame {
void delete_objs();
#ifdef OSMESA
OSMesaContext _ctx;
#else
#endif
#ifdef USE_FBO
GLuint _fb, _color_rb, _depth_rb;
GLuint _fbms, _color_rbms, _depth_rbms;
#endif
......
......@@ -1417,7 +1417,8 @@ void TBmeshWin::output_png( const char* fn, Sequence *seqwidget )
bool sequence = (seqwidget!=NULL);
int start=tm;
int stop;
std::string foutname(fn);
static std::string foutname;
foutname=fn;
if ( sequence ) {
Fl::flush();
......
......@@ -35,7 +35,7 @@ sem_t * make_sem( std::string base, int val=0 ) {
#else
#ifndef __APPLE__
#ifdef USE_GLUT
#ifdef USE_GLUT
#include <FL/glut.H>
#else
#include <GLFW/glfw3.h>
......
Supports Markdown
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