47 #ifdef KJB_HAVE_OPENGL
48 class Sprite :
public Renderable
50 enum Origin_type {TOP_LEFT, CENTER};
52 Sprite (
float z_pos = 1);
53 Sprite (
const Image& img,
float z_pos = 1);
54 Sprite (
const Matrix& gray_img,
float z_pos = 1);
55 Sprite (
const Texture& img,
float z_pos = 1);
57 Sprite (
const Sprite& other );
60 void swap(Sprite& src)
65 std::swap(m_base_width, src.m_base_width);
66 std::swap(m_base_height, src.m_base_height);
69 std::swap(m_depth_test, src.m_depth_test);
70 std::swap(m_min_filter, src.m_min_filter);
71 std::swap(m_mag_filter, src.m_mag_filter);
75 void enable_depth_test(
bool enable);
78 void set_position(
int u,
int v) {
83 void set_u(
int u) { m_u = u; }
84 void set_v(
int v) { m_v = v; }
89 void set_crop_relative(
float left,
float right,
float bottom,
float top)
94 m_crop_bottom = bottom;
100 void set_crop_absolute(
float left,
float right,
float bottom,
float top)
102 m_crop_left = left / m_base_width;
103 m_crop_right = right / m_base_width;
104 m_crop_bottom = bottom / m_base_height;
105 m_crop_top = top / m_base_height;
109 void set_scale(
float u_scale,
float v_scale)
111 m_width = (int) (m_base_width * u_scale);
112 m_height = (int)(m_base_height * v_scale);
116 void set_size(
int width,
int height)
123 void set_rect(
int u,
int v,
int width,
int height) {
125 set_size(width, height);
129 int get_base_width()
const {
return m_base_width; }
130 int get_base_height()
const {
return m_base_height; }
133 int get_width()
const {
return m_width; }
134 int get_height()
const {
return m_height; }
137 int get_u_scale()
const {
return m_width / (float) m_base_width; }
138 int get_v_scale()
const {
return m_height / (float) m_base_height; }
140 int get_u()
const {
return m_u;}
141 int get_v()
const {
return m_v;}
142 Vector get_position()
const {
144 pos[0] = m_u; pos[1] = m_v; pos[2] = 0;
164 virtual void render()
const;
165 virtual void render_quad()
const;
167 Sprite& operator=(
const Sprite &src);
169 void set(
const Image& img);
170 void set(
const Texture& tex);
171 void set(
const Matrix& img);
173 const Texture& get_texture()
const
179 void m_init_texture();
182 static std::map<int, int> m_ref_count;
189 int m_width, m_height;
197 Origin_type m_origin;
206 typedef boost::shared_ptr<Sprite> Sprite_ptr;
246 #ifdef KJB_HAVE_OPENGL
250 typedef opengl::Sprite Gl_sprite;
void swap(Perspective_camera &cam1, Perspective_camera &cam2)
Swap two cameras.
Definition: perspective_camera.h:599
height
Definition: APPgetLargeConnectedEdges.m:33
Abstract class to render this object with GL.
void render(const Cuboid &c)
Definition: psi_weighted_box.cpp:56
void swap(kjb::Gsl_Multimin_fdf &m1, kjb::Gsl_Multimin_fdf &m2)
Swap two wrapped multimin objects.
Definition: gsl_multimin.h:693
Code for a wrapper class around the C struct KJB_Image.