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.

  • 相关阅读:
    [转]深入理解Java 8 Lambda(类库篇——Streams API,Collectors和并行)
    [转]深入理解Java 8 Lambda(语言篇——lambda,方法引用,目标类型和默认方法)
    JDE Develop Server分别安装DV PY PD后WEBSERVER问题
    [转]Java 8:不要再用循环了
    查找-find -grep
    长度有限制的字符串hash函数
    oracle 中proc和oci操作对缓存不同处理
    反编译.o到.cpp
    类的对象在外部访问它自己的私有成员变量没问题吗?
    strcpy(),string使用问题
  • 原文地址:https://www.cnblogs.com/lxb0478/p/6381677.html
Copyright © 2011-2022 走看看