I am trying to read the value from glEvalCoord, but not getting the exact values which I should get. My code is
GLfloat ctrlpoints[4][3] = {
{ -4.0, -4.0
I think your size
is 28
because your projection/modelview pair is clipping out some points.
"In feedback mode, each primitive that would be rasterized ... generates a block of values that's copied into the feedback array."
Try this:
#include <GL/glut.h>
#include <iostream>
using namespace std;
void display()
{
glClear( GL_COLOR_BUFFER_BIT );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
double w = glutGet( GLUT_WINDOW_WIDTH );
double h = glutGet( GLUT_WINDOW_HEIGHT );
double ar = w / h;
glOrtho( -5 * ar, 5 * ar, -5, 5, -1, 1 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
GLfloat ctrlpoints[4][3] =
{
{ -4.0, -4.0, 0.0 }, { -2.0, 4.0, 0.0 },
{ 2.0, -4.0, 0.0 }, { 4.0, 4.0, 0.0 }
};
glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints[0][0]);
glEnable(GL_MAP1_VERTEX_3);
GLfloat feedBuffer[1024];
glFeedbackBuffer (1024, GL_3D, feedBuffer);
glRenderMode (GL_FEEDBACK);
glPointSize( 5 );
glColor3ub( 255, 255, 255 );
glBegin (GL_POINTS);
for (int i=0; i<=30; ++i)
{
GLfloat t = GLfloat(i)/30;
glEvalCoord1f(t);
}
glEnd();
GLint size = glRenderMode (GL_RENDER);
cerr << size << endl;
glutSwapBuffers();
}
int main( int argc, char **argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE );
glutInitWindowSize( 640, 480 );
glutCreateWindow( "GLUT" );
glutDisplayFunc( display );
glutMainLoop();
return 0;
}
I added a slightly larger projection matrix.
With that I get a size
of 124
:
GL_POINT_TOKEN
per point = 3131 + 91 = 124