void draw_difficulty_menu(MenuData *menu) { draw_options_menu_bg(menu); draw_text(AL_Right, 210*(1-menu->fade), 30, "Rank Select", _fonts.mainmenu); int i; for(i = 0; i < menu->ecount; i++) { menu->entries[i].drawdata += 0.2 * (30*(i == menu->cursor) - menu->entries[i].drawdata); glPushMatrix(); glTranslatef(SCREEN_W/3 - menu->entries[i].drawdata, 200 + 70*i,0); glColor4f(1,1-0.1*i,1-0.1*i,0.7); glPushMatrix(); glTranslatef(145,0,0); glScalef(310,60,1); draw_quad(); glPopMatrix(); glColor4f(0,0,0,1); if(i == menu->cursor) glColor3f(0.2,0,0.1); draw_text(AL_Left, 0, -15, menu->entries[i].name, _fonts.standard); glColor3f(1,1,1); glPopMatrix(); } fade_out(menu->fade); }
void draw_texture_p(float x, float y, Texture *tex) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, tex->gltex); glPushMatrix(); float wq = ((float)tex->w)/tex->truew; float hq = ((float)tex->h)/tex->trueh; if(x || y) glTranslatef(x,y,0); if(tex->w != 1 || tex->h != 1) glScalef(tex->w,tex->h,1); glMatrixMode(GL_TEXTURE); glLoadIdentity(); if(wq != 1 || hq != 1) glScalef(wq, hq, 1); glMatrixMode(GL_MODELVIEW); draw_quad(); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glDisable(GL_TEXTURE_2D); }
GLvoid CDKPrimitives::draw_textured_quad(GLfloat x, GLfloat y, GLfloat width, GLfloat height, GLuint texture) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,texture); draw_quad(x,y,width,height); glDisable(GL_TEXTURE_2D); }
void draw_animation_p(float x, float y, int row, Animation *ani) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, ani->tex->gltex); float s = (float)ani->tex->w/ani->cols/ani->tex->truew; float t = ((float)ani->tex->h)/ani->tex->trueh/(float)ani->rows; if(ani->speed == 0) errx(-1, "animation speed of %s == 0. relativity?", ani->name); glPushMatrix(); if(x || y) glTranslatef(x,y,0); if(ani->w != 1 || ani->h != 1) glScalef(ani->w,ani->h, 1); glMatrixMode(GL_TEXTURE); glPushMatrix(); glScalef(s,t,1); int col = global.frames/ani->speed % ani->cols; if(col || row) glTranslatef(col, row, 0); glMatrixMode(GL_MODELVIEW); draw_quad(); glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glDisable(GL_TEXTURE_2D); }
static cairo_test_status_t draw (cairo_t *cr, int width, int height) { int position[5] = {0, HEIGHT/2-10, HEIGHT/2-5, HEIGHT/2, HEIGHT-10 }; int i; cairo_set_source_rgb (cr, 0, 0, 0); cairo_paint (cr); for (i = 0; i < 5; i++) { cairo_reset_clip (cr); cairo_set_source_rgb (cr, 1, 1, 1); cairo_rectangle (cr, 0, 0, WIDTH/2, HEIGHT/2); cairo_rectangle (cr, WIDTH/2, position[i], WIDTH/2, 10); cairo_fill_preserve (cr); cairo_clip (cr); cairo_set_source_rgb (cr, 1, 0, 1); draw_quad (cr, 50, 50, 75, 75, 50, 150, 25, 75); cairo_fill (cr); cairo_translate(cr, WIDTH, 0); } return CAIRO_TEST_SUCCESS; }
void fill_screen_p(float xoff, float yoff, float ratio, Texture *tex) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, tex->gltex); float rw = ratio; float rh = ratio; if(ratio == 0) { rw = ((float)tex->w)/tex->truew; rh = ((float)tex->h)/tex->trueh; } glMatrixMode(GL_TEXTURE); glLoadIdentity(); glTranslatef(xoff,yoff, 0); glScalef(rw, rh, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glTranslatef(VIEWPORT_W*0.5, VIEWPORT_H*0.5, 0); glScalef(VIEWPORT_W, VIEWPORT_H, 1); draw_quad(); glPopMatrix(); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); }
void gl_render_glyph() { unsigned texture_width = 128; unsigned texture_height = texture_width; unsigned texture_size = texture_width * texture_height; char *texture_buffer; FT_Bitmap *bitmap = &face->glyph->bitmap; unsigned glyph_width = bitmap->width; unsigned glyph_height = bitmap->rows; unsigned texture_id; texture_buffer = malloc(texture_size); memset(texture_buffer, 0, texture_size); bitblit( texture_buffer, texture_width, bitmap->buffer, glyph_width, glyph_height, 0, 0 ); glGenTextures(1, &texture_id); abort_on_error("OpenGL", glGetError()); glBindTexture(GL_TEXTURE_2D, texture_id); abort_on_error("OpenGL", glGetError()); glTexImage2D( GL_TEXTURE_2D, 0, GL_RED, texture_width, texture_height, 0, GL_RED, GL_UNSIGNED_BYTE, texture_buffer ); abort_on_error("OpenGL", glGetError()); free(texture_buffer); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); abort_on_error("OpenGL", glGetError()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); abort_on_error("OpenGL", glGetError()); draw_quad(); glDeleteTextures(1, &texture_id); abort_on_error("OpenGL", glGetError()); }
void neb::gfx::gui::object::textview::draw(sp::shared_ptr<neb::glsl::program> p) { //printf("%s\n",__PRETTY_FUNCTION__); float sx = 1.0/600.0; float sy = 1.0/600.0; draw_quad(p, x_, y_, w_, h_, bg_color_); draw_text(p, x_, y_, sx, sy, font_color_, label_); }
// Constructor ScaleManipulator::ScaleManipulator (Scalable& scalable, std::size_t segments, float length) : m_free(scalable), m_axis(scalable) { draw_arrowline(length, m_arrow_x.m_line, 0); draw_arrowline(length, m_arrow_y.m_line, 1); draw_arrowline(length, m_arrow_z.m_line, 2); draw_quad(16, m_quad_screen.m_quad); }
void shader_drawpolygon(int n, const struct vertex_pack *vb, uint32_t color, uint32_t additive) { int i = 0; --n; do { draw_quad(vb, color, additive, n, i); i+=2; } while (i<n-1); }
void Client::render() { SDL_LockMutex(mutex); static const int grasslimit = ceil(4*(256/11.0)); int tiles[18*18]; int i = 0; for (int y = 0; y < 18; ++y) { for (int x = 0; x < 18; ++x) { unsigned char a0 = grass(x, y); unsigned char a1 = grass(x+1, y); unsigned char a2 = grass(x, y+1); unsigned char a3 = grass(x+1, y+1); tiles[i++] = (a0 >= grasslimit ? 1 : 0) + (a1 >= grasslimit ? 2 : 0) + (a2 >= grasslimit ? 4 : 0) + (a3 >= grasslimit ? 8 : 0); } } int overlay[17*17]; i = 0; for (int y = 1; y < 18; ++y) { for (int x = 1; x < 18; ++x) { overlay[i++] = (int)(grass(x,y))*(11.0/256) + 100; // distribute over 11 images starting at index 100 } } draw_quad(-512, -512, 1024, 1024, bgcolor_r, bgcolor_g, bgcolor_b); draw_tiles(-512-64 + dx*t, -512-64 + dy*t, 64, 64, tiles, 18, 18); draw_tiles(-512-32 + dx*t, -512-32 + dy*t, 64, 64, overlay, 17, 17); std::list<Sprite*> sprites; for (typeof(entities.begin()) it = entities.begin(); it != entities.end(); ++it) sprites.push_back(&(it->second)); sprites.sort(Sprite::less); for (typeof(sprites.begin()) it = sprites.begin(); it != sprites.end(); ++it) (*it)->render(); //for (typeof(entities.begin()) it = entities.begin(); it != entities.end(); ++it) // it->second.render(); t -= 0.125; if (t < 0) t = 0; SDL_UnlockMutex(mutex); }
static void draw_projectiles(struct GameState *game_state, struct Renderer *renderer) { bind_program(renderer->quad_program); begin_sprite_batch(&renderer->sprite_batch); for (uint32 i = 0; i < game_state->projectile_count; ++i) { struct Projectile *projectile = &game_state->projectiles[i]; draw_quad(&renderer->sprite_batch, projectile->position, projectile->size, vec3_new(0.0f, 1.0f, 0.0f)); } end_sprite_batch(&renderer->sprite_batch); bind_program(0); }
static void draw_buildings(struct GameState *game_state, struct Renderer *renderer) { bind_program(renderer->quad_program); begin_sprite_batch(&renderer->sprite_batch); for (uint32 i = 0; i < game_state->building_count; ++i) { struct Building *building = &game_state->buildings[i]; draw_quad(&renderer->sprite_batch, building->position, building->size, vec3_new(0.3f, 0.3f, 0.3f)); } end_sprite_batch(&renderer->sprite_batch); bind_program(0); }
static void draw_ships(struct GameState *game_state, struct Renderer *renderer) { bind_program(renderer->quad_program); begin_sprite_batch(&renderer->sprite_batch); for (uint32 i = 0; i < game_state->ship_count; ++i) { struct Ship *ship = &game_state->ships[i]; draw_quad(&renderer->sprite_batch, ship->position, ship->size, vec3_new(0.5f, 0.5f, 0.5f)); } end_sprite_batch(&renderer->sprite_batch); bind_program(0); }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; glViewport(0, 0, piglit_width, piglit_height); glClearColor(0.5, 0.5, 0.5, 0.5); glClear(GL_COLOR_BUFFER_BIT); glViewport(0, 0, piglit_width/2, piglit_height); glUseProgram(prog_tex); draw_quad(); glViewport(piglit_width/2, 0, piglit_width/2, piglit_height); glUseProgram(prog_texgrad); draw_quad(); if (!piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width, piglit_height)) pass = GL_FALSE; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
void Fluids::set_boundaries(int b, GLuint& tmp, GLuint& buf) { do_set_bnd_->setInt("b", b); do_set_bnd_->apply(); setRenderTexture(tmp,0); glDrawBuffer(GL_COLOR_ATTACHMENT0); set_texture_for_sampler(do_set_bnd_, "x", 0, buf); draw_quad(1); //glUseProgram(0); swap(tmp, buf); }
enum piglit_result piglit_display(void) { GLboolean pass = GL_TRUE; const float violet[3] = {0.5, 0, 0.5}; glClear(GL_COLOR_BUFFER_BIT); draw_quad(10, 10, 0.99, 0, 1); draw_quad(40, 10, 1, 0, 0.99); glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); draw_quad(70, 10, 0.99, 0, 1); draw_quad(100, 10, 1, 0, 0.99); glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS); pass = piglit_probe_pixel_rgb(20, 20, colors[4]) && pass; pass = piglit_probe_pixel_rgb(50, 20, colors[0]) && pass; pass = piglit_probe_pixel_rgb(80, 20, violet) && pass; pass = piglit_probe_pixel_rgb(110, 20, violet) && pass; piglit_present_results(); return pass ? PIGLIT_PASS : PIGLIT_FAIL; }
void stage4_fountain_draw(Vector pos) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, get_tex("stage2/border")->gltex); glPushMatrix(); glTranslatef(pos[0], pos[1], pos[2]); glRotatef(-90, 1,0,0); glScalef(1000,3010,1); draw_quad(); glPopMatrix(); glDisable(GL_TEXTURE_2D); }
// give each top-level object a chance to display itself // Only the computer lives in 3D space: the others all live in 2D window coords void render () { #ifdef WANT_GLUT vis->prepare_frame(); vis->view_3D(); // enter the 3D view for the computer computer->visualize(); vis->end_3D(); // local drawing if(show_time) { char text[100]; glPushMatrix(); glPushAttrib(GL_CURRENT_BIT); palette->use_color(TIME_DISPLAY); sprintf(text, "%.2f", sim_time); glTranslatef( -vis->width/2+50, -vis->height/2+50, -0.1); draw_text_justified(TD_BOTTOM, 100, 100, text); glPopAttrib(); glPopMatrix(); glPushMatrix(); glPushAttrib(GL_CURRENT_BIT); palette->use_color(FPS_DISPLAY); sprintf(text, "%.2f", fps); glTranslatef( vis->width/2-50, -vis->height/2+50, -0.1); draw_text_justified(TD_BOTTOM, 100, 100, text); glPopAttrib(); glPopMatrix(); } if(evolution_lagging) { glPushMatrix(); glPushAttrib(GL_CURRENT_BIT); palette->use_color(LAG_WARNING); glTranslatef( 0, -vis->height/2+50, -0.1); draw_text_justified(TD_BOTTOM, 100, 100, "LAG WARNING"); glPopAttrib(); glPopMatrix(); } if(selecting) { glPushMatrix(); palette->use_color(DRAG_SELECTION); glTranslatef((drag_anchor[0]+drag_current[0]-vis->width)/2, -(drag_anchor[1]+drag_current[1]-vis->height)/2, -0.05); draw_quad(fabs(drag_anchor[0]-drag_current[0]), fabs(drag_anchor[1]-drag_current[1])); glPopMatrix(); } // rest of drawing vis->visualize(); if(compiler) compiler->visualize(); if(motelink!=NULL) motelink->visualize(); vis->complete_frame(); #endif // WANT_GLUT }
// Constructor TranslateManipulator::TranslateManipulator(Translatable& translatable, std::size_t segments, float length) : _translateFree(translatable), _translateAxis(translatable), _arrowHeadX(3 * 2 * (segments << 3)), _arrowHeadY(3 * 2 * (segments << 3)), _arrowHeadZ(3 * 2 * (segments << 3)) { draw_arrowline(length, &_arrowX.front(), 0); draw_arrowhead(segments, length, &_arrowHeadX._vertices.front(), TripleRemapXYZ<Vertex3f>(), TripleRemapXYZ<Normal3f>()); draw_arrowline(length, &_arrowY.front(), 1); draw_arrowhead(segments, length, &_arrowHeadY._vertices.front(), TripleRemapYZX<Vertex3f>(), TripleRemapYZX<Normal3f>()); draw_arrowline(length, &_arrowZ.front(), 2); draw_arrowhead(segments, length, &_arrowHeadZ._vertices.front(), TripleRemapZXY<Vertex3f>(), TripleRemapZXY<Normal3f>()); draw_quad(16, &_quadScreen.front()); }
void draw_sponsor_loading() { GLuint texobj; int w = getparam_x_resolution(); int h = getparam_y_resolution(); glEnable( GL_TEXTURE_2D ); /* loading */ if ( get_texture_binding( sponsor_selected, &texobj ) ) { glBindTexture( GL_TEXTURE_2D, texobj ); draw_quad(0,0, w, h ); } }
void draw_quad(GLuint texture, float aspect) { if(texture!=0) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture); } draw_quad(aspect); if(texture!=0) { glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); } }
// Constructor TranslateManipulator::TranslateManipulator (Translatable& translatable, std::size_t segments, float length) : m_free(translatable), m_axis(translatable), m_arrow_head_x(3 * 2 * (segments << 3)), m_arrow_head_y(3 * 2 * (segments << 3)), m_arrow_head_z(3 * 2 * (segments << 3)) { draw_arrowline(length, m_arrow_x.m_line, 0); draw_arrowhead(segments, length, m_arrow_head_x.m_vertices.data(), TripleRemapXYZ<Vertex3f> (), TripleRemapXYZ< Normal3f> ()); draw_arrowline(length, m_arrow_y.m_line, 1); draw_arrowhead(segments, length, m_arrow_head_y.m_vertices.data(), TripleRemapYZX<Vertex3f> (), TripleRemapYZX< Normal3f> ()); draw_arrowline(length, m_arrow_z.m_line, 2); draw_arrowhead(segments, length, m_arrow_head_z.m_vertices.data(), TripleRemapZXY<Vertex3f> (), TripleRemapZXY< Normal3f> ()); draw_quad(16, m_quad_screen.m_quad); }
/*********************************** FUNCTION: draw_house ARGS: none RETURN: none DOES: helper build function; defines a hollow cube with a bottomless pyramid as rooftop ************************************/ void draw_house() { draw_triangle(vertices_house,0,1,2,RED); draw_triangle(vertices_house,0,2,3,GREEN); draw_triangle(vertices_house,0,3,4,WHITE); draw_triangle(vertices_house,0,4,1,GREY); draw_quad(vertices_house,2,1,5,6, BLUE); draw_triangle(vertices_house,2,6,3, CYAN); draw_triangle(vertices_house,3,6,7, CYAN); draw_triangle(vertices_house,3,7,8, YELLOW); draw_triangle(vertices_house,8,3,4, YELLOW); draw_triangle(vertices_house,4,8,1, MAGENTA); draw_triangle(vertices_house,1,8,5, MAGENTA); }
void draw_laser_curve(Laser *laser) { glEnable(GL_TEXTURE_2D); Texture *tex = get_tex("part/lasercurve"); complex last; glBindTexture(GL_TEXTURE_2D, tex->gltex); glColor4fv((float *)laser->color); glBlendFunc(GL_SRC_ALPHA, GL_ONE); float t = (global.frames - laser->birthtime)*laser->speed - laser->timespan + laser->timeshift; if(t < 0) t = 0; last = laser->prule(laser, t); for(t += 0.5; t < (global.frames - laser->birthtime)*laser->speed + laser->timeshift && t <= laser->deathtime + laser->timeshift; t += 1.5) { complex pos = laser->prule(laser,t); glPushMatrix(); float t1 = t - ((global.frames - laser->birthtime)*laser->speed - laser->timespan/2 + laser->timeshift); float tail = laser->timespan/1.9; float s = -0.75/pow(tail,2)*(t1-tail)*(t1+tail); glTranslatef(creal(pos), cimag(pos), 0); glRotatef(180/M_PI*carg(last-pos), 0, 0, 1); float wq = ((float)tex->w)/tex->truew; float hq = ((float)tex->h)/tex->trueh; glScalef(tex->w*wq*0.5*cabs(last-pos),s*laser->width*hq,s); draw_quad(); last = pos; glPopMatrix(); } glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1,1,1,1); glDisable(GL_TEXTURE_2D); }
void draw_rec_texture(tex_unit* t, int vp[4]) { std::string RECTEXV = "rec_tex.vert"; std::string RECTEXF = "rec_tex.frag"; shader_object *rectex_shader = new shader_object; rectex_shader->init_from_file(RECTEXV.c_str(), RECTEXF.c_str()); glDisable(GL_DEPTH_TEST); glActiveTexture(GL_TEXTURE0); t->bind(); float mag[2] = {1.0, 1.0}; float offset[2] = {0., 0.}; if(vp) { mag[0] = 1.0 * t->get_width() / vp[2]; mag[1] = 1.0 * t->get_height() / vp[3]; offset[0] = vp[0]; offset[1] = vp[1]; toOrtho(vp); } else { int v[4]; v[0] = 0; v[1] = 0; v[2] = t->get_width(); v[3] = t->get_height(); offset[0] = v[0]; offset[1] = v[1]; toOrtho(v); } rectex_shader->use(); glUniform2f(rectex_shader->getUniformLocation("vpxy"), offset[0], offset[1]); glUniform2f(rectex_shader->getUniformLocation("p"), mag[0], mag[1]); draw_quad(); glUseProgram(0); t->unbind(); pop_all_matrix(); glEnable(GL_DEPTH_TEST); delete rectex_shader; }
void GLWidget::draw_grid(double x,double y,double dx,double dy,int w,int h,double(*z)(const vec&),vec(*col)(const vec&)){ for (int i=0; i<w - 1; i++){ for (int j=0; j<h - 1; j++){ vec color(col(vec(i,j,0))); glColor3f(color.x, color.y, color.z); int I = i+1; int J = j+1; float pi = x+i*dx; float pj = y+j*dy; float pI = x+I*dx; float pJ = y+J*dy; draw_quad( vec(pi,pj,z(vec(i,j))), vec(pI,pj,z(vec(I,j))), vec(pI,pJ,z(vec(I,J))), vec(pi,pJ,z(vec(i,J)))); }; }; }
/* draw the shapes calculated by translate_shapes() */ void draw() { int c; QUAD *face = current_faces; VTX *v1, *v2, *v3, *v4; clear(buffer); for (c=0; c < NUM_FACES; c++) { /* find the vertices used by the face */ v1 = face->vtxlist + face->v1; v2 = face->vtxlist + face->v2; v3 = face->vtxlist + face->v3; v4 = face->vtxlist + face->v4; draw_quad(buffer, v1, v2, v3, v4, DRAW_TYPE); face++; } blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); }
void osd_xenon_update_video(render_primitive_list &primlist) { primlist.acquire_lock(); pre_render(); int minwidth, minheight; // get the minimum width/height for the current layout xenos_target->compute_minimum_size(minwidth, minheight); // make that the size of our target xenos_target->set_bounds(minwidth, minheight); n = 0; // begin ... render_primitive *prim; for (prim = primlist.first(); prim != NULL; prim = prim->next()) { switch (prim->type) { case render_primitive::LINE: draw_line(prim); break; case render_primitive::QUAD: draw_quad(prim); break; default: throw emu_fatalerror("Unexpected render_primitive type"); } n++; } printf("Number of primitives :%d\r\n", n); render(); primlist.release_lock(); }
void Fluids::advect(float dt, int b, GLuint& d, GLuint d0, GLuint u, GLuint v) { setFrameBuffer(frambuffer_); do_advect_->setFloat("dt", dt); do_advect_->apply(); setRenderTexture(d); glDrawBuffer(GL_COLOR_ATTACHMENT0); checkFramebufferStatus(); //assert(do_advect_->samplers_.count("density") && do_advect_->samplers_.count("velocity")); glEnable(GL_TEXTURE_2D); set_texture_for_sampler(do_advect_, "d0", 0, d0); set_texture_for_sampler(do_advect_, "u", 1, u); set_texture_for_sampler(do_advect_, "v", 2, v); draw_quad(1); set_boundaries(b, p_prev_, d); glActiveTexture(GL_TEXTURE0 + 2); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0 + 1); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); glUseProgram(0); setRenderTexture(0,0); }