void widget_sprite_draw() { struct node *this = _current_node; struct widget_sprite *wgspr = (struct widget_sprite *)_current_widget; if(wgspr->tex == NULL)return; if(wgspr->sheet == NULL)return; struct rect *rect = spritesheet_get_rect(wgspr->sheet); if(rect != NULL) { int sw = (int)rect->w; int sh = (int)rect->h; if (sw + (int)rect->x > wgspr->tex->w) sw -= (int)rect->x - wgspr->tex->w; if (sh + (int)rect->y > wgspr->tex->w) sh -= (int)rect->y - wgspr->tex->h; node_draw((uint32_t *)wgspr->tex->data + (wgspr->tex->w * (int)rect->y + (int)rect->x) , wgspr->tex->w , sw , sh , 0, 0 , this->bounds.w , this->bounds.h); } }
static void draw_galaxy(int i, int j, int f, float a) { struct galaxy *g = get_galaxy(i); float V[6][4]; float p[4] = { 0.0, 0.0, 0.0, 1.0 }; init_galaxy(i); glPushMatrix(); { /* Apply the local coordinate system transformation. */ transform_entity(j); get_viewfrust(V); get_viewpoint(p); /* Supply the view position as a vertex program parameter. */ if (GL_has_vertex_program) glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB, 0, p[0], p[1], p[2], p[3]); glPushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); { /* Set up the GL state for star rendering. */ draw_brush(g->brush, a * get_entity_alpha(j)); glBindTexture(GL_TEXTURE_2D, g->texture); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); glDepthMask(GL_FALSE); glBlendFunc(GL_ONE, GL_ONE); if (GL_has_vertex_program) glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB); if (GL_has_point_sprite) { glEnable(GL_POINT_SPRITE_ARB); glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); } draw_arrays(i); /* Render all stars. */ node_draw(g->N, 0, 0, V); } glPopClientAttrib(); glPopAttrib(); /* Render all child entities in this coordinate system. */ draw_entity_tree(j, f, a * get_entity_alpha(j)); } glPopMatrix(); }