* fix: FBO creation was random
* disable MSAA with samples = 0, even if more is forced via driver
This commit is contained in:
parent
552d0ac083
commit
0bf509dc1a
|
|
@ -120,9 +120,6 @@ public:
|
|||
glVertex2f( rectangle.x, rectangle.y );
|
||||
glEnd();
|
||||
|
||||
if( GlobalOpenGL().GL_1_3() ) {
|
||||
glEnable( GL_MULTISAMPLE );
|
||||
}
|
||||
GlobalOpenGL_debugAssertNoErrors();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1278,12 +1278,10 @@ public:
|
|||
_constructed = false;
|
||||
}
|
||||
virtual void start(){
|
||||
// if ( GlobalOpenGL().GL_1_3() ) {
|
||||
// glDisable( GL_MULTISAMPLE );
|
||||
// }
|
||||
if( !_constructed ){
|
||||
construct();
|
||||
}
|
||||
setMultisample();
|
||||
glBindFramebuffer( GL_FRAMEBUFFER, _fbo );
|
||||
}
|
||||
virtual void save(){
|
||||
|
|
@ -1306,6 +1304,14 @@ protected:
|
|||
GLuint _tex;
|
||||
GLuint _depth;
|
||||
GLuint _color;
|
||||
void setMultisample(){
|
||||
if( GlobalOpenGL().GL_1_3() ) {
|
||||
if( _samples )
|
||||
glEnable( GL_MULTISAMPLE );
|
||||
else
|
||||
glDisable( GL_MULTISAMPLE );
|
||||
}
|
||||
}
|
||||
virtual void construct() {
|
||||
int curSamples;
|
||||
glGetIntegerv( GL_SAMPLES, &curSamples );
|
||||
|
|
@ -1319,6 +1325,8 @@ protected:
|
|||
_samples = maxSamples;
|
||||
}
|
||||
}
|
||||
// globalErrorStream() << _samples << " samples\n";
|
||||
setMultisample();
|
||||
|
||||
glGenFramebuffers( 1, &_fbo );
|
||||
glBindFramebuffer( GL_FRAMEBUFFER, _fbo );
|
||||
|
|
@ -1381,7 +1389,7 @@ public:
|
|||
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
glOrtho( 0, _width, 0, _height, -100, 100 );
|
||||
glOrtho( 0, 1, 0, 1, -100, 100 );
|
||||
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
|
|
@ -1405,17 +1413,17 @@ public:
|
|||
glBindTexture( GL_TEXTURE_2D, _tex );
|
||||
|
||||
|
||||
glColor4f( 1.0, 1.0, 1.0, 1.0 );
|
||||
glColor4f( 1.f, 1.f, 1.f, 1.f );
|
||||
glBegin( GL_QUADS );
|
||||
|
||||
glTexCoord2f( 0, 0 );
|
||||
glVertex3f( 0, 0, 0 );
|
||||
glTexCoord2f( 0, 1 );
|
||||
glVertex3f( 0, _height, 0 );
|
||||
glTexCoord2f( 1, 1 );
|
||||
glVertex3f( _width, _height, 0 );
|
||||
glTexCoord2f( 1, 0 );
|
||||
glVertex3f( _width, 0, 0 );
|
||||
glTexCoord2i( 0, 0 );
|
||||
glVertex2i( 0, 0 );
|
||||
glTexCoord2i( 0, 1 );
|
||||
glVertex2i( 0, 1 );
|
||||
glTexCoord2i( 1, 1 );
|
||||
glVertex2i( 1, 1 );
|
||||
glTexCoord2i( 1, 0 );
|
||||
glVertex2i( 1, 0 );
|
||||
glEnd();
|
||||
glBindTexture( GL_TEXTURE_2D, 0 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -717,6 +717,9 @@ FreezePointer m_freezePointer;
|
|||
|
||||
public:
|
||||
FBO* m_fbo;
|
||||
FBO* fbo_get(){
|
||||
return m_fbo = m_fbo? m_fbo : GlobalOpenGL().support_ARB_framebuffer_object? new FBO : new FBO_fallback;
|
||||
}
|
||||
GtkWidget* m_gl_widget;
|
||||
GtkWindow* m_parent;
|
||||
|
||||
|
|
@ -952,7 +955,7 @@ void camwnd_update_xor_rectangle( CamWnd& self, rect_t area ){
|
|||
GlobalOpenGL_debugAssertNoErrors();
|
||||
|
||||
glDrawBuffer( GL_FRONT );
|
||||
self.m_fbo->blit();
|
||||
self.fbo_get()->blit();
|
||||
|
||||
self.m_XORRectangle.set( rectangle_from_area( area.min, area.max, self.getCamera().width, self.getCamera().height ), self.getCamera().width, self.getCamera().height );
|
||||
|
||||
|
|
@ -1070,7 +1073,7 @@ gboolean wheelmove_scroll( GtkWidget* widget, GdkEventScroll* event, CamWnd* cam
|
|||
}
|
||||
|
||||
gboolean camera_size_allocate( GtkWidget* widget, GtkAllocation* allocation, CamWnd* camwnd ){
|
||||
camwnd->m_fbo->reset( allocation->width, allocation->height, g_camwindow_globals_private.m_MSAA, true );
|
||||
camwnd->fbo_get()->reset( allocation->width, allocation->height, g_camwindow_globals_private.m_MSAA, true );
|
||||
camwnd->getCamera().width = allocation->width;
|
||||
camwnd->getCamera().height = allocation->height;
|
||||
Camera_updateProjection( camwnd->getCamera() );
|
||||
|
|
@ -1378,9 +1381,9 @@ CamWnd::CamWnd() :
|
|||
m_selection_motion_handler( 0 ),
|
||||
m_freelook_button_press_handler( 0 ),
|
||||
m_freelook_button_release_handler( 0 ),
|
||||
m_drawing( false ){
|
||||
m_fbo = GlobalOpenGL().support_ARB_framebuffer_object? new FBO : new FBO_fallback;
|
||||
|
||||
m_drawing( false ),
|
||||
m_fbo( 0 )
|
||||
{
|
||||
m_bFreeMove = false;
|
||||
|
||||
GlobalWindowObservers_add( m_window_observer );
|
||||
|
|
@ -1663,7 +1666,7 @@ void ShowStatsToggle(){
|
|||
|
||||
void CamWnd::Cam_Draw(){
|
||||
// globalOutputStream() << "Cam_Draw()\n";
|
||||
m_fbo->start();
|
||||
fbo_get()->start();
|
||||
|
||||
glViewport( 0, 0, m_Camera.width, m_Camera.height );
|
||||
#if 0
|
||||
|
|
@ -1831,7 +1834,7 @@ void CamWnd::Cam_Draw(){
|
|||
// elsewhere using/modifying texture maps between contexts
|
||||
glBindTexture( GL_TEXTURE_2D, 0 );
|
||||
|
||||
m_fbo->save();
|
||||
fbo_get()->save();
|
||||
}
|
||||
|
||||
void CamWnd::draw(){
|
||||
|
|
@ -2123,7 +2126,7 @@ typedef FreeCaller1<const IntImportCallback&, RenderModeExport> RenderModeExport
|
|||
void CamMSAAImport( int value ){
|
||||
g_camwindow_globals_private.m_MSAA = value ? 1 << value : value;
|
||||
if ( g_camwnd != 0 ) {
|
||||
g_camwnd->m_fbo->reset( g_camwnd->getCamera().width, g_camwnd->getCamera().height, g_camwindow_globals_private.m_MSAA, true );
|
||||
g_camwnd->fbo_get()->reset( g_camwnd->getCamera().width, g_camwnd->getCamera().height, g_camwindow_globals_private.m_MSAA, true );
|
||||
}
|
||||
}
|
||||
typedef FreeCaller1<int, CamMSAAImport> MSAAImportCaller;
|
||||
|
|
|
|||
|
|
@ -1269,9 +1269,6 @@ void Texture_Draw( TextureBrowser& textureBrowser ){
|
|||
|
||||
// reset the current texture
|
||||
glBindTexture( GL_TEXTURE_2D, 0 );
|
||||
if( GlobalOpenGL().GL_1_3() ) {
|
||||
glEnable( GL_MULTISAMPLE );
|
||||
}
|
||||
glDisable( GL_BLEND );
|
||||
//qglFinish();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -768,7 +768,7 @@ bool XYWnd::XY_Draw_Overlay_start(){
|
|||
if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) {
|
||||
GlobalOpenGL_debugAssertNoErrors();
|
||||
glDrawBuffer( GL_FRONT );
|
||||
m_fbo->blit();
|
||||
fbo_get()->blit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -852,7 +852,7 @@ gboolean xywnd_wheel_scroll( GtkWidget* widget, GdkEventScroll* event, XYWnd* xy
|
|||
}
|
||||
|
||||
gboolean xywnd_size_allocate( GtkWidget* widget, GtkAllocation* allocation, XYWnd* xywnd ){
|
||||
xywnd->m_fbo->reset( allocation->width, allocation->height, g_xywindow_globals_private.m_MSAA, false );
|
||||
xywnd->fbo_get()->reset( allocation->width, allocation->height, g_xywindow_globals_private.m_MSAA, false );
|
||||
xywnd->m_nWidth = allocation->width;
|
||||
xywnd->m_nHeight = allocation->height;
|
||||
xywnd->updateProjection();
|
||||
|
|
@ -888,10 +888,9 @@ XYWnd::XYWnd() :
|
|||
m_deferred_motion( xywnd_motion, this ),
|
||||
m_parent( 0 ),
|
||||
m_window_observer( NewWindowObserver() ),
|
||||
m_chasemouse_handler( 0 )
|
||||
m_chasemouse_handler( 0 ),
|
||||
m_fbo( 0 )
|
||||
{
|
||||
m_fbo = GlobalOpenGL().support_ARB_framebuffer_object? new FBO : new FBO_fallback;
|
||||
|
||||
m_cursorCurrent = 0;
|
||||
|
||||
m_bActive = false;
|
||||
|
|
@ -999,6 +998,10 @@ void XYWnd::Scroll( int x, int y ){
|
|||
queueDraw();
|
||||
}
|
||||
|
||||
FBO* XYWnd::fbo_get(){
|
||||
return m_fbo = m_fbo? m_fbo : GlobalOpenGL().support_ARB_framebuffer_object? new FBO : new FBO_fallback;
|
||||
}
|
||||
|
||||
unsigned int Clipper_buttons(){
|
||||
return RAD_LBUTTON;
|
||||
}
|
||||
|
|
@ -2702,7 +2705,7 @@ void XYWnd::XY_Draw(){
|
|||
glGetIntegerv(GL_SAMPLES,&curSamples);
|
||||
globalOutputStream() << curSamples << " GL_SAMPLES\n";
|
||||
*/
|
||||
m_fbo->start();
|
||||
fbo_get()->start();
|
||||
//
|
||||
// clear
|
||||
//
|
||||
|
|
@ -2903,7 +2906,7 @@ void XYWnd::XY_Draw(){
|
|||
m_render_time.start();
|
||||
}
|
||||
|
||||
m_fbo->save();
|
||||
fbo_get()->save();
|
||||
|
||||
{
|
||||
// reset modelview
|
||||
|
|
@ -3302,13 +3305,13 @@ void ToggleShowGrid(){
|
|||
void MSAAImport( int value ){
|
||||
g_xywindow_globals_private.m_MSAA = value ? 1 << value : value;
|
||||
if ( g_pParentWnd->GetXYWnd() ) {
|
||||
g_pParentWnd->GetXYWnd()->m_fbo->reset( g_pParentWnd->GetXYWnd()->Width(), g_pParentWnd->GetXYWnd()->Height(), g_xywindow_globals_private.m_MSAA, false );
|
||||
g_pParentWnd->GetXYWnd()->fbo_get()->reset( g_pParentWnd->GetXYWnd()->Width(), g_pParentWnd->GetXYWnd()->Height(), g_xywindow_globals_private.m_MSAA, false );
|
||||
}
|
||||
if ( g_pParentWnd->GetXZWnd() ) {
|
||||
g_pParentWnd->GetXZWnd()->m_fbo->reset( g_pParentWnd->GetXZWnd()->Width(), g_pParentWnd->GetXZWnd()->Height(), g_xywindow_globals_private.m_MSAA, false );
|
||||
g_pParentWnd->GetXZWnd()->fbo_get()->reset( g_pParentWnd->GetXZWnd()->Width(), g_pParentWnd->GetXZWnd()->Height(), g_xywindow_globals_private.m_MSAA, false );
|
||||
}
|
||||
if ( g_pParentWnd->GetYZWnd() ) {
|
||||
g_pParentWnd->GetYZWnd()->m_fbo->reset( g_pParentWnd->GetYZWnd()->Width(), g_pParentWnd->GetYZWnd()->Height(), g_xywindow_globals_private.m_MSAA, false );
|
||||
g_pParentWnd->GetYZWnd()->fbo_get()->reset( g_pParentWnd->GetYZWnd()->Width(), g_pParentWnd->GetYZWnd()->Height(), g_xywindow_globals_private.m_MSAA, false );
|
||||
}
|
||||
}
|
||||
typedef FreeCaller1<int, MSAAImport> MSAAImportCaller;
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ DeferredDraw m_deferredDraw;
|
|||
DeferredMotion m_deferred_motion;
|
||||
public:
|
||||
FBO* m_fbo;
|
||||
FBO* fbo_get();
|
||||
GtkWindow* m_parent;
|
||||
XYWnd();
|
||||
~XYWnd();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user