zoukankan      html  css  js  c++  java
  • OpenGLES中函数 glDrawArrays 详解

    glDrawArrays的功能:提供绘制功能,从数组数据中提取数据渲染基本图元。

    定义

    void glDrawArrays(  GLenum mode,    GLint first,    GLsizei count);  

    参数

    mode

        需要渲染的图元类型,包括 GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN ,GL_TRIANGLES。

    • GL_POINTS:把每一个顶点作为一个点进行处理,顶点n即定义了点n,共绘制N个点
    • GL_LINES:连接每两个顶点作为一个独立的线段,顶点2n-1和2n之间共定义了n条线段,总共绘制N/2条线段
    • GL_LINE_STRIP:绘制从第一个顶点到最后一个顶点依次相连的一组线段,第n和n+1个顶点定义了线段n,总共绘制n-1条线段
    • GL_LINE_LOOP:绘制从第一个顶点到最后一个顶点依次相连的一组线段,然后最后一个顶点和第一个顶点相连,第n和n+1个顶点定义了线段n,总共绘制n条线段
    • GL_TRIANGLES:把每三个顶点作为一个独立的三角形,顶点3n-2、3n-1和3n定义了第n个三角形,总共绘制N/3个三角形
    • GL_TRIANGLE_STRIP:绘制一组相连的三角形,对于奇数n,顶点n、n+1和n+2定义了第n个三角形;对于偶数n,顶点n+1、n和n+2定义了第n个三角形,总共绘制N-2个三角形
    • GL_TRIANGLE_FAN:绘制一组相连的三角形,三角形是由第一个顶点及其后给定的顶点确定,顶点1、n+1和n+2定义了第n个三角形,总共绘制N-2个三角形

    first   

        从数组缓存中的哪一位开始绘制,一般为0.

    count

        数组中顶点的数量.

    功能

    glDrawArrays specifies multiple geometric primitives with very few subroutine calls. It is possible to prespecify separate arrays of attributes and use them to construct a sequence of primitives with a single call to glDrawArrays.

    When glDrawArrays is called, it uses count sequential elements from each enabled array to construct a sequence of geometric primitives, beginning with element first. mode specifies what kind of primitives are constructed and how the array elements construct those primitives.

    To enable and disable a generic vertex attribute array, call glEnableVertexAttribArray and glDisableVertexAttribArray.

    If an array corresponding to a generic attribute required by a vertex shader is not enabled, then the corresponding element is taken from the current generic attribute state. Errors

    GL_INVALID_ENUM is generated if mode is not an accepted value.

    GL_INVALID_VALUE is generated if count is negative.

    GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to an enabled array and the buffer object's data store is currently mapped.

    GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete (i.e. the return value from glCheckFramebufferStatus is not GL_FRAMEBUFFER_COMPLETE).

    GL_INVALID_OPERATION is generated if recording the vertices of a primitive to the buffer objects being used for transform feedback purposes would result in either exceeding the limits of any buffer object’s size, or in exceeding the end position offset + size - 1, as set by glBindBufferRange.

  • 相关阅读:
    HDU:2767-Proving Equivalences(添边形成连通图)
    POJ:1330-Nearest Common Ancestors(LCA在线、离线、优化算法)
    HDU:1269-迷宫城堡(tarjan模板)
    Xml 丶json丶 C/S KVO 数据库 SQL 数据持久化 复杂对象 集合视图综合
    项目穿越记
    SDP (Session Description Protocol)
    shell脚本实现查找文件夹下重复的文件,并提供删除功能
    HDU 2896 病毒侵袭 (AC自动机)
    项目启动那些事儿
    C++ 完美破解九宫格(数独)游戏
  • 原文地址:https://www.cnblogs.com/lxb0478/p/6381677.html
Copyright © 2011-2022 走看看