40 m_frames(rhs.m_frames),
57 m_frames.push_back(std::make_pair(name,
id));
61 if(starting_point < 0)
64 for(
int i = starting_point,
end =
int(m_frames.size());
i <
end; ++
i)
65 if(m_frames[
size_t(
i)].first ==
name)
75 std::pair<String, unsigned long> new_frame = std::make_pair(name,
id);
77 if(at_this_index < 0 || at_this_index >
int(m_frames.size()))
80 m_frames.push_back(new_frame);
83 &m_frames + at_this_index + 1,
84 &m_frames + at_this_index,
85 (m_frames.size() - at_this_index - 1) *
sizeof(std::pair<String, unsigned long>));
87 m_frames[
size_t(at_this_index)] = new_frame;
91 if(frame_number < 0 || frame_number >
int(m_frames.size()))
95 &m_frames + frame_number,
96 &m_frames + frame_number + 1,
97 (m_frames.size() - frame_number - 1) *
sizeof(std::pair<String, unsigned long>));
103 return int(m_frames.size());
113 if(frame_number < 0 || frame_number >
int(m_frames.size()))
116 m_frame = frame_number;
120 static bool no_recurse =
true;
127 if(m_frames.empty() || m_frame < 0 || m_frame >=
int(m_frames.size()))
151 Texture_GL::Texture_GL(
const String &
filename,
const bool &repeat,
const bool &lazy_loading)
155 m_frame_buffer_object(0),
165 m_texture_id(build_from_Image(image)),
167 m_frame_buffer_object(0)
169 , m_filename(1,
'\0')
177 m_texture_id(build_from_Image(
Image(size,
Image::RGBA, repeat))),
179 m_frame_buffer_object(0)
181 , m_filename(1,
'\0')
193 if(m_frame_buffer_object)
225 for(
int bit = 1; bit; bit <<= 1)
226 bit_count += ((image.
width() & bit) != 0) + ((image.
height() & bit) != 0);
228 ZENI_LOGE(
"Dimensions of textures must be powers of 2.");
235 throw Texture_Init_Failure();
244 static bool printed =
false;
246 ZENI_LOGW(
"Quality Warning: Your graphics card does not support GL_CLAMP_TO_EDGE in OpenGL.");
258 #ifndef REQUIRE_GL_ES
276 #ifndef REQUIRE_GL_ES
283 #ifndef REQUIRE_GL_ES
289 #ifndef REQUIRE_GL_ES
298 void Texture_GL::load(
const String &
filename,
const bool &repeat)
const {
299 Image
image(filename, repeat);
304 m_texture_id = build_from_Image(image);
311 Texture_DX9::Texture_DX9(
const String &filename,
const bool &repeat)
314 m_render_to_surface(0)
319 Texture_DX9::Texture_DX9(
const Image &image)
321 m_size(image.
size()),
322 m_texture(build_from_Image(image)),
323 m_render_to_surface(0)
331 m_render_to_surface(0)
335 set_sampler_states(
true);
353 &m_render_to_surface)))
356 m_texture->Release();
363 if(m_render_to_surface)
364 m_render_to_surface->Release();
367 m_texture->Release();
391 void Texture_DX9::set_sampler_states(
const bool &disable_mipmapping) {
420 switch(image.color_space()) {
442 set_sampler_states();
445 UINT(image.width()),
UINT(image.height()),
451 throw Texture_Init_Failure();
454 if(FAILED(ppTexture->LockRect(0, &rect, 0, 0))) {
455 ppTexture->Release();
456 throw Texture_Init_Failure();
460 memcpy(rect.
pBits, image.get_data(), image.width() * image.height());
464 const Uint8 *
src = image.get_data();
465 for(
Uint8 *
const dest_end = dest + image.width() * image.height() * 4; dest != dest_end; dest += 4, src += 2) {
474 const Uint8 * src = image.get_data();
475 for(
Uint8 *
const dest_end = dest + image.width() * image.height() * 4; dest != dest_end; dest += 4, src += 3) {
484 const Uint8 * src = image.get_data();
485 for(
Uint8 *
const dest_end = dest + image.width() * image.height() * 4; dest != dest_end; dest += 4, src += 4) {
493 if(FAILED(ppTexture->UnlockRect(0))) {
494 ppTexture->Release();
495 throw Texture_Init_Failure();
499 ppTexture->Release();
500 throw Texture_Init_Failure();
506 void Texture_DX9::load(
const String &filename)
const {
514 Image
image(filename);
516 m_texture = build_from_Image(image);
517 m_size = image.size();
#define GL_LINEAR_MIPMAP_LINEAR
#define GL_LUMINANCE_ALPHA
The Direct3D9 Rendering System.
GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data)
#define GL_TEXTURE_ENV_MODE
LPDIRECT3DDEVICE9 & get_d3d_device()
See DirectX Documentation for details.
void insert_frame(const String &name, const int &at_this_index)
Insert a frame.
#define D3DUSAGE_AUTOGENMIPMAP
static bool get_lighting()
Determine whether dynamic lighting is enabled.
static int get_anisotropic_filtering()
Check the current level of anisotropy.
const Uint8 * get_data() const
Get access to the raw image data.
unsigned long get_id(const String &name) const
Get an id by name, possibly throwing an Error.
EGLSurface EGLint EGLint EGLint EGLint height
EGLImageKHR EGLint * name
#define GL_TEXTURE_MAG_FILTER
bool tileable() const
Determine if the given Image is tileable.
typedef UINT(WINAPI *PFNWGLGETCONTEXTGPUIDAMDPROC)(HGLRC hglrc)
#define glDeleteFramebuffersEXT
Sprite & operator=(const Sprite &rhs)
void ZENI_LOGW(const Zeni::String &str)
#define GL_PERSPECTIVE_CORRECTION_HINT
enum _D3DFORMAT D3DFORMAT
An Abstraction of a Texture.
void set_current_frame(const int &frame_number)
Set this frame.
#define D3DUSAGE_RENDERTARGET
#define GL_TEXTURE_MIN_FILTER
virtual void apply_Texture() const
Apply the current Texture frame to upcoming polygons.
int find_frame(const String &name, const int &starting_point=0) const
Search for a frame.
EGLSurface EGLint EGLint EGLint width
int get_maximum_anisotropy() const
Get the current level of anisotrophy.
void append_frame(const String &name)
Add a frame to the Sprite.
static D3DXCreateRenderToSurface_fcn D3DXCreateRenderToSurface()
#define GL_TEXTURE_MAX_ANISOTROPY_EXT
#define glDeleteRenderbuffersEXT
Color_Space color_space() const
Determine the Color_Space of the raw image data.
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
#define GL_GENERATE_MIPMAP
void remove_frame(const int &frame_number)
Remove a frame.
static D3DXCreateTexture_fcn D3DXCreateTexture()
static D3DXFilterTexture_fcn D3DXFilterTexture()
void ZENI_LOGE(const Zeni::String &str)
Textures & get_Textures()
Get access to the singleton.
void apply_Texture(const String &name)
Apply a texture for upcoming polygons (Called by Video::apply_Texture)
int width() const
Get the number of pixels in the image in the x-direction.
int get_current_frame() const
Get the currently selected frame number.
virtual void apply_Texture() const
Apply a Texture to upcoming polygons.
void swap(Zeni::String &lhs, Zeni::String &rhs)
#define GL_TEXTURE_WRAP_T
uint8_t Uint8
An unsigned 8-bit integer type.
typedef DWORD(WINAPI *XInputGetState_t)(DWORD dwUserIndex
#define GL_TEXTURE_WRAP_S
int get_num_frames() const
Get the number of frames.
int height() const
Get the number of pixels in the image in the y-direction.
interface IDirect3DTexture9 IDirect3DTexture9
static void set_texturing_mode(const int &anisotropic_filtering_, const bool &bilinear_filtering_, const bool &mipmapping_)
Check to see if Textures is set to use lazy loading if possible.
Video & get_Video()
Get access to the singleton.
static bool get_mipmapping()
Check if mipmapping is in use.
static bool get_bilinear_filtering()
Check if bilinear filtering is in use.
GL_APICALL void GL_APIENTRY glDeleteBuffers(GLsizei n, const GLuint *buffers)
virtual void apply_Texture() const
Apply a Texture to upcoming polygons.
#define GL_NEAREST_MIPMAP_NEAREST
A 2D Point represented with integers.