简体   繁体   English

使用QVector3D在OpenGL中绘制点

[英]Draw points in OpenGL with QVector3D

I have a list of QVector3D , which is a list of points, I want to draw a list of points with glDrawArrays . 我有一个QVector3D列表,这是一个点列表,我想用glDrawArrays绘制一个点列表。

initializeGLFunctions();

glGenBuffers(2, vbo);
//the vertices 
QVector3D *vertices = &data[0];

glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
glBufferData(GL_ARRAY_BUFFER, data.size() * sizeof(QVector3D), vertices, GL_STATIC_DRAW);

glDrawArrays(GL_POINTS,??);

or what other method I can use to deal with this? 或我可以使用什么其他方法来处理呢?

glBufferData(GL_ARRAY_BUFFER, data.size() * sizeof(QVector3D), vertices, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER,data.size()* sizeof(QVector3D),顶点,GL_STATIC_DRAW);

This is correct, but I would suggest to use more intelligent containers like QVector outside an then constData as follows: 这是正确的,但是我建议在然后constData之外使用更智能的容器,例如QVector,如下所示:

glBufferData(GL_ARRAY_BUFFER, data.size() * sizeof(QVector3D), myVector.constData(), GL_STATIC_DRAW);

Here is another official example how to use glBufferData in the context of QVector3D : 这是另一个官方示例,该示例如何在glBufferData的上下文中使用QVector3D

geometryengine.cpp Example File geometryengine.cpp示例文件

Here can you find another third-party example following the official example: 在官方示例之后,您可以在这里找到另一个第三方示例:

FabScan100 FabScan100

Then, you could write: 然后,您可以编写:

glDrawArrays(GL_POINTS, 0, data.size());

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

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