From 432193552c43b9ab4546b72064390a373a3293e1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 2 Dec 2012 15:58:26 +0000 Subject: [PATCH] fix GhostSDL displaying text in multiple views. add support for multi-sample. --- intern/ghost/intern/GHOST_SystemSDL.cpp | 2 +- intern/ghost/intern/GHOST_WindowSDL.cpp | 28 +++++++++++++------ .../blender/editors/space_view3d/drawobject.c | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemSDL.cpp b/intern/ghost/intern/GHOST_SystemSDL.cpp index 237d4c0f787..fdc4f33b784 100644 --- a/intern/ghost/intern/GHOST_SystemSDL.cpp +++ b/intern/ghost/intern/GHOST_SystemSDL.cpp @@ -73,7 +73,7 @@ GHOST_SystemSDL::createWindow(const STR_String& title, { GHOST_WindowSDL *window = NULL; - window = new GHOST_WindowSDL(this, title, left, top, width, height, state, parentWindow, type, stereoVisual, 1); + window = new GHOST_WindowSDL(this, title, left, top, width, height, state, parentWindow, type, stereoVisual, numOfAASamples); if (window) { if (GHOST_kWindowStateFullScreen == state) { diff --git a/intern/ghost/intern/GHOST_WindowSDL.cpp b/intern/ghost/intern/GHOST_WindowSDL.cpp index 369fc4ace14..6641b28a20e 100644 --- a/intern/ghost/intern/GHOST_WindowSDL.cpp +++ b/intern/ghost/intern/GHOST_WindowSDL.cpp @@ -26,6 +26,7 @@ #include "GHOST_WindowSDL.h" #include "SDL_mouse.h" +#include #include static SDL_GLContext s_firstContext = NULL; @@ -48,6 +49,20 @@ GHOST_WindowSDL::GHOST_WindowSDL(GHOST_SystemSDL *system, m_invalid_window(false), m_sdl_custom_cursor(NULL) { + SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); + + if (numOfAASamples) { + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, numOfAASamples); + } + + /* creating the window _must_ come after setting attributes */ m_sdl_win = SDL_CreateWindow(title, left, top, @@ -55,14 +70,7 @@ GHOST_WindowSDL::GHOST_WindowSDL(GHOST_SystemSDL *system, height, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); - //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); - //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); + m_sdl_glcontext = SDL_GL_CreateContext(m_sdl_win); @@ -164,6 +172,10 @@ GHOST_WindowSDL::activateDrawingContext() if (m_sdl_glcontext != NULL) { int status = SDL_GL_MakeCurrent(m_sdl_win, m_sdl_glcontext); (void)status; + /* Disable AA by default */ + if (m_numOfAASamples > 0) { + glDisable(GL_MULTISAMPLE_ARB); + } return GHOST_kSuccess; } return GHOST_kFailure; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 08ba4fb59bc..4a89deca162 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2579,7 +2579,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS BMIter iter; int i; - /* make the precision of the pronted value proportionate to the gridsize */ + /* make the precision of the display value proportionate to the gridsize */ if (grid < 0.01f) conv_float = "%.6g"; else if (grid < 0.1f) conv_float = "%.5g";