static void drawScaleLabel(drawContext *ctx, PView *p, double xmin, double ymin, double width, double height, double tic, int horizontal) { PViewOptions *opt = p->getOptions(); PViewData *data; // requested by Laurent: but is this really what we should be doing? if(opt->externalViewIndex >= 0 && opt->externalViewIndex < (int)PView::list.size()) data = PView::list[opt->externalViewIndex]->getData(); else data = p->getData(); drawContext::global()->setFont(CTX::instance()->glFontEnum, CTX::instance()->glFontSize); double font_h = drawContext::global()->getStringHeight(); char label[1024]; int nt = data->getNumTimeSteps(); if((opt->showTime == 1 && nt > 1) || opt->showTime == 2){ char tmp[256]; sprintf(tmp, opt->format.c_str(), data->getTime(opt->timeStep)); sprintf(label, "%s (%s)", data->getName().c_str(), tmp); } else if((opt->showTime == 3 && nt > 1) || opt->showTime == 4){ sprintf(label, "%s (%d/%d)", data->getName().c_str(), opt->timeStep, data->getNumTimeSteps() - 1); } else sprintf(label, "%s", data->getName().c_str()); if(horizontal){ glRasterPos2d(xmin + width / 2., ymin + height + tic + 1.4 * font_h); ctx->drawString(label, CTX::instance()->glFontTitle, CTX::instance()->glFontEnumTitle, CTX::instance()->glFontSizeTitle, 1); } else{ glRasterPos2d(xmin, ymin - 2 * font_h); ctx->drawString(label, CTX::instance()->glFontTitle, CTX::instance()->glFontEnumTitle, CTX::instance()->glFontSizeTitle, 0); } }
GLvoid output(float row, float col, std::string out) { int len, i; glRasterPos2d(col, row); len = (int)out.length(); for (i = 0; i < len; i++) { glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, out[i]); } }
void Writer::write(const TRaster32P &ras, Processor *processor) { m_context->makeCurrent(); glClear(GL_COLOR_BUFFER_BIT); if (ras) { glRasterPos2d(0, 0); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // ras->getWrap()); glDrawPixels(ras->getLx(), ras->getLy(), TGL_FMT, TGL_TYPE, ras->getRawData()); } if (processor) { processor->draw(); } glRasterPos2d(0, 0); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // ras->getWrap()); glReadPixels(0, 0, m_raster->getLx(), m_raster->getLy(), TGL_FMT, TGL_TYPE, m_raster->getRawData()); TImageP img = TRasterImageP(m_raster); m_levelWriter->getFrameWriter(++m_frameCount)->save(img); }
void AGIPane::drawcoodname(int i){ const int w = getWidth(); glRasterPos2d(ag->getV(i,0)*xyrate * coodrate + w/2, ag->getV(i,1)*xyrate *coodrate+ w/2); std::string str = data->atrname.at(i); int size = (int)str.size(); for(int j = 0;j< size;j++){ char ic = str[j]; glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,ic); } }
void GameMenu::DrawStart(double begin) { glColor3ub(0,0,0); glRasterPos2d((windowWid/2)-90,(windowHei/2)-16); YsGlDrawFontBitmap20x32("S T A R T"); }
// 押されたマス目の描画 void displayPushedPiece(int x, int y, int num) { // マス目の色をGrayにする displayPiece(x, y, colors[Gray]); // 数字描画 glColor3dv(colors[num]); glRasterPos2d(sqrSize*(x + frame)+sqrSize*1.5 / 5.0, sqrSize*(y + frame)+sqrSize*4.0 / 5.0); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, numbers[num]); }
void Texture::DisplayTexture(GLdouble width,GLdouble height,GLdouble x,GLdouble y) { glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glPushMatrix(); // Store The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix glOrtho(0,width,0,height,-1,1); // Set Up An Ortho Screen glRasterPos2d(x,y); glDrawPixels(textureImage->sizeX,textureImage->sizeY,GL_RGB,GL_UNSIGNED_BYTE,textureImage->data); glPopMatrix(); }
void PrintPower(int power) { char str[256]; if (power > 0) sprintf (str, "Remaining Power: %d", power); else sprintf (str, "Lazer Enemy is Died!"); glColor3ub(255,255,255); glRasterPos2d(100,700); YsGlDrawFontBitmap8x12(str); }
void disp_string(float x, float y, char *str) { int i; i = 0; glColor3f(1.0f, 1.0f, 1.0f); glRasterPos2d(x, y); while (str[i]) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, str[i++]); free(str); }
void surface_copy(int destination, float x, float y, int source) { get_surface(ssurf,source); get_surface(dsurf,destination); unsigned char *surfbuf=new unsigned char[dsurf->width*dsurf->height*4]; glBindFramebuffer(GL_READ_FRAMEBUFFER, ssurf->fbo); glReadPixels(0,0,dsurf->width,dsurf->height,GL_RGBA,GL_UNSIGNED_BYTE,surfbuf); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dsurf->fbo); glPushMatrix(); glPushAttrib(GL_VIEWPORT_BIT); screen_set_viewport(0, 0, dsurf->width, dsurf->height); d3d_set_projection_ortho(0, 0, dsurf->width, dsurf->height, 0); glRasterPos2d(x, y); glDrawPixels(dsurf->width,dsurf->height,GL_RGBA,GL_UNSIGNED_BYTE,surfbuf); glBindFramebuffer(GL_READ_FRAMEBUFFER, enigma::bound_framebuffer); glPopAttrib(); glPopMatrix(); glRasterPos2d(0, 0); delete[] surfbuf; }
//------------------------------------------------------------------------------ // Pixmap Font functions // FtglPixmapFont::outputText() -- FTGLPixmapFont output routines //------------------------------------------------------------------------------ void FtglPixmapFont::outputText(const double x, const double y, const char* txt, const int n, const bool vf, const bool) { // Make sure we have characters to print if (n <= 0) return; // Make sure we have a loaded font if (isNotLoaded()) { loadFont(); if (isNotLoaded()) throw new ExpInvalidFont(); } // Prepare the output text char cbuf[MSG_BUF_LEN]; int nn = xferChars(cbuf,MSG_BUF_LEN,txt,n); if (nn <= 0) return; // output the text FTGLPixmapFont* ftgl1 = static_cast<FTGLPixmapFont*>(FTGL()); if (ftgl1 != nullptr) { if (vf) { // Vertical text char cc[2]; cc[1] = '\0'; for (int i = 0; i < nn; i++) { cc[0] = cbuf[i]; glRasterPos2d( x, (y - static_cast<float>(i)*getLineSpacing()) ); ftgl1->Render(cc); } } else { // Normal text glRasterPos2d(x,y); ftgl1->Render(cbuf); } } else { if (isMessageEnabled(MSG_ERROR)) { std::cerr << "FTGLPixmapFont::outputText() - no Pixmap font available" << std::endl; } } }
void drawText (double x, double y, const char s[]) { int i, length; char c; glRasterPos2d (x, y); length = strlen (s); for (i=0; i<length; i++) { c = s[i]; glutBitmapCharacter (GLUT_BITMAP_8_BY_13, c); } }
void FrameDisplayGL::paintGL() { ImageDisplay* displayedImage = image; glRasterPos2d(0,currHeight); // нижний левый угол glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // выравнивание glPixelZoom( 1 , 1 ); glDrawPixels( displayedImage->getWidth(), displayedImage->getHeight(), GL_RGB, GL_FLOAT, displayedImage->getImage() ); }
void DrawText(double x, double y, char *string) { int len, i; void *font = GLUT_BITMAP_9_BY_15; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glRasterPos2d(x, y); len = (int) strlen(string); for (i = 0; i < len; i++) { glutBitmapCharacter(font, string[i]); } glDisable(GL_BLEND); }
/** * Copies memory into frame buffer and updates the window * using an OpenGL command. */ void ColorBuffer::showColorBuffer() { // Insure raster position is lower left hand corner of the window. glRasterPos2d(-1, -1); // Copy color buffer to raster (OpenGL command) glDrawPixels( window.width, window.height, GL_RGBA, GL_UNSIGNED_BYTE, colorBuffer ); // Flush all drawing commands and swapbuffers glutSwapBuffers(); } // end showColorBuffer
/* 文字描画*/ void drawBitmapString(void *font, string s, int x, int y) { double _x1 = 2.0*x/WINDOW_W - 1; double _y1 = -2.0*y/WINDOW_H + 1; glPushAttrib(GL_CURRENT_BIT); glRasterPos2d(_x1, _y1); /* 描画位置 */ /* ビットマップ文字列の描画 */ for(unsigned int i=0; i<s.size() ;i++) glutBitmapCharacter(font, s[i]); glPopAttrib(); }
void text() { double x = -1.25, y = -0.33, dy = 0.13; glColor3f(1., 1., 0.); glRasterPos2d(x, y); printstring("Press:", 0.); y -= dy; glRasterPos2d(x, y); printstring(" p: to change the print format (PS, EPS, PDF, ...)", 0.); y -= dy; glRasterPos2d(x, y); printstring(" s: to save the images", 0.); y -= dy; glRasterPos2d(x, y); printstring(" t: to alternate between teapot and torus", 0.); y -= dy; glRasterPos2d(x, y); printstring(" v: to alternate between single and multiple viewport modes", 0.); y -= dy; glRasterPos2d(x, y); printstring(" b: to change the blending mode (transparency)", 0.); y -= dy; glRasterPos2d(x, y); printstring(" q: to quit", 0.), 0.; y -= dy; glRasterPos2d(x, y); printstring("Click and move the mouse to rotate the objects", 0.); glRasterPos2d(0, 0.75); printstring("rotated!", 45.); glRasterPos2d(x, 1.15); printstring(format_string, 0.); gl2psSpecial(GL2PS_TEX, "% This should only be printed in LaTeX output!"); }
// afisare arborele lui Perron void Display3() { CArborePerron cap; char c[3]; sprintf(c, "%2d", nivel); glRasterPos2d(-0.98,-0.98); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'N'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'i'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'v'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'e'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'l'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, '='); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, c[0]); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, c[1]); glRasterPos2d(-1.0,-0.9); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'a'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'r'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'b'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'o'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'r'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'e'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, ' '); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'P'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'e'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'r'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'r'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'o'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'n'); glPushMatrix(); glLoadIdentity(); glScaled(0.4, 0.4, 1); glTranslated(-0.5, -0.5, 0.0); cap.afisare(1, nivel); glPopMatrix(); nivel++; }
void Enemy::displayHP() { vector<double> bound = getNewBoundary(0, 0); double x = bound[0] + 5; double y = bound[2] + 5; glRasterPos2d(x, y); string num; int temp = hp; while (temp) { num += '0' + temp % 10; temp /= 10; } reverse(num.begin(), num.end()); glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_10, (unsigned char*) num.c_str()); }
void Display8() { nivel++; CMandelbrot cm; cm.afisare(100, 0.0, nivel); glColor3d(0, 0, 0); glRasterPos2d(-0.98,-0.98); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, '('); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, '-'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, '2'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, ','); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, '-'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, '2'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, ')'); glRasterPos2d(0.7,0.9); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, '('); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, '2'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, ','); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, '2'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, ')'); }
void Score::DrawScoreCard(void) { char *gameName[] = { "Pool", "CAD", "Gear", "Keep Awake"}; FsGetWindowSize(winWid, winHei); glRasterPos2d(0.0,(double)(winHei-1)); glDrawPixels(scoreCard.wid,scoreCard.hei,GL_RGBA,GL_UNSIGNED_BYTE,scoreCard.rgba); char msg[256]; glColor3ub(0, 0, 0); for (int i=0; i<4; i++) { sprintf(msg, "Game %d: %s", i+1, gameName[i]); glRasterPos2d(175, 175+i*100); YsGlDrawFontBitmap16x24(msg); sprintf(msg, "%d trials, %s", gameCount[i], gamePassed[i]?"Passed":"Failed"); glRasterPos2d(225, 215+i*100); YsGlDrawFontBitmap16x24(msg); } }
void drawplane(const int counter) { if(counter==1) { glColor3ub(0,255,0); //printf("\n colour changed to green"); } else if(counter==2) { glColor3ub(0,255,255); //printf("\n colour changed to some colour"); } else if(counter==3) { glColor3ub(0,0,255); //printf("\n colour changed to blue"); } if(counter==1) { glRasterPos2d(300,100); YsGlDrawFontBitmap20x32("THE BAT X"); } if(counter==2) { glRasterPos2d(300,100); YsGlDrawFontBitmap20x32("THE FA-HORNET"); } if(counter==3) { glRasterPos2d(300,100); YsGlDrawFontBitmap20x32("THE DESTROYER"); } }
// ボードの基礎の描画 void displayBoard() { // タイトル描画 glColor3d(1, 1, 1); glRasterPos2d(sqrSize*frame, sqrSize*9.0 / 5.0); for (char* str = title; *str; str++) { glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *str); } for (int i = 0; i < sqrNum; i++) { for (int j = 0; j < sqrNum; j++) { displayPiece(i, j, colors[Blue]); } } }
void TextInput::Draw(void) { glColor3ub(0,0,0); glRasterPos2d(490,250); YsGlDrawFontBitmap20x32(str.GetPointer()); switch(time(NULL)%2) { case 0: YsGlDrawFontBitmap20x32("_"); break; case 1: YsGlDrawFontBitmap20x32(" "); break; } }
void DrawLetter(Piece piece) { int x = piece.x_Location + (piece.size/2)-5; int y = piece.y_Location + (piece.size/2)-5; int letter = piece.pieceID; glColor4f(1.0f, 0.5f, 0.0f, 0.5f); glRasterPos2d(x, y); int div; for (div = 1; div <= letter; div *= 10); do { div /= 10; glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, (letter == 0 ? 0 : (letter / div)) + '0'); if (letter != 0) letter %= div; } while (letter); }
void renderBitmapString( float x, float y, int spacing, void *font, char *string) { char *c; int x1 = x; //Guarda posicao rasterizada para computar espaco for (c=string; *c != '\0'; c++) { glRasterPos2d(x1,y); glutBitmapCharacter(font, *c); x1 = x1 + glutBitmapWidth(font, *c) + spacing; } }
// Outputs a string of text at the specified location. void DrawText(double x, double y, std::string *stringer) { void *font = GLUT_BITMAP_9_BY_15; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); int len, i; glRasterPos2d(x, y); len = stringer->length(); for (i = 0; i < len; i++) { glutBitmapCharacter(font, stringer->at(i)); } glDisable(GL_BLEND); }
void View::draw_text(double x, double y, const char* text, int align) { void* font = GLUT_BITMAP_9_BY_15; if (align > -1) { int width = glutBitmapLength(font, (const unsigned char*) text); if (align == 1) x -= width; // align right else x -= (double) width / 2; // center } y += 5; //(double) glutBitmapHeight(font) / 2 - 1; glDisable(GL_TEXTURE_1D); glDisable(GL_LIGHTING); glRasterPos2d((int) (x+0.5), (int) (y+0.5)); glutBitmapString(font, (const unsigned char*) text); }
// afisare patrate void Display6() { CArbore ca; ca.afisare(0.1, nivel); char c[3]; sprintf(c, "%2d", nivel); glRasterPos2d(-0.98,-0.98); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'N'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'i'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'v'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'e'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'l'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, '='); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, c[0]); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, c[1]); nivel++; }
// afisare patrate void Display5() { CPatrate cp; cp.afisare(1.6, nivel); char c[3]; sprintf(c, "%2d", nivel); glRasterPos2d(-0.98,-0.98); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'N'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'i'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'v'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'e'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, 'l'); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, '='); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, c[0]); glutBitmapCharacter(GLUT_BITMAP_9_BY_15, c[1]); nivel++; }