#include #include #include #include #include #define WINDSIZEX 100 #define WINDSIZEY 100 void init(void) { } static const char progStr[] = "!!ARBvp1.0\n\ OUTPUT otex0 = result.texcoord[0];\n\ \n\ PARAM EX2const = { 0.000000, -2.000000, 1.000000, -1.000000 };\n\ EX2 otex0, EX2const.y;\n\ END\n\n\ \0"; static void test(void) { GLuint vpHandle; const GLsizei FEEDBACK_SIZE = 1024; const GLenum FEEDBACK_TYPE = GL_4D_COLOR_TEXTURE; GLfloat buf[1024]; GLint feedbackSize; GLint errorPosition; // enable the extension glEnable(GL_VERTEX_PROGRAM_ARB); //Generate the vertex program and have the API return the VP handle glGenProgramsARB(1, &vpHandle); //Bind the program with the handle that contains the vertex program glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vpHandle); glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLint) strlen((const char*)progStr), progStr); glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPosition); if (errorPosition != -1) { printf("\nERROR loading vertex program! Error position = %d\n", errorPosition); exit(1); } glFeedbackBuffer(FEEDBACK_SIZE, FEEDBACK_TYPE, buf); feedbackSize = glRenderMode(GL_FEEDBACK); glBegin( GL_POINTS ); glVertex3f(0.25f, 0.25f, 0.0f); glEnd(); feedbackSize = glRenderMode(GL_RENDER); printf("feedback size: %d\n", feedbackSize); printf("feedback buffer:%f %f %f %f\n", buf[9], buf[10], buf[11], buf[12]); printf("it should be: 0.25 0.25 0.25 0.25\n"); } void display(void) { glViewport(0, 0, WINDSIZEX, WINDSIZEY); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, WINDSIZEX, 0, WINDSIZEY); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); test(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(WINDSIZEX, WINDSIZEY); glutInitWindowPosition(100, 100); glutCreateWindow(argv[0]); init(); glutDisplayFunc(display); glutMainLoop(); return 0; }