void keyMap(unsigned char key, int x,int y){ switch(key){ //Code to display a alphabet with pixels case '1': drawChars(); break; //Code to display a alphabet with pixels case '2': draw3dchars(); break; //Code to display the triangle case '3': glutPostRedisplay(); break; //Code to display a alphabet with pixels case ' ': draw3dchars(); break; } }
void drawUI(HexMemoryData* data, PDUI* uiFuncs) { PDVec2 textStart = uiFuncs->getCursorPos(); PDVec2 windowSize = uiFuncs->getWindowSize(); windowSize.y -= textStart.y; if (!data->data) return; const float fontHeight = uiFuncs->getFontHeight(); const float fontWidth = uiFuncs->getFontWidth(); int drawableLineCount = (int)(windowSize.y / fontHeight); float drawableChars = (float)(int)(windowSize.x / fontWidth); // margins between the rows drawableChars -= margins * 3.0f; //int addressTextSize = ((int)fontWidth) * (data->addressSize * 2) + 2; //printf("%d %d\n", addressTextSize, (int)drawableChars); //if (addressTextSize > drawableChars) // return; drawAddresses(data, uiFuncs, drawableLineCount, 8); uiFuncs->setCursorPos(textStart); drawNumbers(data, uiFuncs, drawableLineCount, 8, 76.0f); uiFuncs->setCursorPos(textStart); drawChars(data, uiFuncs, drawableLineCount, 8, 300.0f); }
void Snake::draw() { // Draw each segment for(unsigned int i = 0; i < size(); ++i) { drawChars(mySegments[i], SEGMENT_CHAR); } }
/*! This method is just like drawChars() except it treats yoff as position of the font baseline. The default implementation simply subtracts the ascent of the current font from yoff and calls drawChars(), which should work on all platforms except for win32. On win32 because of the trickery we use to achieve wysiwyg layout the acent of the font we work with is slightly smaller than that of the actual font the system uses to draw on the screen. As a result, the characters end up positioned slightly higher than they should and this has proved a problem in the math plugin (see screen shots in #9500) */ void GR_Graphics::drawCharsRelativeToBaseline(const UT_UCSChar* pChars, int iCharOffset, int iLength, UT_sint32 xoff, UT_sint32 yoff, int* pCharWidths) { drawChars(pChars, iCharOffset, iLength, xoff, yoff - getFontAscent(), pCharWidths); }
/*! renderChars() outputs textual data represented by ri onto the device (screen, priter, etc.). The output starts at ri.m_iOffset, is ri.m_iLength long and the drawing starts at ri.m_xoff, ri.m_yoff */ void GR_Graphics::renderChars(GR_RenderInfo & ri) { UT_return_if_fail(ri.getType() == GRRI_XP); GR_XPRenderInfo & RI = (GR_XPRenderInfo &)ri; drawChars(RI.s_pCharBuff,RI.m_iOffset,RI.m_iLength,RI.m_xoff,RI.m_yoff,RI.s_pAdvances); }
/** * Opens the given file in this MDI window. */ bool QC_MDIWindow::slotFileOpen(const QString& fileName, RS2::FormatType type) { RS_DEBUG->print("QC_MDIWindow::slotFileOpen"); bool ret = false; if (document && !fileName.isEmpty()) { document->newDoc(); // cosmetics.. // RVT_PORT qApp->processEvents(1000); qApp->processEvents(QEventLoop::AllEvents, 1000); ret = document->open(fileName, type); if (ret) { //QString message=tr("Loaded document: ")+fileName; //statusBar()->showMessage(message, 2000); if (fileName.endsWith(".lff") || fileName.endsWith(".cxf")) { drawChars(); RS_DEBUG->print("QC_MDIWindow::slotFileOpen: autoZoom"); graphicView->zoomAuto(false); RS_DEBUG->print("QC_MDIWindow::slotFileOpen: autoZoom: OK"); } else graphicView->redraw(); } else { RS_DEBUG->print("QC_MDIWindow::slotFileOpen: failed"); } } else { RS_DEBUG->print("QC_MDIWindow::slotFileOpen: cancelled"); //statusBar()->showMessage(tr("Opening aborted"), 2000); } RS_DEBUG->print("QC_MDIWindow::slotFileOpen: OK"); return ret; }
void display(){ //printf("starting diplay loop\n"); glClearColor(1,1,1,1); //white glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //printf("screen cleared\n"); //load program to use glUseProgram(shader3dprogram); //glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); //load vertex array to use glBindVertexArray(cubeVAO); ////setup first cube glm::mat4 view = camera.matrix(); glUniformMatrix4fv(ucamera, 1, GL_FALSE, &view[0][0]); glUniform3fv(ulightpos, 1, &light.position[0]); glUniform3fv(ulightint, 1, &light.intensities[0]); //add rotation glm::mat4 model = glm::rotate(glm::mat4(), degree, glm::vec3(0,1,1)); glUniformMatrix4fv(umodel, 1, GL_FALSE, &model[0][0]); light.intensities = glm::vec3(1,0,0); glUniform3fv(ulightint, 1, &light.intensities[0]); //draw triangle glDrawArrays(GL_TRIANGLES, 0, 6 * 2 * 3); ////setup second cube model = glm::rotate(glm::mat4(), degree, glm::vec3(0,1,0)); model = glm::translate(model, glm::vec3(-4,0,0)); glUniformMatrix4fv(umodel, 1, GL_FALSE, &model[0][0]); light.intensities = glm::vec3(0,1,0); glUniform3fv(ulightint, 1, &light.intensities[0]); glDrawArrays(GL_TRIANGLES, 0, 6 * 2 * 3); ////setup third cube model = glm::rotate(glm::mat4(), degree, glm::vec3(0,0,1)); model = glm::translate(model, glm::vec3(4,0,0)); glUniformMatrix4fv(umodel, 1, GL_FALSE, &model[0][0]); light.intensities = glm::vec3(0,0,1); glUniform3fv(ulightint, 1, &light.intensities[0]); glDrawArrays(GL_TRIANGLES, 0, 6 * 2 * 3); //printf("boxes drawn\n"); //draw overlay glUseProgram(shader2dprogram); //printf("using shard2dprogram\n"); glBindVertexArray(overlayVAO); //printf("overlayVAO has been bound\n"); glDrawArrays(GL_TRIANGLES, 0, 6); char framerate[80]; sprintf(framerate, "Frames per second: %d", fps); drawChars("Hello World!", -0.95,0.83f, 2.0/800, 2.0/600); drawChars(framerate, -0.95,0.70f, 2.0/800, 2.0/600); drawChars("abcdefghijklmnopqrstuvmxyz", -0.95, 0.0f, 2.0/800, 2.0/600); //unbind for next pass glBindVertexArray(0); glUseProgram(0); glfwSwapBuffers(); }
// Draw specified lines of text. void PaintText::drawLines(int start, int count) const { // Make sure we hav a display list. calcLayoutIfNeeded(); // Make sure we have something to do. if(m_lines.empty()) { return; } // Initialize the graphics state. GFXToggleTexture(false,0); if(gl_options.smooth_lines) { glEnable(GL_LINE_SMOOTH); } GFXPushBlendMode(); GFXBlendMode(SRCALPHA,INVSRCALPHA); glPushMatrix(); // Keep track of line position. float lineTop = m_rect.top(); // Figure ending line index. const int end = guiMin(start + count, m_lines.size()); // Loop through the display list lines. for(int i=start; i<end; i++) { const TextLine& line = m_lines[i]; // Make sure we can paint this line in the vertical space we have left. if(lineTop - line.height*LINE_HEIGHT_EPSILON < m_rect.origin.y) { // Not enough space to draw this line. break; } // Position at the start of the line. glLoadIdentity(); glTranslatef(m_rect.origin.x+line.x, lineTop-line.baseLine, 0.0); if (line.fragments.size()) { GFXColorf(line.fragments[0].color); } if (!useStroke()){ glRasterPos2f(0,0); }else glScaled(m_horizontalScaling, m_verticalScaling, 1.0); float rasterpos=0; // Draw each fragment. for(vector<TextFragment>::const_iterator frag=line.fragments.begin(); frag!=line.fragments.end(); frag++) { if(frag->start == ELLIPSIS_FRAGMENT) { // We have a special-case for the ellipsis at the end of a line. drawChars(ELLIPSIS_STRING, 0, 2, frag->font, frag->color,rasterpos); } else { rasterpos=drawChars(m_text, frag->start, frag->end, frag->font, frag->color,rasterpos); } } // Top of next line. lineTop -= line.height; } glRasterPos2f(0,0); // Undo graphics state GFXPopBlendMode(); if(gl_options.smooth_lines) { glDisable(GL_LINE_SMOOTH); } glPopMatrix(); GFXToggleTexture(true,0); }
void BonusApple::draw() { drawChars(myPos, "B"); }
void Apple::draw() { drawChars(myPos, "*"); }