13 * This is a simple class built on top of OpenGL that manages drawing images in a higher-level and quicker way.
16 DrawableThing::DrawableThing(Image* image_arg)
31 if(image_arg!=NULL) setImage(image_arg);
35 void DrawableThing::setFlip(bool x, bool y)
41 void DrawableThing::setHotspot(int x, int y)
47 void DrawableThing::move(int x, int y)
53 void DrawableThing::scale(float x, float y)
55 DrawableThing::xscale=x;
56 DrawableThing::yscale=y;
59 void DrawableThing::scale(float k)
61 DrawableThing::xscale=k;
62 DrawableThing::yscale=k;
65 void DrawableThing::setImage(Image* image)
67 DrawableThing::image=image;
70 void DrawableThing::rotate(int angle)
72 DrawableThing::angle=angle;
75 void DrawableThing::render()
83 if(xscale!=1 || yscale!=1)
85 glScalef(xscale, yscale, 1);
90 glRotatef(angle, 0,0,1);
93 glBindTexture(GL_TEXTURE_2D, image->getID()[0] );
97 printf("%f %f %d %d\n", image->tex_coord_x, image->tex_coord_y, hotspotX, hotspotY);
99 glTexCoord2f(xflip? image->tex_coord_x : 0, yflip? 0 : image->tex_coord_y);
100 glVertex2f( -hotspotX, -hotspotY );
102 glTexCoord2f(xflip? 0 : image->tex_coord_x, yflip? 0 : image->tex_coord_y);
103 glVertex2f( image->width-hotspotX, -hotspotY );
105 glTexCoord2f(xflip? 0 : image->tex_coord_x, yflip? image->tex_coord_y : 0);
106 glVertex2f( image->width-hotspotX, image->height-hotspotY );
108 glTexCoord2f(xflip? image->tex_coord_x : 0, yflip? image->tex_coord_y : 0);
109 glVertex2f( -hotspotX, image->height-hotspotY );