Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Plisson <damien.plisson@yahoo.fr>2010-01-06 14:42:52 +0300
committerDamien Plisson <damien.plisson@yahoo.fr>2010-01-06 14:42:52 +0300
commit75f190bde8f60f8c091f84169620e3e814386379 (patch)
tree6eeb7d0c90df26d7e38566fd346680a3d8d53e12 /intern/ghost
parent0cbf63bac985e2bbd305e8c680600975410aec1e (diff)
OpenGL Anti-aliasing implementation for blender windows
Added GHOST_TUns16 numOfAASamples parameter to GHOST_CreateWindow to specify the number of AA samples (null if no AA wanted) Implemented it in the cascade of GHOST classes. Full implementation currently done for OSX/Cocoa, stubs for other OSes. Moguri : it's ready for your win32 implementation ! Note that fallback to a non AA window (if gfx card doesn't support AA) is done inside GHOST OS specific layer, so that blender windowmanager still gets its window created properly.
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/GHOST_C-api.h5
-rw-r--r--intern/ghost/GHOST_ISystem.h18
-rw-r--r--intern/ghost/intern/GHOST_C-api.cpp5
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.cpp1
-rw-r--r--intern/ghost/intern/GHOST_SystemCarbon.h1
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.h19
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm3
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp2
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.h6
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp3
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.h1
-rw-r--r--intern/ghost/intern/GHOST_Window.cpp6
-rw-r--r--intern/ghost/intern/GHOST_Window.h23
-rw-r--r--intern/ghost/intern/GHOST_WindowCarbon.cpp3
-rw-r--r--intern/ghost/intern/GHOST_WindowCarbon.h3
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.h22
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm56
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.cpp5
-rw-r--r--intern/ghost/intern/GHOST_WindowWin32.h4
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.cpp5
-rw-r--r--intern/ghost/intern/GHOST_WindowX11.h4
21 files changed, 137 insertions, 58 deletions
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index d4788ae9e86..7e7b24721eb 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -162,6 +162,8 @@ extern void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle,
* @param height The height the window.
* @param state The state of the window when opened.
* @param type The type of drawing context installed in this window.
+ * @param stereoVisual Stereo visual for quad buffered stereo.
+ * @param numOfAASamples Number of samples used for AA (zero if no AA)
* @return A handle to the new window ( == NULL if creation failed).
*/
extern GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
@@ -172,7 +174,8 @@ extern GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
- const int stereoVisual);
+ const int stereoVisual,
+ const GHOST_TUns16 numOfAASamples);
/**
* Returns the window user data.
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 305caa70ae4..d1449aaef59 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -216,14 +216,15 @@ public:
* Create a new window.
* The new window is added to the list of windows managed.
* Never explicitly delete the window, use disposeWindow() instead.
- * @param title The name of the window (displayed in the title bar of the window if the OS supports it).
- * @param left The coordinate of the left edge of the window.
- * @param top The coordinate of the top edge of the window.
- * @param width The width the window.
- * @param height The height the window.
- * @param state The state of the window when opened.
- * @param type The type of drawing context installed in this window.
+ * @param title The name of the window (displayed in the title bar of the window if the OS supports it).
+ * @param left The coordinate of the left edge of the window.
+ * @param top The coordinate of the top edge of the window.
+ * @param width The width the window.
+ * @param height The height the window.
+ * @param state The state of the window when opened.
+ * @param type The type of drawing context installed in this window.
* @param stereoVisual Create a stereo visual for quad buffered stereo.
+ * @param numOfAASamples Number of samples used for AA (zero if no AA)
* @param parentWindow Parent (embedder) window
* @return The new window (or 0 if creation failed).
*/
@@ -231,7 +232,8 @@ public:
const STR_String& title,
GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height,
GHOST_TWindowState state, GHOST_TDrawingContextType type,
- const bool stereoVisual,
+ const bool stereoVisual = false,
+ const GHOST_TUns16 numOfAASamples = 0,
const GHOST_TEmbedderWindowID parentWindow = 0) = 0;
/**
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index 556176809f4..be726282d80 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -140,7 +140,8 @@ GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
- const int stereoVisual)
+ const int stereoVisual,
+ const GHOST_TUns16 numOfAASamples)
{
GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
bool bstereoVisual;
@@ -151,7 +152,7 @@ GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
bstereoVisual = false;
return (GHOST_WindowHandle) system->createWindow(title, left, top, width, height,
- state, type, bstereoVisual);
+ state, type, bstereoVisual, numOfAASamples);
}
GHOST_TUserDataPtr GHOST_GetWindowUserData(GHOST_WindowHandle windowhandle)
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp
index 57d6f6c06cc..3813a5ee450 100644
--- a/intern/ghost/intern/GHOST_SystemCarbon.cpp
+++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp
@@ -402,6 +402,7 @@ GHOST_IWindow* GHOST_SystemCarbon::createWindow(
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
bool stereoVisual,
+ const GHOST_TUns16 numOfAASamples,
const GHOST_TEmbedderWindowID parentWindow
)
{
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.h b/intern/ghost/intern/GHOST_SystemCarbon.h
index 5b3b786a5ac..7ebbbd8e97b 100644
--- a/intern/ghost/intern/GHOST_SystemCarbon.h
+++ b/intern/ghost/intern/GHOST_SystemCarbon.h
@@ -115,6 +115,7 @@ public:
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
const bool stereoVisual,
+ const GHOST_TUns16 numOfAASamples = 0,
const GHOST_TEmbedderWindowID parentWindow = 0
);
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h
index 81eb8978588..5b78f9b8fa3 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -93,13 +93,15 @@ public:
* Create a new window.
* The new window is added to the list of windows managed.
* Never explicitly delete the window, use disposeWindow() instead.
- * @param title The name of the window (displayed in the title bar of the window if the OS supports it).
- * @param left The coordinate of the left edge of the window.
- * @param top The coordinate of the top edge of the window.
- * @param width The width the window.
- * @param height The height the window.
- * @param state The state of the window when opened.
- * @param type The type of drawing context installed in this window.
+ * @param title The name of the window (displayed in the title bar of the window if the OS supports it).
+ * @param left The coordinate of the left edge of the window.
+ * @param top The coordinate of the top edge of the window.
+ * @param width The width the window.
+ * @param height The height the window.
+ * @param state The state of the window when opened.
+ * @param type The type of drawing context installed in this window.
+ * @param stereoVisual Stereo visual for quad buffered stereo.
+ * @param numOfAASamples Number of samples used for AA (zero if no AA)
* @param parentWindow Parent (embedder) window
* @return The new window (or 0 if creation failed).
*/
@@ -111,7 +113,8 @@ public:
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
- const bool stereoVisual,
+ const bool stereoVisual = false,
+ const GHOST_TUns16 numOfAASamples = 0,
const GHOST_TEmbedderWindowID parentWindow = 0
);
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index e9d34534fcf..1ba20315512 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -657,6 +657,7 @@ GHOST_IWindow* GHOST_SystemCocoa::createWindow(
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
bool stereoVisual,
+ const GHOST_TUns16 numOfAASamples,
const GHOST_TEmbedderWindowID parentWindow
)
{
@@ -672,7 +673,7 @@ GHOST_IWindow* GHOST_SystemCocoa::createWindow(
left = left > contentRect.origin.x ? left : contentRect.origin.x;
top = top > contentRect.origin.y ? top : contentRect.origin.y;
- window = new GHOST_WindowCocoa (this, title, left, top, width, height, state, type);
+ window = new GHOST_WindowCocoa (this, title, left, top, width, height, state, type, stereoVisual, numOfAASamples);
if (window) {
if (window->getValid()) {
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 15914a5bf43..d7d657fb496 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -190,7 +190,7 @@ GHOST_IWindow* GHOST_SystemWin32::createWindow(
const STR_String& title,
GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height,
GHOST_TWindowState state, GHOST_TDrawingContextType type,
- bool stereoVisual, const GHOST_TEmbedderWindowID parentWindow )
+ bool stereoVisual, const GHOST_TUns16 numOfAASamples, const GHOST_TEmbedderWindowID parentWindow )
{
GHOST_Window* window = 0;
window = new GHOST_WindowWin32 (this, title, left, top, width, height, state, type, stereoVisual);
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index 517f7ddbeea..65d6a57ede3 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -110,6 +110,8 @@ public:
* @param height The height the window.
* @param state The state of the window when opened.
* @param type The type of drawing context installed in this window.
+ * @param stereoVisual Stereo visual for quad buffered stereo.
+ * @param numOfAASamples Number of samples used for AA (zero if no AA)
* @param parentWindow Parent (embedder) window
* @return The new window (or 0 if creation failed).
*/
@@ -117,7 +119,9 @@ public:
const STR_String& title,
GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height,
GHOST_TWindowState state, GHOST_TDrawingContextType type,
- const bool stereoVisual, const GHOST_TEmbedderWindowID parentWindow = 0 );
+ const bool stereoVisual = false,
+ const GHOST_TUns16 numOfAASamples = 0,
+ const GHOST_TEmbedderWindowID parentWindow = 0 );
/***************************************************************************************
** Event management functionality
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index ad8647d2246..3ee3c1a29f3 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -228,6 +228,8 @@ getMainDisplayDimensions(
* @param height The height the window.
* @param state The state of the window when opened.
* @param type The type of drawing context installed in this window.
+ * @param stereoVisual Stereo visual for quad buffered stereo.
+ * @param numOfAASamples Number of samples used for AA (zero if no AA)
* @param parentWindow Parent (embedder) window
* @return The new window (or 0 if creation failed).
*/
@@ -242,6 +244,7 @@ createWindow(
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
bool stereoVisual,
+ const GHOST_TUns16 numOfAASamples,
const GHOST_TEmbedderWindowID parentWindow
){
GHOST_WindowX11 * window = 0;
diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h
index d76c3991beb..361db783102 100644
--- a/intern/ghost/intern/GHOST_SystemX11.h
+++ b/intern/ghost/intern/GHOST_SystemX11.h
@@ -127,6 +127,7 @@ public:
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
const bool stereoVisual,
+ const GHOST_TUns16 numOfAASamples = 0,
const GHOST_TEmbedderWindowID parentWindow = 0
);
diff --git a/intern/ghost/intern/GHOST_Window.cpp b/intern/ghost/intern/GHOST_Window.cpp
index 14a255e2e5e..939a911dfac 100644
--- a/intern/ghost/intern/GHOST_Window.cpp
+++ b/intern/ghost/intern/GHOST_Window.cpp
@@ -44,13 +44,15 @@ GHOST_Window::GHOST_Window(
GHOST_TInt32 /*left*/, GHOST_TInt32 /*top*/, GHOST_TUns32 width, GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
- const bool stereoVisual)
+ const bool stereoVisual,
+ const GHOST_TUns16 numOfAASamples)
:
m_drawingContextType(type),
m_cursorVisible(true),
m_cursorGrab(GHOST_kGrabDisable),
m_cursorShape(GHOST_kStandardCursorDefault),
- m_stereoVisual(stereoVisual)
+ m_stereoVisual(stereoVisual),
+ m_numOfAASamples(numOfAASamples)
{
m_isUnsavedChanges = false;
m_canAcceptDragOperation = false;
diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h
index 1b5681dc41c..8aab9125130 100644
--- a/intern/ghost/intern/GHOST_Window.h
+++ b/intern/ghost/intern/GHOST_Window.h
@@ -75,14 +75,15 @@ public:
* Constructor.
* Creates a new window and opens it.
* To check if the window was created properly, use the getValid() method.
- * @param title The text shown in the title bar of the window.
- * @param left The coordinate of the left edge of the window.
- * @param top The coordinate of the top edge of the window.
- * @param width The width the window.
- * @param heigh The height the window.
- * @param state The state the window is initially opened with.
- * @param type The type of drawing context installed in this window.
- * @param stereoVisual Stereo visual for quad buffered stereo.
+ * @param title The text shown in the title bar of the window.
+ * @param left The coordinate of the left edge of the window.
+ * @param top The coordinate of the top edge of the window.
+ * @param width The width the window.
+ * @param heigh The height the window.
+ * @param state The state the window is initially opened with.
+ * @param type The type of drawing context installed in this window.
+ * @param stereoVisual Stereo visual for quad buffered stereo.
+ * @param numOfAASamples Number of samples used for AA (zero if no AA)
*/
GHOST_Window(
const STR_String& title,
@@ -92,7 +93,8 @@ public:
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
- const bool stereoVisual = false);
+ const bool stereoVisual = false,
+ const GHOST_TUns16 numOfAASamples = 0);
/**
* @section Interface inherited from GHOST_IWindow left for derived class
@@ -319,6 +321,9 @@ protected:
* the graphics h/w
*/
bool m_stereoVisual;
+
+ /** Number of samples used in anti-aliasing, set to 0 if no AA **/
+ GHOST_TUns16 m_numOfAASamples;
/** Full-screen width */
GHOST_TUns32 m_fullScreenWidth;
diff --git a/intern/ghost/intern/GHOST_WindowCarbon.cpp b/intern/ghost/intern/GHOST_WindowCarbon.cpp
index 362e949a0a4..3e53a052146 100644
--- a/intern/ghost/intern/GHOST_WindowCarbon.cpp
+++ b/intern/ghost/intern/GHOST_WindowCarbon.cpp
@@ -98,7 +98,8 @@ GHOST_WindowCarbon::GHOST_WindowCarbon(
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
- const bool stereoVisual
+ const bool stereoVisual,
+ const GHOST_TUns16 numOfAASamples
) :
GHOST_Window(title, left, top, width, height, state, GHOST_kDrawingContextTypeNone),
m_windowRef(0),
diff --git a/intern/ghost/intern/GHOST_WindowCarbon.h b/intern/ghost/intern/GHOST_WindowCarbon.h
index dd00add7fb1..b91e5410ddd 100644
--- a/intern/ghost/intern/GHOST_WindowCarbon.h
+++ b/intern/ghost/intern/GHOST_WindowCarbon.h
@@ -80,7 +80,8 @@ public:
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
- const bool stereoVisual = false
+ const bool stereoVisual = false,
+ const GHOST_TUns16 numOfAASamples = 0
);
/**
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.h b/intern/ghost/intern/GHOST_WindowCocoa.h
index e59d9c17333..b54634b08d7 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.h
+++ b/intern/ghost/intern/GHOST_WindowCocoa.h
@@ -61,15 +61,16 @@ public:
* Constructor.
* Creates a new window and opens it.
* To check if the window was created properly, use the getValid() method.
- * @param systemCocoa The associated system class to forward events to
- * @param title The text shown in the title bar of the window.
- * @param left The coordinate of the left edge of the window.
- * @param top The coordinate of the top edge of the window.
- * @param width The width the window.
- * @param height The height the window.
- * @param state The state the window is initially opened with.
- * @param type The type of drawing context installed in this window.
- * @param stereoVisual Stereo visual for quad buffered stereo.
+ * @param systemCocoa The associated system class to forward events to
+ * @param title The text shown in the title bar of the window.
+ * @param left The coordinate of the left edge of the window.
+ * @param top The coordinate of the top edge of the window.
+ * @param width The width the window.
+ * @param height The height the window.
+ * @param state The state the window is initially opened with.
+ * @param type The type of drawing context installed in this window.
+ * @param stereoVisual Stereo visual for quad buffered stereo.
+ * @param numOfAASamples Number of samples used for AA (zero if no AA)
*/
GHOST_WindowCocoa(
GHOST_SystemCocoa *systemCocoa,
@@ -80,7 +81,8 @@ public:
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
- const bool stereoVisual = false
+ const bool stereoVisual = false,
+ const GHOST_TUns16 numOfAASamples = 0
);
/**
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 0f8ed741fdf..4d1aa35c4e7 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -34,9 +34,11 @@
#include <Carbon/Carbon.h>
#endif
+#include <OpenGL/gl.h>
/***** Multithreaded opengl code : uncomment for enabling
#include <OpenGL/OpenGL.h>
*/
+
#include "GHOST_WindowCocoa.h"
#include "GHOST_SystemCocoa.h"
@@ -277,14 +279,15 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
- const bool stereoVisual
+ const bool stereoVisual, const GHOST_TUns16 numOfAASamples
) :
- GHOST_Window(title, left, top, width, height, state, GHOST_kDrawingContextTypeNone, stereoVisual),
+ GHOST_Window(title, left, top, width, height, state, GHOST_kDrawingContextTypeNone, stereoVisual, numOfAASamples),
m_customCursor(0)
{
NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[40];
+ NSOpenGLPixelFormat *pixelFormat = nil;
int i;
-
+
m_systemCocoa = systemCocoa;
m_fullScreen = false;
@@ -329,13 +332,52 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
if (stereoVisual) pixelFormatAttrsWindow[i++] = NSOpenGLPFAStereo;
+ if (numOfAASamples>0) {
+ // Multisample anti-aliasing
+ pixelFormatAttrsWindow[i++] = NSOpenGLPFAMultisample;
+
+ pixelFormatAttrsWindow[i++] = NSOpenGLPFASampleBuffers;
+ pixelFormatAttrsWindow[i++] = (NSOpenGLPixelFormatAttribute) 1;
+
+ pixelFormatAttrsWindow[i++] = NSOpenGLPFASamples;
+ pixelFormatAttrsWindow[i++] = (NSOpenGLPixelFormatAttribute) numOfAASamples;
+
+ pixelFormatAttrsWindow[i++] = NSOpenGLPFANoRecovery;
+ }
+
pixelFormatAttrsWindow[i] = (NSOpenGLPixelFormatAttribute) 0;
-
- //Creates the OpenGL View inside the window
- NSOpenGLPixelFormat *pixelFormat =
- [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttrsWindow];
+ pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttrsWindow];
+
+ //Fall back to no multisampling if Antialiasing init failed
+ if (pixelFormat == nil) {
+ i=0;
+ pixelFormatAttrsWindow[i++] = NSOpenGLPFADoubleBuffer;
+ pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccelerated;
+ //pixelFormatAttrsWindow[i++] = NSOpenGLPFAAllowOfflineRenderers,; // Removed to allow 10.4 builds, and 2 GPUs rendering is not used anyway
+
+ pixelFormatAttrsWindow[i++] = NSOpenGLPFADepthSize;
+ pixelFormatAttrsWindow[i++] = (NSOpenGLPixelFormatAttribute) 32;
+
+ if (stereoVisual) pixelFormatAttrsWindow[i++] = NSOpenGLPFAStereo;
+
+ pixelFormatAttrsWindow[i] = (NSOpenGLPixelFormatAttribute) 0;
+
+ pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttrsWindow];
+
+ }
+
+ if (numOfAASamples>0) { //Set m_numOfAASamples to the actual value
+ GLint gli;
+ [pixelFormat getValues:&gli forAttribute:NSOpenGLPFASamples forVirtualScreen:0];
+ if (m_numOfAASamples != (GHOST_TUns16)gli) {
+ m_numOfAASamples = (GHOST_TUns16)gli;
+ printf("GHOST_Window could be created with anti-aliasing of only %i samples\n",m_numOfAASamples);
+ }
+ }
+
+ //Creates the OpenGL View inside the window
m_openGLView = [[CocoaOpenGLView alloc] initWithFrame:rect
pixelFormat:pixelFormat];
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index ea14f1dfc1b..e276f216fb7 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -105,10 +105,11 @@ GHOST_WindowWin32::GHOST_WindowWin32(
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type,
- const bool stereoVisual)
+ const bool stereoVisual,
+ const GHOST_TUns16 numOfAASamples)
:
GHOST_Window(title, left, top, width, height, state, GHOST_kDrawingContextTypeNone,
- stereoVisual),
+ stereoVisual,numOfAASamples),
m_system(system),
m_hDC(0),
m_hGlRc(0),
diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h
index 07a31911a5e..954546f3d82 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.h
+++ b/intern/ghost/intern/GHOST_WindowWin32.h
@@ -75,6 +75,7 @@ public:
* @param state The state the window is initially opened with.
* @param type The type of drawing context installed in this window.
* @param stereoVisual Stereo visual for quad buffered stereo.
+ * @param numOfAASamples Number of samples used for AA (zero if no AA)
*/
GHOST_WindowWin32(
GHOST_SystemWin32 * system,
@@ -85,7 +86,8 @@ public:
GHOST_TUns32 height,
GHOST_TWindowState state,
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
- const bool stereoVisual = false
+ const bool stereoVisual = false,
+ const GHOST_TUns16 numOfAASamples = 0
);
/**
diff --git a/intern/ghost/intern/GHOST_WindowX11.cpp b/intern/ghost/intern/GHOST_WindowX11.cpp
index 25d6c5980f6..286e64e7e23 100644
--- a/intern/ghost/intern/GHOST_WindowX11.cpp
+++ b/intern/ghost/intern/GHOST_WindowX11.cpp
@@ -153,9 +153,10 @@ GHOST_WindowX11(
GHOST_TWindowState state,
const GHOST_TEmbedderWindowID parentWindow,
GHOST_TDrawingContextType type,
- const bool stereoVisual
+ const bool stereoVisual,
+ const GHOST_TUns16 numOfAASamples
) :
- GHOST_Window(title,left,top,width,height,state,type,stereoVisual),
+ GHOST_Window(title,left,top,width,height,state,type,stereoVisual,numOfAASamples),
m_context(NULL),
m_display(display),
m_system (system),
diff --git a/intern/ghost/intern/GHOST_WindowX11.h b/intern/ghost/intern/GHOST_WindowX11.h
index 0dba1776553..9a299e16eb4 100644
--- a/intern/ghost/intern/GHOST_WindowX11.h
+++ b/intern/ghost/intern/GHOST_WindowX11.h
@@ -67,6 +67,7 @@ public:
* @param parentWindow Parent (embedder) window
* @param type The type of drawing context installed in this window.
* @param stereoVisual Stereo visual for quad buffered stereo.
+ * @param numOfAASamples Number of samples used for AA (zero if no AA)
*/
GHOST_WindowX11(
GHOST_SystemX11 *system,
@@ -79,7 +80,8 @@ public:
GHOST_TWindowState state,
const GHOST_TEmbedderWindowID parentWindow,
GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
- const bool stereoVisual = false
+ const bool stereoVisual = false,
+ const GHOST_TUns16 numOfAASamples = 0
);
bool