void ScreenSerial::draw() { if ( !m_text || m_needs_drawing) { m_needs_drawing = false; //Start painting sequence painter.firstPage(); do { painter.setColorIndex(1); //Paint title on top of screen painter.title(MSG_SCREEN_SERIAL_TITLE()); //Paint bitmap on the left uint8_t x_init = painter.coordinateXInit(); uint8_t y_init = painter.coordinateYInit(); uint8_t x_end = painter.coordinateXEnd(); uint8_t y_end = painter.coordinateYEnd(); uint8_t x_offset = 6; uint8_t y_offset = 4; painter.setColorIndex(1); painter.drawBitmap(x_init + x_offset, y_init + y_offset, serial_width, serial_height, bits_serial); //Print state Area text_area(x_init + x_offset + serial_width, y_init, 127, 63); painter.setWorkingArea(text_area); SERIAL_ECHOLN(m_text); painter.multiText(m_text); } while( painter.nextPage() ); } }
sdl::timage draw_text_to_texture(const SDL_Rect &area, int size, const SDL_Color &color, const std::string &text, bool use_tooltips, int style) { SDL_Rect rect = text_area(text, size, style); surface surf = create_neutral_surface(rect.w, rect.h); draw_text(surf, area, size, color, text, 0, 0, use_tooltips, style); return sdl::timage(surf); }
rectangle textbox::text_area() const { internal_scope_guard lock; auto editor = get_drawer_trigger().editor(); if (editor) return editor->text_area(false); return{}; }
sdl::timage draw_text_to_texture(const SDL_Rect &area, int size, const SDL_Color &color, const std::string &text, bool use_tooltips, int style) { SDL_Rect rect = text_area(text, size, style); surface surf = SDL_CreateRGBSurface(SDL_SWSURFACE, rect.w, rect.h, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); SDL_FillRect(surf, NULL, 0x000000ff); draw_text(surf, area, size, color, text, 0, 0, use_tooltips, style); return sdl::timage(surf); }
void ScreenStop::draw() { uint8_t padding = 13; char c_time[24]; char total_time[24] = ""; snprintf(c_time, 24, "%02d:%02d", m_time.hours, m_time.minutes); strcat(total_time, c_time); char height[9] = "Z:"; char z_value[7] = { 0 }; uint8_t number_size = 5; if(m_height < 100) { number_size = 4; } else if(m_height < 10) { number_size = 3; } dtostrf(m_height, number_size, 2, z_value); strcat(height, z_value); painter.firstPage(); do { painter.title(m_title); painter.box(m_box); painter.setColorIndex(1); Area text_area(0, 14, 127, 41); painter.setWorkingArea(text_area); painter.multiText_P(m_message); painter.setPrintPos(padding, 43); painter.print(height); painter.drawBitmap(127 - strlen(total_time) * 6 - padding - icon_clock_width - 2, 43, icon_clock_width, icon_clock_height, icon_clock); painter.setPrintPos( 127 - strlen(total_time) * 6 - padding, 43); painter.print(total_time); } while( painter.nextPage() ); }
void ScreenEmergency::draw() { painter.firstPage(); do { painter.title(m_title); painter.box(m_box); painter.setColorIndex(1); Area bitmap_area(0, 14, 39, 54); painter.setWorkingArea(bitmap_area); uint8_t x_offset = 12; uint8_t y_offset = 9; Area temp_area = painter.getWorkingArea(); painter.drawBitmap(temp_area.x_init + x_offset, temp_area.y_init + y_offset, emergency_width, emergency_height, bits_emergency); Area text_area(40, 14, 127, 54); painter.setWorkingArea(text_area); painter.multiText_P(m_message); } while (painter.nextPage()); }
int draw( void ) { if(wireframe) { glClearColor(1, 1, 1, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glLineWidth(2); } else { glClearColor(0.2f, 0.2f, 0.2f, 1); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } // effacer l'image glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(key_state('r')) { clear_key_state('r'); reload_program(); } // recupere les mouvements de la souris int mx, my; unsigned int mb= SDL_GetRelativeMouseState(&mx, &my); int mousex, mousey; SDL_GetMouseState(&mousex, &mousey); // deplace la camera if(mb & SDL_BUTTON(1)) orbiter_rotation(camera, mx, my); // tourne autour de l'objet else if(mb & SDL_BUTTON(2)) orbiter_translation(camera, (float) mx / (float) window_width(), (float) my / (float) window_height()); // deplace le point de rotation else if(mb & SDL_BUTTON(3)) orbiter_move(camera, mx); // approche / eloigne l'objet // recupere les transformations Transform model= make_identity(); Transform view= orbiter_view_transform(camera); Transform projection= orbiter_projection_transform(camera, window_width(), window_height(), 45); Transform viewport= make_viewport(window_width(), window_height()); Transform mvp= projection * view * model; Transform mvpInv= make_inverse(mvp); Transform mv= model * view; // affiche l'objet if(program_failed == false) { if(key_state('w')) { clear_key_state('w'); wireframe= !wireframe; } // configuration minimale du pipeline glBindVertexArray(vao); glUseProgram(program); // affecte une valeur aux uniforms // transformations standards program_uniform(program, "modelMatrix", model); program_uniform(program, "modelInvMatrix", make_inverse(model)); program_uniform(program, "viewMatrix", view); program_uniform(program, "viewInvMatrix", make_inverse(view)); program_uniform(program, "projectionMatrix", projection); program_uniform(program, "projectionInvMatrix", make_inverse(projection)); program_uniform(program, "viewportMatrix", viewport); program_uniform(program, "viewportInvMatrix", make_inverse(viewport)); program_uniform(program, "mvpMatrix", mvp); program_uniform(program, "mvpInvMatrix", mvpInv); program_uniform(program, "mvMatrix", mv); program_uniform(program, "normalMatrix", make_normal_transform(mv)); // interactions program_uniform(program, "viewport", make_vec2(window_width(), window_height())); program_uniform(program, "time", (float) SDL_GetTicks()); program_uniform(program, "motion", make_vec3(mx, my, mb & SDL_BUTTON(1))); program_uniform(program, "mouse", make_vec3(mousex, mousey, mb & SDL_BUTTON(1))); // textures for(unsigned int i= 0; i < (unsigned int) textures.size(); i++) { char uniform[1024]; sprintf(uniform, "texture%d", i); program_use_texture(program, uniform, i, textures[i]); } // go glDrawArrays(GL_TRIANGLES, 0, vertex_count); } // affiche les infos begin(widgets); if(program_failed) { label(widgets, "[error] program '%s'", program_filename.path); begin_line(widgets); text_area(widgets, 20, program_log.c_str(), program_area); } else { label(widgets, "program '%s' running...", program_filename.path); if(mesh_filename[0] != 0) { begin_line(widgets); label(widgets, "mesh '%s', %u positions, %u texcoords, %u normals", mesh_filename.path, (unsigned int) mesh.positions.size(), (unsigned int) mesh.texcoords.size(), (unsigned int) mesh.normals.size()); } for(unsigned int i= 0; i < (unsigned int) texture_filenames.size(); i++) { begin_line(widgets); label(widgets, "texture%u '%s'", i, texture_filenames[i].path); } } end(widgets); draw(widgets, window_width(), window_height()); if(key_state('s')) { clear_key_state('s'); screenshot("shader_kit.png"); } if(key_state('c')) { clear_key_state('c'); write_orbiter(camera, "orbiter.txt"); } if(key_state('v')) { clear_key_state('v'); camera= read_orbiter("orbiter.txt"); } return 1; }
void ScreenStats::draw() { char temp_str[24]; uint8_t temp_lenght; uint8_t str_lenght; uint8_t num_spaces; // First line composition char total_time[24]; strcpy_P(total_time, MSG_SCREEN_VIEW_STATS_TEXT1()); str_lenght = strnlen(total_time,24); snprintf(temp_str, 24, "%01uh",m_hours); temp_lenght = strnlen(temp_str,24); num_spaces = 21-(str_lenght+temp_lenght); memset(&(total_time[str_lenght]), ' ', num_spaces); total_time[str_lenght + num_spaces] = '\0'; strcat(total_time, temp_str); // Second line composition char successful_prints[24]; strcpy_P(successful_prints, MSG_SCREEN_VIEW_STATS_TEXT2()); str_lenght = strnlen(successful_prints,24); snprintf(temp_str, 24, "%01u", m_succeded_prints); temp_lenght = strnlen(temp_str,24); num_spaces = 21-(str_lenght+temp_lenght); memset(&(successful_prints[str_lenght]), ' ', num_spaces); successful_prints[str_lenght + num_spaces] = '\0'; strcat(successful_prints, temp_str); // Third line composition char failed_prints[24]; strcpy_P(failed_prints, MSG_SCREEN_VIEW_STATS_TEXT3()); str_lenght = strnlen(failed_prints,24); snprintf(temp_str, 24, "%01u", m_failed_prints); temp_lenght = strnlen(temp_str,24); num_spaces = 21-(str_lenght+temp_lenght); memset(&(failed_prints[str_lenght]), ' ', num_spaces); failed_prints[str_lenght + num_spaces] = '\0'; strcat(failed_prints, temp_str); painter.firstPage(); do { painter.title(m_title); painter.box(m_box); painter.setColorIndex(1); //First line, printing time Area text_area(0, 17, 127, 29); painter.setWorkingArea(text_area); painter.text(total_time); //Second line, successful prints Area success_area(0, 30, 127, 42); painter.setWorkingArea(success_area); painter.text(successful_prints); //Third line, failed prints Area fail_area(0, 43, 127, 55); painter.setWorkingArea(fail_area); painter.text(failed_prints); } while( painter.nextPage() ); }