点OpenGL的数组数组、OpenGL

2023-09-07 23:19:51 作者:赴一场爱意

我有以下的code,以画点的数组,但只汲取一点在中心。怎样绘制使用OpenGL的2D点阵列?

 闪烁NumberOfPoints = 10;
GLfloat×〔2],Y [2];

在glBegin(GL_POINTS);

的for(int i = 0; I< NumberOfPoints ++ I)
{
    glVertex2f(X [I]中,值Y [i]);

}
glEnd();
 

解决方案

你在哪里设置值X [0],X [1],Y [0]和Y [1]?

如果这只是画一个点为中心,这听起来像中的值设置为0所有四个这些变量。请确保您参考他们在您的来电gVertex2f()之前初始化它们的值。

QtOpenGL入门教程 三 初识OpenGL对象 顶点数组对象和缓存对象

I have the following code to draw an array of points but it only draws one point in the center. How can I draw an array of 2D points using OpenGL?

GLint NumberOfPoints = 10;
GLfloat x[2],y[2];

glBegin( GL_POINTS );

for ( int i = 0; i < NumberOfPoints; ++i )
{
    glVertex2f( x[i], y[i] );

}
glEnd();

解决方案

Where are you setting the values for x[0], x[1], y[0], and y[1]?

If it's only drawing one point in the center, it sounds like the values are set to 0 for all four of those variables. Be sure to initialize their values before you reference them in your call to gVertex2f().