void bar_widget::draw_ticks(GLfloat x_offset, int segments, const SDL_Color& color) const { // tick marks if(segments > 1) { std::vector<GLfloat>& varray = graphics::global_vertex_array(); varray.clear(); for(int n = 1; n < segments; ++n) { //GLfloat lx = x_offset + GLfloat((segment_length_ * n + (n - 1) * tick_width_ + 1) * scale_); GLfloat lx = x_offset + tick_distance_ * n; varray.push_back(lx); varray.push_back(GLfloat(y())); varray.push_back(lx); varray.push_back(GLfloat(y()+height())); } glLineWidth(GLfloat(tick_width_) * scale_); glColor4ub(color.r, color.g, color.b, 255); #if defined(USE_GLES2) gles2::manager gles2_manager(gles2::get_simple_shader()); gles2::active_shader()->shader()->vertex_array(2, GL_FLOAT, 0, 0, &varray.front()); glDrawArrays(GL_LINES, 0, varray.size()/2); #else glDisable(GL_TEXTURE_2D); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(2, GL_FLOAT, 0, &varray.front()); glDrawArrays(GL_LINES, 0, varray.size()/2); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnable(GL_TEXTURE_2D); #endif glLineWidth(1.0f); } }
void view3d_widget::render_texture() const { gles2::manager gles2_manager(gles2::shader_program::get_global("texture2d")); GLint cur_id = graphics::texture::get_current_texture(); glBindTexture(GL_TEXTURE_2D, *texture_); const int w_odd = width() % 2; const int h_odd = height() % 2; const int w = width() / 2; const int h = height() / 2; glm::mat4 mvp = proj_2d_ * glm::translate(glm::mat4(1.0f), glm::vec3(x()+w, y()+h, 0.0f)); glUniformMatrix4fv(gles2::active_shader()->shader()->mvp_matrix_uniform(), 1, GL_FALSE, glm::value_ptr(mvp)); GLfloat varray[] = { GLfloat(-w), GLfloat(-h), GLfloat(-w), GLfloat(h+h_odd), GLfloat(w+w_odd), GLfloat(-h), GLfloat(w+w_odd), GLfloat(h+h_odd) }; const GLfloat tcarray[] = { 0.0f, GLfloat(height())/tex_height_, 0.0f, 0.0f, GLfloat(width())/tex_width_, GLfloat(height())/tex_height_, GLfloat(width())/tex_width_, 0.0f, }; gles2::active_shader()->shader()->vertex_array(2, GL_FLOAT, 0, 0, varray); gles2::active_shader()->shader()->texture_array(2, GL_FLOAT, 0, 0, tcarray); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glBindTexture(GL_TEXTURE_2D, cur_id); }