static GLboolean test_instancing(GLuint divisor) { static const GLfloat verts[4][2] = { {-1, -1}, {1, -1}, {1, 1}, {-1, 1} }; glVertexPointer(2, GL_FLOAT, 0, verts); glEnableClientState(GL_VERTEX_ARRAY); glVertexAttribPointer(PosAttrib, 2, GL_FLOAT, GL_FALSE, 0, Positions); glVertexAttribPointer(ColorAttrib, 4, GL_FLOAT, GL_FALSE, 0, Colors); glEnableVertexAttribArray(PosAttrib); glEnableVertexAttribArray(ColorAttrib); glVertexAttribDivisorARB(PosAttrib, 1); /* advance color once every 'n' instances */ glVertexAttribDivisorARB(ColorAttrib, divisor); glClear(GL_COLOR_BUFFER_BIT); glUseProgram(Program); glDrawArraysInstancedARB(GL_POLYGON, 0, 4, PRIMS); glUseProgram(0); { GLint i; GLint pos[4]; for (i = 0; i < PRIMS; i++) { GLuint elem = i / divisor; /* use glRasterPos to determine where to read a sample pixel */ glRasterPos2fv(Positions[i]); glGetIntegerv(GL_CURRENT_RASTER_POSITION, pos); if (!piglit_probe_pixel_rgba(pos[0], pos[1], Colors[elem])) { fprintf(stderr, "%s: instance %d failed to draw correctly\n", TestName, i); fprintf(stderr, "%s: color instance divisor = %u\n", TestName, divisor); glutSwapBuffers(); return GL_FALSE; } } } glDisableClientState(GL_VERTEX_ARRAY); glDisableVertexAttribArray(PosAttrib); glDisableVertexAttribArray(ColorAttrib); glutSwapBuffers(); return GL_TRUE; }
void bglVertex2fv(const float vec[2]) { switch (curmode) { case GL_POINTS: if (pointhack) { glRasterPos2fv(vec); glBitmap(pointhack, pointhack, (float)pointhack / 2, pointhack / 2, 0.0, 0.0, Squaredot); } else { glVertex2fv(vec); } break; } }
// -------------------------------------------------------------------------------------------------------- void kDisplayString ( const std::string & str, const KVector & position, void * font ) { std::string replaced(str); kStringReplace(replaced, "\\n", "\n"); if (font == GLUT_STROKE_ROMAN || font == GLUT_STROKE_MONO_ROMAN) { kStrokeString(replaced, position, font); } else { glRasterPos2fv(position.getValues()); kBitmapString(replaced, position, font); } }
void display(void) { float rp[2]; blur_(xw, yw, pxa); glClear(GL_COLOR_BUFFER_BIT); rp[0]=-((float)*xw)/xwidth; rp[1]=-((float)*yw)/ywidth; glRasterPos2fv(rp); glDrawPixels(*xw, *yw, GL_RGBA, GL_UNSIGNED_BYTE, pxa); glFlush(); glutSwapBuffers(); }
void CFontDisplay::display(int fontsize,char *str,GLfloat *fontlocation,GLfloat *fontcolor) { if (fontcolor==NULL) { fontcolor=m_fontcolor; } if (fontlocation==NULL) { fontlocation=m_fontlocation; } //glClear(GL_COLOR_BUFFER_BIT); selectFont(fontsize, DEFAULT_CHARSET, "Times New Roman"); //默认设定 glColor3fv(fontcolor); glRasterPos2fv(fontlocation); // DrawString("Hello, World!"); // glRasterPos2f(0.5,0.8); drawCNString(str); // drawChar_To_Texture(("我")); // drawChar_To_Texture("ff"); // glutSwapBuffers(); }
void VisualizerPlot1D::draw() { glColor3f( _params.color.x, _params.color.y, _params.color.z ); draw_frame2D( _wnd_rect ); draw_axes2D( _wnd_rect ); glRasterPos2fv( _wnd_rect.minpt ); glPrint( _caption ); if( !cursor()->on_pause() ) { _coords.clear(); cursor()->snapshort( storage() ); if( cursor()->count() < 1 ) return; std::vector<float> data = storage()->read_elem( cursor()->count()-1 ); if( _coords.capacity() == 0 ) { AllocGlBuffers( data.size() ); } GLfloat dt = _wnd_rect.len[0] / data.size(); GLfloat t = _wnd_rect.len[0] * 0.5f; for( long i = 0; i < (long)data.size(); ++i ) { _coords.push_back( _wnd_rect.center[0] + t ); _coords.push_back( _wnd_rect.center[1] + _params.scale * data[i] ); _coords.push_back( 0 ); t -= dt; } } glLineWidth( 2. ); glColor3f( _params.color.x, _params.color.y, _params.color.z ); draw_arrays( &_coords[0], _coords.size() / 3 ); }
M(void, glRasterPos2fv, jobject v) { glRasterPos2fv(BUFF(GLfloat, v)); }
///////////////////////////////////////////////////////// // Render // void GEMglRasterPos2fv :: render(GemState *state) { glRasterPos2fv (v); }
void __glXDisp_RasterPos2fv(GLbyte *pc) { glRasterPos2fv( (GLfloat *)(pc + 0) ); }
static GLboolean test_instancing(GLuint divisor) { static const GLfloat verts[4][2] = { {-1, -1}, {1, -1}, {1, 1}, {-1, 1} }; GLuint vbo; uintptr_t offset = 0; if (use_vbo) { glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(verts) + sizeof(Positions) + sizeof(Colors), NULL, GL_STATIC_DRAW); glBufferSubData(GL_ARRAY_BUFFER, offset, sizeof(verts), verts); glVertexPointer(2, GL_FLOAT, 0, (void*) offset); offset += sizeof(verts); glBufferSubData(GL_ARRAY_BUFFER, offset, sizeof(Positions), Positions); glVertexAttribPointer(PosAttrib, 2, GL_FLOAT, GL_FALSE, 0, (void*) offset); offset += sizeof(Positions); glBufferSubData(GL_ARRAY_BUFFER, offset, sizeof(Colors), Colors); glVertexAttribPointer(ColorAttrib, 4, GL_FLOAT, GL_FALSE, 0, (void*) offset); offset += sizeof(Colors); glBindBuffer(GL_ARRAY_BUFFER, 0); } else { glVertexPointer(2, GL_FLOAT, 0, verts); glVertexAttribPointer(PosAttrib, 2, GL_FLOAT, GL_FALSE, 0, Positions); glVertexAttribPointer(ColorAttrib, 4, GL_FLOAT, GL_FALSE, 0, Colors); } glEnableClientState(GL_VERTEX_ARRAY); glEnableVertexAttribArray(PosAttrib); glEnableVertexAttribArray(ColorAttrib); glVertexAttribDivisorARB(PosAttrib, 1); /* advance color once every 'n' instances */ glVertexAttribDivisorARB(ColorAttrib, divisor); glClear(GL_COLOR_BUFFER_BIT); glUseProgram(Program); glDrawArraysInstancedARB(GL_POLYGON, 0, 4, PRIMS); glUseProgram(0); if (use_vbo) { glDeleteBuffers(1, &vbo); } { GLint i; GLint pos[4]; for (i = 0; i < PRIMS; i++) { GLuint elem = i / divisor; /* use glRasterPos to determine where to read a sample pixel */ glRasterPos2fv(Positions[i]); glGetIntegerv(GL_CURRENT_RASTER_POSITION, pos); if (!piglit_probe_pixel_rgba(pos[0], pos[1], Colors[elem])) { fprintf(stderr, "%s: instance %d failed to draw correctly\n", TestName, i); fprintf(stderr, "%s: color instance divisor = %u\n", TestName, divisor); piglit_present_results(); return GL_FALSE; } } } glDisableClientState(GL_VERTEX_ARRAY); glDisableVertexAttribArray(PosAttrib); glDisableVertexAttribArray(ColorAttrib); piglit_present_results(); return GL_TRUE; }