2012-04-26 91 views
0

我有一个2007年的MacBook Pro与ATI radeon X1600显卡。我正在尝试使用多重采样功能获得抗锯齿功能。在opengl 2.1中使用多重采样进行抗混叠?

使用GlView,这是我手头的资料显示:

渲染信息是:

渲染:ATI的Radeon X1600的OpenGL EngineVendor:ATI技术Inc.Memory:128 MBVersion:2.1 ATI-7.0.52Device:MacBookPro2,2Shading语言版本:1.20

我查了扩展信息的arb_multisample和它说: “晋升为核心功能,在OpenGL 1.3”,它是正确的,然后假设 那在我的代码我可以简单地说(因为我是基于OpenGL 2.1):

glEnable(GL_MULTISAMPLE)

在我的应用程序代码中,我有一个数据结构,它具有以下信息: 顶点,索引和纹理,然后我渲染使用glDrawElements等等。所有的 都是三角网格。

的代码看起来是这样的:

(capi:define-interface stad-viewer (capi:interface) 
     ((double-buffered-p :initform t :initarg :double-buffered-p :accessor double- 
      buffered-p)) 
     (:panes 
     (canvas opengl:opengl-pane 
       :configuration (list :rgba t :depth t :depth-buffer 32 :double-buffered t) 
       :min-width 1440 
       :min-height 900 
       :message "Stadium demo" 
       :drawing-mode :quality 
       :reader canvas 
       :resize-callback 'resize-stad-canvas 
       :display-callback 'redisplay-stad-canvas)) 
     (:layouts 
     (main capi:column-layout '(canvas))) 
     (:default-initargs :auto-menus NIL :title "Stadium Viewer"))  


;;; enable multisampling 
(opengl:gl-enable opengl:*gl-multisample*) 
(opengl:gl-sample-coverage 0.70 opengl:*gl-false*) 

;;; some more opengl commands.... 

;;; rendering meshes 
(dolist (wfmesh *wfmeshes*) 
    (format t " ------ PREPARING MESH ---- ~A ~% " (mesh-name wfmesh)) 
    (multiple-value-bind (vertices indices) 
     (prepare-mesh wfmesh) 
     (let* ((gl-vertices (gl-vertexes vertices)) 
      (gl-indices (gl-indexes indices))) 
     (if *texture-ids* 
      (multiple-value-bind (texture-id found) 
        (gethash (mesh-name wfmesh) *texture-ids*) 
      (when found 
       (opengl:gl-bind-texture opengl:*gl-texture-2d* texture-id) 
       (opengl:gl-tex-coord-pointer 2 opengl:*gl-float* 0 
                (gl-texels (mesh-vertices wfmesh) 
                 1.0 t)))))  
     (opengl:gl-vertex-pointer 3 opengl:*gl-float* 0 gl-vertices) 
     (opengl:gl-draw-elements opengl:*gl-triangles* 
            (length indices) 
            opengl:*gl-unsigned-int* 
            gl-indices)))) 

也如上面我已经启用了多重采样。 However this is what I get

锯齿状边缘清晰可见。

所以我的问题是:

  1. 我的理解是多级采样是核心功能是否正确?
  2. 只需启用多重采样和调用绘图代码工作或一些更多的步骤来获得多重采样的工作?

回答

3

您使用的是Cocoa NSOpenGLView吗?因为那样你可以在Interface Builder中启用多重采样。在任何情况下,您都必须使用示例缓冲区专门创建渲染上下文。无论如何,glEnable(GL_MULTISAMPLE)是不够的。为了获得更具体的帮助,您需要说明如何创建OpenGL窗口/视图。

+0

其实我使用Lispworks和他们的ffi接口来使用opengl。 Lispworks GUI工具包(CAPI)有一个特定的opengl窗格。所以从你提到的内容来看,我认为我必须找出如何用样本缓冲区创建opengl上下文。 – 2012-04-26 12:28:20

+0

用实际代码更新了问题。 capi-define-interface部分是带有opengl窗格的窗口被创建的地方。其余部分是启用多重采样然后渲染网格。对不起,我没有发布实际的代码,并提供了我使用lisp的事实。 – 2012-04-26 12:40:45

+0

我不知道lisp或Lispworks,但我认为在创建OpenGL窗格时,必须将更多参数添加到配置列表中。在引擎盖下,这一切都取决于选择支持多重采样的适当像素格式。这个[示例](http://www.opengl.org/wiki/Multisampling)适用于Windows,但它解释了多重采样如何取决于像素格式。 – 2012-04-26 13:11:16