void desactivar_actuador(int x, int y, TipoActuador actuador, string nombre){ std::swap( x,y); SDL_Rect rect; rect.x = x; rect.y = y; rect.w = 100; rect.h = 100; SDL_SetRenderDrawColor(renderer,0xFF,0xFF,0xFF,0xFF); SDL_RenderFillRect(renderer, &rect); SDL_RenderPresent(renderer); switch (actuador){ case Alarma: filledCircleRGBA( renderer, ORIGEN_X + x, ORIGEN_Y + y, 6, 0xFF,0xFF,0xFF,0xFF); circleRGBA(renderer, ORIGEN_X + x, ORIGEN_Y + y, 6 , 0xFF,0x00,0x00,0xFF); renderString(nombre.c_str(), x +ORIGEN_X-3 ,y+ORIGEN_Y-18, 0xFF,0x00,0x00); renderString("OFF", x +ORIGEN_X-6 ,y+ORIGEN_Y+10, 0xFF,0x00,0x00); break; case Luz: filledCircleRGBA( renderer, ORIGEN_X + x, ORIGEN_Y + y, 6, 0xFF,0xFF,0xFF,0xFF); circleRGBA(renderer, ORIGEN_X + x, ORIGEN_Y + y, 6 , 0xFF,0xB4,0x00,0xFF); renderString(nombre.c_str(), x +ORIGEN_X-3 ,y+ORIGEN_Y-18,0xFF,0xB4,0x00); renderString("OFF", x +ORIGEN_X-6 ,y+ORIGEN_Y+10,0xFF,0xB4,0x00); break; }; SDL_RenderPresent(renderer); }
void TextRenderer::renderToBox(string text,float width, float height){ int maxChars=width/renderWidth; int maxLines=height/renderHeight; int cnt=0; int begin=0; int x=0; int lx=0; while(x<text.length()){ lx=x; x=getNextWord(text,x,maxChars); if(x-begin>maxChars){ renderString(text.substr(begin,lx-begin),-cnt*renderHeight); cnt++; if(cnt>maxLines) break; begin=lx+1; } renderString(text.substr(begin,x-begin),-cnt*renderHeight); } }
void valor_sensor(int x, int y, TipoSensor sensor, float valor){ std::swap( x,y); SDL_Rect rect; rect.x = x +ORIGEN_X-6; rect.y = y+ORIGEN_Y+10; rect.w = 50; rect.h = 14; SDL_SetRenderDrawColor(renderer,0xFF,0xFF,0xFF,0xFF); SDL_RenderFillRect(renderer, &rect); SDL_RenderPresent(renderer); switch (sensor){ case Temperatura: circleRGBA( renderer, ORIGEN_X + x, ORIGEN_Y + y, 6, 0,255,0,255); renderString(toString(valor).c_str(), x +ORIGEN_X-6 ,y+ORIGEN_Y+10,0,255,0); break; case Luminosidad: circleRGBA( renderer, ORIGEN_X + x, ORIGEN_Y + y, 6, 0xFF,0xFF,0xFF,0xFF); renderString(toString(valor).c_str(), x +ORIGEN_X-6 ,y+ORIGEN_Y+10,0xFF,0xFF,0xFF); break; case Humo: circleRGBA( renderer, ORIGEN_X + x, ORIGEN_Y + y, 6, 0x00,0x00,0xFF,0xFF); renderString(toString(valor).c_str(), x +ORIGEN_X-6 ,y+ORIGEN_Y+10,0x00,0x00,0xFF); break; }; }
//Show the text void drawText(){ glPushMatrix(); glLoadIdentity(); gluOrtho2D(0.0, 512.0, 0.0, 512.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glColor3f(1.0, 1.0, 1.0); //renderString(string, posx, posy) renderString("Press G to toggle balls", 330, 450); renderString("Press H to toggle Grid", 330, 430); renderString("Play with water using mouse", 330, 410); renderString("Rotate container with A and D", 330, 390); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); }
void HudGaugeThrottle::renderThrottleSpeed(float current_speed, int y_end) { char buf[32]; int sx, sy, x_pos, y_pos, w, h; //setGaugeColor(); sprintf(buf, "%d", fl2i(current_speed+0.5f)); hud_num_make_mono(buf, font_num); gr_get_string_size(&w, &h, buf); if ( orbit ) { // y_end is the y-coordinate of the current throttle setting, calc x-coordinate for edge of // circle (x^2 + y^2 = r^2) y_pos = position[1] + Orbit_center_offsets[1] - y_end; x_pos = (int)sqrt(double(orbit_radius * orbit_radius - y_pos * y_pos) ); x_pos = position[0] + Orbit_center_offsets[0] - x_pos; // draw current speed at (x_pos, y_end); sx = x_pos - w - 2; sy = fl2i(y_end - h/2.0f + 1.5); } else { sx = position[0] + Orbit_center_offsets[0] - w; sy = position[1] + Orbit_center_offsets[1]; } renderPrintf(sx, sy, buf); if ( object_get_gliding(Player_obj) ) { if ( Use_custom_glide ) { renderString(position[0] + Glide_offsets[0], position[1] + Glide_offsets[1], "GLIDE"); } else { int offset; if ( current_speed <= 9.5 ) { offset = -31; } else if ( current_speed <= 99.5 ) { offset = -22; } else { offset = -13; } renderString(sx+offset, sy + h, "GLIDE"); } } else if ( Players[Player_num].flags & PLAYER_FLAGS_MATCH_TARGET ) { if ( Use_custom_match_speed ) { renderMatchSpeedIcon(position[0] + Match_speed_offsets[0], position[1] + Match_speed_offsets[1]); } else { int offset; if ( current_speed <= 9.5 ) { offset = 0; } else { offset = 3; } renderMatchSpeedIcon(sx+offset, sy + h); } } }
// draw the shield icon and integrity for the escort ship void HudGaugeEscort::renderIcon(int x, int y, int index) { if(MULTI_DOGFIGHT && index <= 2) { renderIconDogfight(x, y, index); return; } float shields, integrity; int screen_integrity, offset; char buf[255]; object *objp = &Objects[Escort_ships[index].objnum]; ship *sp = &Ships[objp->instance]; // determine if its "friendly" or not // Goober5000 - changed in favor of just passing the team setGaugeColorEscort(index, sp->team); /* if(Player_ship != NULL){ hud_escort_set_gauge_color(index, (sp->team == Player_ship->team) ? 1 : 0); } else { hud_escort_set_gauge_color(index, 1); } */ // draw a 'D' if a ship is disabled if ( (sp->flags & SF_DISABLED) || (ship_subsys_disrupted(sp, SUBSYSTEM_ENGINE)) ) { renderString( x + ship_status_offsets[0], y + ship_status_offsets[1], EG_NULL, XSTR( "D", 284)); } // print out ship name strcpy_s(buf, sp->ship_name); gr_force_fit_string(buf, 255, ship_name_max_width); end_string_at_first_hash_symbol(buf); renderString( x + ship_name_offsets[0], y + ship_name_offsets[1], EG_ESCORT1 + index, buf); // show ship integrity hud_get_target_strength(objp, &shields, &integrity); screen_integrity = fl2i(integrity*100 + 0.5f); offset = 0; if ( screen_integrity < 100 ) { offset = 2; if ( screen_integrity == 0 ) { if ( integrity > 0 ) { screen_integrity = 1; } } } renderPrintf( x+ship_integrity_offsets[0] + offset, y+ship_integrity_offsets[1], EG_NULL, "%d", screen_integrity); //Let's be nice. setGaugeColor(); }
void HudGaugeRadarStd::drawContactCircle( int x, int y, int rad ) { if ( rad == Radar_blip_radius_target ) { if (radar_target_id_flags & RTIF_BLINK) { if (Missiontime & 8192) return; } renderString( Large_blip_offset_x+x, Large_blip_offset_y+y, Large_blip_string ); } else { // rad = RADAR_BLIP_RADIUS_NORMAL; renderString( Small_blip_offset_x+x, Small_blip_offset_y+y, Small_blip_string ); } }
void PropPC::input(SDL_Event e) { if (crashed) return; renderString("_", (text.size() + 1) * 8, lineHeight * 8, Pixel(0x0, 0x0, 0x0, 0xFF)); char key = e.key.keysym.sym; if (key == SDLK_BACKSPACE) { if (!text.empty()) { for (int x = 0; x < 16; x++) { for (int y = 0; y < 8; y++) { setPixel(text.size()*8 + x, lineHeight * 8 + y, Pixel(0x0, 0x0, 0x0, 0xFF)); } } text.pop_back(); } } else if (key == SDLK_RETURN) { std::string command = text.substr(0, text.find(" ")); if (command == "crash") { crashed = true; } else if (command == "camera") { this->texture = this->cameraTexture; } else if (command == "help") { renderString("crash\ncamera\necho <text>", 0, (lineHeight + 1)*8, Pixel(0xFF, 0xFF, 0xFF, 0xFF)); lineHeight += 4; } else if (command == "echo") { renderString(text.substr(text.find(" ") + 1, text.length() - 1), 0, (lineHeight + 1) * 8, Pixel(0xFF, 0xFF, 0xFF, 0xFF)); lineHeight += 2; } lineHeight++; text = ""; renderString(">", 0, 0 + lineHeight * 8, Pixel(0xFF, 0xFF, 0xFF, 0xFF)); } else { if (key >= '0' && key <= '9' || key >= 'a' && key <= 'z' || key == ' ' || key == ',' || key == '.') { if (key >= 'a' && key <= 'z') { if (e.key.keysym.mod & (KMOD_SHIFT | KMOD_CAPS)) { key -= 32; } } else if (key >= '0' && key <= '9') { if (e.key.keysym.mod & (KMOD_SHIFT | KMOD_CAPS)) { key -= 16; } } text += key; } renderString(text, 8, 0 + lineHeight * 8, Pixel(0xFF, 0xFF, 0xFF, 0xFF)); } if ((text.size()) % (300 / 8) + 1 == 0) { text += "\n"; } }
void showErrorMessage(const char *msg) { SDL_Event event; const char * s; int y = VID_Y/4; SDL_FillRect(SDL_GetVideoSurface(), NULL, 0); for( s = msg; s && s[0]; s = strchr(s, '\n'), s += (s ? 1 : 0), y += 35 ) { const char * s1 = strchr(s, '\n'); int len = s1 ? s1 - s : strlen(s); char buf[512]; strncpy(buf, s, len); buf[len] = 0; if( len > 0 ) renderString(buf, VID_X/2, y); } SDL_Flip(SDL_GetVideoSurface()); while (1) { while (SDL_WaitEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_UNDO || event.key.keysym.sym == SDLK_ESCAPE) exit(1); break; } } } }
void drawHex(u32 val, int x, int y) { char str[9]; hex2str(str,val); renderString(str,x,y); }
void HudGaugeWingmanStatus::renderBackground(int num_wings_to_draw) { int sx, sy, bitmap; if((num_wings_to_draw < 1) || (num_wings_to_draw > 5)){ Int3(); return; } if((num_wings_to_draw > 2) && (grow_mode == GROW_LEFT)) { // make some room for the spacers sx = position[0] - (num_wings_to_draw - 2)*wing_width; } else { sx = position[0]; } sy = position[1]; bitmap = Wingman_status_left.first_frame; if ( bitmap > -1 ) { renderBitmap(bitmap, sx, sy); } //Tell renderDots() where to start actual_origin[0] = sx; actual_origin[1] = sy; // write "wingmen" on gauge renderString(sx+header_offsets[0], sy+header_offsets[1], XSTR( "wingmen", 352)); // bring us to the end of the left portion so we can draw the last or middle bits depending on how many wings we have to draw if ( grow_mode == GROW_DOWN ) { sy += left_frame_end_x; } else { sx += left_frame_end_x; } bitmap = Wingman_status_middle.first_frame; if ( grow_mode == GROW_DOWN ) { for ( int i = 0; i < num_wings_to_draw; i++ ) { renderBitmap(bitmap, sx, sy); sy += wing_width; } sy += right_frame_start_offset; } else { if(num_wings_to_draw > 2 && bitmap > 0) { for(int i = 0; i < num_wings_to_draw - 2; i++){ renderBitmap(bitmap, sx, sy); sx += wing_width; } } sx += right_frame_start_offset; } bitmap = Wingman_status_right.first_frame; renderBitmap(bitmap, sx, sy); }
void Font::renderString( const std::string & str, glm::vec2 & cursor, float fontSize, float maxWidth) { renderString(toUtf16(str), cursor, fontSize, maxWidth); }
void ofkFontRenderer::renderString(const string& srt, float scale, string ID) { glPushMatrix(); glScalef(scale, scale, scale); renderString(srt, ID); glPopMatrix(); }
void PropPC::update() { Prop::update(); if (age % (60 / 10) == 0) { if (crashed) { for (int x = 0; x < 320 / 16 + 1; x++) { for (int y = 0; y < 200 / 16 + 1; y++) { Pixel p = Pixel(Util::random() * 0xFF, Util::random() * 0xFF, Util::random() * 0xFF, 0xFF); for (int px = 0; px < 16; px++) { for (int py = 0; py < 16; py++) { setPixel(x * 16 + px, y * 16 + py, p); } } } } } else { if (age % (60/4) == 0) { caret = !caret; GLubyte carCol = caret ? 0xFF : 0x0; renderString("_", (text.size() + 1) * 8, lineHeight * 8, Pixel(carCol, carCol, carCol, 0xFF)); } } redraw(); } }
void render(void) { unsigned int time = glutGet(GLUT_ELAPSED_TIME); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); { camApply(); glTranslatef(0, 0, -5); glRotatef(90, 1, 0, 0); draw_obj(go); } glPopMatrix(); // draw fps char buf[128]; sprintf(buf, "fps: %.2f", fps); glColor3f(0.8, 0, 0); renderString(10, 10, buf, NULL); // camera matrix { int y, x; for (y=0; y<4; y++) for (x=0; x<4; x++) { sprintf(buf, "%+.3f", camera[y*4+x]); renderString(10 + x * 80, 180 - y*20, buf, NULL); } } float pos[3]; camGetPosition(pos); sprintf(buf, "%+.3f %+.3f %+.3f", pos[0], pos[1], pos[2]); renderString(10, 40, buf, NULL); glutSwapBuffers(); if (key[27]) exit(0); camBegin(); if (key['w']) camForward(+4 / fps); if (key['s']) camForward(-4 / fps); if (key['d']) camTurn(+90 / fps); if (key['a']) camTurn(-90 / fps); if (key['q']) camPan(+4 / fps); if (key['e']) camPan(-4 / fps); camEnd(); fps = 1000.0 / (glutGet(GLUT_ELAPSED_TIME) - time); }
void HudGaugeFixedMessages::render(float frametime) { HUD_ft *hp; hp = &HUD_fixed_text[0]; if (!timestamp_elapsed(hp->end_time)) { gr_set_color((hp->color >> 16) & 0xff, (hp->color >> 8) & 0xff, hp->color & 0xff); if (center_text) { int w = 0; gr_get_string_size(&w, nullptr, hp->text); renderString(position[0] - (w / 2), position[1], hp->text); } else { renderString(position[0], position[1], hp->text); } //renderString(0x8000, MSG_WINDOW_Y_START + MSG_WINDOW_HEIGHT + 8, hp->text); }
PUBLIC ssize espRenderConfig(HttpConn *conn) { cchar *config; if ((config = getClientConfig(conn)) != 0) { return renderString(config); } return 0; }
Image* FontBase::getAsImage(const std::string& text) { Image* image = m_pool.getRenderedText(this, text); if (!image) { SDL_Surface* textSurface = renderString(text); image = RenderBackend::instance()->createImage(textSurface); m_pool.addRenderedText( this, text, image ); } return image; }
PropPC::PropPC(Level *level, GLuint t) : Prop("PC", level, 7, 5.25f, 11) { GLuint texture; glGenTextures(1, &texture); this->cameraTexture = t; this->texture = texture; Events::addListener(onKeyPress, SDL_KEYDOWN, this); renderString(">", 0, 0 + lineHeight * 8, Pixel(0xFF, 0xFF, 0xFF, 0xFF)); redraw(); }
void marca_sensor(int x, int y, TipoSensor sensor, string nombre){ SDL_RenderPresent(renderer); std::swap(x,y); switch (sensor){ case Temperatura: filledCircleRGBA(renderer, ORIGEN_X + x, ORIGEN_Y + y, 6, 0,0xFF,0,0xFF); renderString(nombre.c_str(), x+ORIGEN_X-3, y+ORIGEN_Y-18,0,0xFF,0); break; case Luminosidad: filledCircleRGBA(renderer, ORIGEN_X + x, ORIGEN_Y + y, 6,0xFF,0xFF,0xFF,0xFF); renderString(nombre.c_str(), x+ORIGEN_X-3, y+ORIGEN_Y-18, 0xFF,0xFF,0xFF); break; case Humo: filledCircleRGBA(renderer, ORIGEN_X + x, ORIGEN_Y + y, 6, 0,0,0xFF,0xFF); renderString(nombre.c_str(), x+ORIGEN_X-3, y+ORIGEN_Y-18,0,0,0xFF); break; }; SDL_RenderPresent(renderer); }
void drawButton(button_t *button, staticPlacement_t placement) { // Border glColor3f(0.0f, 0.0f, 0.0f); drawRect(placement); // Text glColor3f(1.0f,1.0f,1.0f); renderString(button->dynText ? *button->dynText : button->text, placement, ANCHOR_CENTER, -1); }
void ubcopy (int *data,int size) { renderString(20,29,"XModem transfer progress:"); renderHexU32(45,29,(u32)offset); memcpy ((void *)(UBOOT_ADDR + offset),(void *)data,size); offset += size; return; }
void Debugger::renderDebug(GLFWwindow *window) { #ifdef DEBUG glPushAttrib(GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT); glPushMatrix(); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); int width, height; float ratio; glfwGetFramebufferSize(window, &width, &height); ratio = width / (float) height; glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, width, 0, height, -10, 10); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor3f(1, 1, 1); float x=0, y=10.3, dy=10; for( auto it = debugInfo.begin(); it != debugInfo.end(); it++) { //情報を書いた場所を記述 renderString((*it).first, x, y); y+=dy; //デバッグ情報の記述 auto localDebugInfo = (*it).second; for( auto it2 = localDebugInfo.begin(); it2 != localDebugInfo.end(); it2++, y+=dy) renderString((*it2).first + " : " + (*it2).second, x, y); } glPopMatrix(); glPopAttrib(); clearDebugInfo(); #endif }
void SimonEngine::printInteractText(uint16 num, const char *string) { char convertedString[320]; char *convertedString2 = convertedString; const char *string2 = string; uint16 height = 15; uint16 w = 0xFFFF; uint16 b, pixels, x; // It doesn't really matter what 'w' is to begin with, as long as it's // something that cannot be generated by getPixelLength(). The original // used 620, which was a potential problem. while (1) { string2 = getPixelLength(string, 620, pixels); if (*string2 == 0x00) { if (w == 0xFFFF) w = pixels; strcpy(convertedString2, string); break; } while (*string2 != ' ') { byte chr = *string2; pixels -= charWidth[chr]; string2--; } if (w == 0xFFFF) w = pixels; b = string2 - string; strncpy(convertedString2, string, b); convertedString2 += b; *convertedString2++ = '\n'; height += 15; string = string2; } // ScrollX x = _variableArray[251]; x += 20; if (num == 1) _interactY = 385; // Returned values for box definition _variableArray[51] = x; _variableArray[52] = _interactY; _variableArray[53] = w; _variableArray[54] = height; stopAnimateSimon2(2, num + 6); renderString(num, 0, w, height, convertedString); loadSprite(4, 2, num + 6, x, _interactY, 12); _interactY += height; }
void HudGaugeFixedMessages::render(float frametime) { HUD_ft *hp; hp = &HUD_fixed_text[0]; if (!timestamp_elapsed(hp->end_time)) { gr_set_color((hp->color >> 16) & 0xff, (hp->color >> 8) & 0xff, hp->color & 0xff); renderString(position[0], position[1], hp->text); //renderString(0x8000, MSG_WINDOW_Y_START + MSG_WINDOW_HEIGHT + 8, hp->text); }
void HudGaugeEscort::render(float frametime) { int i = 0; if ( !Show_escort_view ) { return; } if ( !Num_escort_ships ) { return; } // hud_set_default_color(); setGaugeColor(); // draw the top of the escort view renderBitmap(Escort_gauges[0].first_frame, position[0], position[1]); renderString(position[0] + header_text_offsets[0], position[1] + header_text_offsets[1], header_text); int x = position[0] + list_start_offsets[0]; int y = position[1] + list_start_offsets[1]; //This is temporary Num_escort_ships--; i=0; if(Num_escort_ships) { for(; i < Num_escort_ships; i++) { if(i != 0) { x += entry_stagger_w; y += entry_h; } renderBitmap(Escort_gauges[1].first_frame, x, y); //Now we just show the ships info renderIcon(x, y, i); } //Increment for last entry x += entry_stagger_w; y += entry_h; } //Back to right # Num_escort_ships++; //Show the last escort entry renderBitmap(Escort_gauges[2].first_frame, x, y + bottom_bg_offset); renderIcon(x, y, i); }
void inicio(){ if (SDL_Init(SDL_INIT_EVERYTHING) || TTF_Init()) exit(1); wnd = SDL_CreateWindow("SHOL GUI", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800,800, SDL_WINDOW_SHOWN); renderer = SDL_CreateRenderer(wnd,-1,SDL_RENDERER_SOFTWARE); fnt_pt = TTF_OpenFont("font.ttf", 12); if (fnt_pt == NULL){ printf("Font (font.ttf) not found! Exiting...\n"); exit(1); } SDL_SetRenderDrawColor(renderer, 0,0,0,255); SDL_RenderClear(renderer); int fila,columna; fila = 60; columna = 560; renderString("Smart Home", columna, fila, 0xFF,0xFF,0xFF); fila = 80; renderString("Proyecto TL", columna, fila, 0xFF,0xFF,0xFF); fila = 100; renderString("Curso 2015/2016", columna, fila, 0xFF,0xFF,0xFF); renderString("Simulador de Smart Home - Plano de la casa", 50, 10, 0xFF,0xFF,0xFF); SDL_Rect *rect = new SDL_Rect(); rect->x = ORIGEN_X-5; rect->y = ORIGEN_Y-5; rect->w = 455; rect->h = 555; SDL_SetRenderDrawColor(renderer, 255,255,255,255); SDL_RenderFillRect(renderer, rect); fila = 180; columna = 560; renderString("Sensor de temperatura", columna+20,fila , 0,0xFF,0); ellipseRGBA(renderer, columna, fila, 6,6,0,0xFF,0,0xFF); fila = 200; columna = 560; renderString("Sensor de luminosidad",columna+20,fila,0xFF,0xFF,0xFF); ellipseColor(renderer, columna, fila, 6,6, 0xFFFFFFFF); fila = 220; columna = 560; renderString("Sensor de humo",columna+20,fila,0x00,0x00,0xFF); ellipseRGBA(renderer, columna, fila, 6,6, 0x00,0x00,0xFF,0xFF); fila = 250; columna = 560; renderString("Alarma",columna+20,fila,0xFF,0x00,0x00); ellipseColor(renderer, columna, fila, 6,6, 0xFF0000FF); fila = 270; columna = 560; renderString("Luz",columna+20,fila,0xFF,0xB4,0x00); ellipseRGBA(renderer, columna, fila, 6,6, 0xFF,0xB4,0x00,0xFF); SDL_RenderPresent(renderer); }
Image* FontBase::getAsImageMultiline(const std::string& text) { const uint8_t newline_utf8 = '\n'; uint32_t newline; utf8::utf8to32(&newline_utf8,&newline_utf8 + 1,&newline); //std::cout << "Text:" << text << std::endl; Image* image = m_pool.getRenderedText(this, text); if (!image) { std::vector<SDL_Surface*> lines; std::string::const_iterator it = text.begin(); // split text as needed int render_width = 0, render_height = 0; do { uint32_t codepoint = 0; std::string line; while( codepoint != newline && it != text.end() ) { codepoint = utf8::next(it,text.end()); if( codepoint != newline ) utf8::append(codepoint, back_inserter(line)); } //std::cout << "Line:" << line << std::endl; SDL_Surface* text_surface = renderString(line); if (text_surface->w > render_width) { render_width = text_surface->w; } lines.push_back(text_surface); } while (it != text.end()); render_height = (getRowSpacing() + getHeight()) * lines.size(); SDL_Surface* final_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, render_width,render_height,32, RMASK, GMASK, BMASK ,AMASK); if (!final_surface) { throw SDLException(std::string("CreateRGBSurface failed: ") + SDL_GetError()); } SDL_FillRect(final_surface, 0, 0x00000000); int ypos = 0; for (std::vector<SDL_Surface*>::iterator i = lines.begin(); i != lines.end(); ++i) { SDL_Rect dst_rect = { 0, 0, 0, 0 }; dst_rect.y = ypos; SDL_SetAlpha(*i,0,SDL_ALPHA_OPAQUE); SDL_BlitSurface(*i,0,final_surface,&dst_rect); ypos += getRowSpacing() + getHeight(); SDL_FreeSurface(*i); } image = RenderBackend::instance()->createImage(final_surface); m_pool.addRenderedText(this, text, image); } return image; }
PUBLIC void espRenderConfig(HttpConn *conn) { EspRoute *eroute; MprJson *settings; eroute = conn->rx->route->eroute; settings = mprLookupJson(eroute->config, "settings"); if (settings) { renderString(mprJsonToString(eroute->config, MPR_JSON_QUOTES)); } else { renderError(HTTP_CODE_NOT_FOUND, "Cannot find config.settings to send to client"); } finalize(); }
/** * Renders everything for a head animation * Also checks for when new head ani's need to start playing */ void HudGaugeTalkingHead::render(float frametime) { if ( Head_frame.first_frame == -1 ) { return; } if(msg_id != -1 && head_anim != NULL) { if(!head_anim->done_playing) { // draw frame // hud_set_default_color(); setGaugeColor(); // clear setClip(position[0] + Anim_offsets[0], position[1] + Anim_offsets[1], Anim_size[0], Anim_size[1]); gr_clear(); resetClip(); renderBitmap(Head_frame.first_frame, position[0], position[1]); // head ani border float scale_x = i2fl(Anim_size[0]) / i2fl(head_anim->width); float scale_y = i2fl(Anim_size[1]) / i2fl(head_anim->height); gr_set_screen_scale(fl2ir(base_w / scale_x), fl2ir(base_h / scale_y)); setGaugeColor(); generic_anim_render(head_anim,frametime, fl2ir((position[0] + Anim_offsets[0] + HUD_offset_x) / scale_x), fl2ir((position[1] + Anim_offsets[1] + HUD_offset_y) / scale_y)); // draw title gr_set_screen_scale(base_w, base_h); renderString(position[0] + Header_offsets[0], position[1] + Header_offsets[1], XSTR("message", 217)); } else { for (int j = 0; j < Num_messages_playing; ++j) { if (Playing_messages[j].id == msg_id) { Playing_messages[j].play_anim = false; break; // only one head ani plays at a time } } msg_id = -1; // allow repeated messages to display a new head ani head_anim = NULL; // Nothing to see here anymore, move along } } // check playing messages to see if we have any messages with talking animations that need to be created. for (int i = 0; i < Num_messages_playing; i++ ) { if(Playing_messages[i].play_anim && Playing_messages[i].id != msg_id ) { msg_id = Playing_messages[i].id; if (Playing_messages[i].anim_data) head_anim = Playing_messages[i].anim_data; else head_anim = NULL; return; } } }