zoukankan      html  css  js  c++  java
  • OpenGL ES 正反面设置指令

    在OpenGL ES 中,仅有一种表面网格表示方式,那就是三角形。

    三角形的三个顶点,可以组几个面?有答 1 的没有?有!那就是还不懂OpenGL ES 的我。

    事实上,一张纸是有正反面的,那么一个三角形也应该有两个面,那么在空间中,如何区分呢?那就是正反面。

    那具体哪个是正面,哪个是反面呢,据说是默认逆时针是正面,顺时针是反面,不过到现在还没搞清楚,这个顺和逆是个怎么看法,我们只知道在两个轴组成的二维平面坐标系中的顺和逆。

    有知道的朋友不妨给予指出,谢谢。


    不过,从下面的官方资料中,不难看出,应该是空间三角形的顶点向窗口坐标系做投影,得到的投影点,在一个二维坐标系中,就可以按二维坐标系中的顺逆来考虑了。

    先前,我一直考虑可能有个三维的知识点没有掌握,现在看来,还是要转成二维的来考虑。

    在研究三维的过程中,很多问题都要结合着二维来考虑,就比较顺畅了。

    上面说了,系统默认是逆时针是正面,那么顺时针就是反面了,如果想对调一下呢,那就得用下面的指令了 glFrontFace 。



    Name

    glFrontFace — 定义多边形的正面和背面 define front- and back-facing polygons

    C Specification

    void glFrontFace( GLenum mode);
     

    Parameters

    mode

    指定多边形正面的方向。可授受 GL_CW 和 GL_CCW 两个参数。初始值是 GL_CCW。

    Specifies the orientation of front-facing polygons. GL_CW and GL_CCW are accepted. The initial value is GL_CCW.

    描述 Description

    在一个完全由不透明的封闭表面组成的场景中,多边形的背面永远也看不到。忽略这些不可见的多边形对于提升图片的渲染速度有明显的好处。要启用或禁用多边形背面消除特性,可调用 glEnable 和 glDisable 并带参数 GL_CULL_FACE。

    如果一个假想的对象沿着它的第一个顶点、第二个顶点......直到最后一个顶点这样的路径,最后返回到第一个顶点,它围绕多边形本身按顺时针方向移动的,那么这个多边形映射到窗口坐标系的投影可以说成具有顺时针绕向。如果按同样的路径是以反时针方向绕多边形自身移动的,那么多边形的绕向就说成是反时针绕向。glFrontFace指定多边形在窗口坐标系中是顺时针绕向或反时针绕向作为正面;GL_CW 选择顺时针多边形作为正面。默认,反时针多边形被当作正面。

    In a scene composed entirely of opaque closed surfaces, back-facing polygons are never visible. Eliminating these invisible polygons has the obvious benefit of speeding up the rendering of the image. To enable and disable elimination of back-facing polygons, call glEnable and glDisable with argument GL_CULL_FACE.

    The projection of a polygon to window coordinates is said to have clockwise winding if an imaginary object following the path from its first vertex, its second vertex, and so on, to its last vertex, and finally back to its first vertex, moves in a clockwise direction about the interior of the polygon. The polygon's winding is said to be counterclockwise if the imaginary object following the same path moves in a counterclockwise direction about the interior of the polygon. glFrontFace specifies whether polygons with clockwise winding in window coordinates, or counterclockwise winding in window coordinates, are taken to be front-facing. Passing GL_CCW to mode selects counterclockwise polygons as front-facing; GL_CW selects clockwise polygons as front-facing. By default, counterclockwise polygons are taken to be front-facing.

    错误信息 Errors

    如果 mode 不是可接受的值,就会产生 GL_INVALID_ENUM 错误。

    GL_INVALID_ENUM is generated if mode is not an accepted value.

    Associated Gets

    glGet with argument GL_FRONT_FACE

    See Also

    glCullFace

    Copyright

    Copyright © 1991-2006 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.



  • 相关阅读:
    mysql数据引擎
    R语言入门
    springboot整合springmvc、mybatis
    svn搭建和配置
    UML常用图的几种关系的总结
    cookies和session机制
    Java总结篇系列:Java多线程(三)
    Java总结篇系列:Java多线程(一)
    Java总结篇系列:Java多线程(二)
    restframework之认证
  • 原文地址:https://www.cnblogs.com/riasky/p/3478959.html
Copyright © 2011-2022 走看看