简体   繁体   English

OpenGL es 2中的顶点。适用于Android的Java

[英]Vertices in OpenGL es 2. Java for Android

I'm following this tutorial, to learn OpenGl es 2.0. 我正在按照教程学习OpenGl ES 2.0。 Those informations (plus a lot of others tutorials) led me to this: vertices must be declared in an array, the array must be sent to the GPU memory with FloatBuffer operations, from there they must be picked up by openGL. 这些信息(加上许多其他教程)使我想到了这一点:必须在数组中声明顶点,必须使用FloatBuffer操作将数组发送到GPU内存,然后必须由openGL将其拾取。 What follows is a little bit obscure, to me. 对我来说,后面的内容有些晦涩。 The question is: once the vertices are there (in the gpu memory) what part of a java program is meant to pick up these data? 问题是:一旦顶点存在(在gpu内存中),Java程序的哪一部分将要拾取这些数据? The shader and fragment code? 着色器和片段代码? The vertexattrib array commands? vertexattrib数组命令?

The way OpenGL works on a very basic level, not much really happens until you issue a draw call, like glDrawArrays or glDrawElements . OpenGL在非常基本的水平上工作的方式,直到发出诸如glDrawArraysglDrawElements类的绘制调用后,真正的事情才会发生。 Most other calls just set up state that will be used by the draw calls. 大多数其他调用只是设置将由绘图调用使用的状态。 The most important parts of state are what you have already seen: 状态最重要的部分是您已经看到的内容:

  • glVertexAttribArray and related calls are used to specify the vertex data used for the draw call. glVertexAttribArray和相关调用用于指定用于绘制调用的顶点数据。
  • glUseProgram , and all the calls you use before that to build a program, specify what shaders will be run for your draw call. glUseProgram ,以及在此之前用于构建程序的所有调用,指定将为绘画调用运行哪些着色器。

Once you have all this state set up, and issue a draw call, you set the whole machinery in motion. 设置好所有状态并发出抽奖通知后,就可以使整个机械运转。 If you want to read up on details on everything that happens here, you should be able to find good material with search terms like "OpenGL rendering pipeline", or in any OpenGL book. 如果您想详细了解此处发生的所有事情,则应该能够使用“ OpenGL渲染管道”之类的搜索词或任何OpenGL书中找到好的材料。 Very roughly, the main steps are the following: 大致来说,主要步骤如下:

  • A fixed function unit grabs the vertex data based on the state you set up with glVertexAttribArray and related calls, and feeds that data into the vertex shader. 固定功能单元根据您使用glVertexAttribArray设置的状态和相关调用来获取顶点数据,并将该数据输入到顶点着色器中。
  • The vertex shader you set up receives this vertex data in its attribute variables, and processes it. 您设置的顶点着色器在其attribute变量中接收此顶点数据,并对其进行处理。
  • The processed vertices produced by your vertex shader are rasterized by a fixed function unit, which decides which pixels need to be rendered. 顶点着色器产生的已处理顶点由固定功能单元栅格化,该功能单元确定需要渲染的像素。
  • Those pixels (aka fragments) are fed into the fragment shader. 这些像素(也称为片段)被馈入片段着色器。
  • The fragment shader you set up processes these fragments, and outputs the color for the fragments. 您设置的片段着色器将处理这些片段,并输出这些片段的颜色。
  • The colors produced by your fragment shader are written to the framebuffer. 片段着色器产生的颜色将被写入帧缓冲区。

There's more to it than what I listed here, but I hope this will help you understand the basics. 除了我在这里列出的内容以外,还有更多其他功能,但是我希望这将有助于您了解基本知识。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM