Changeset View
Changeset View
Standalone View
Standalone View
source/lib/res/graphics/ogl_tex.cpp
Show First 20 Lines • Show All 838 Lines • ▼ Show 20 Lines | static void upload_level(size_t level, size_t level_w, size_t level_h, const u8* RESTRICT level_data, size_t level_data_size, void* RESTRICT cbData) | ||||
const UploadParams* up = (const UploadParams*)cbData; | const UploadParams* up = (const UploadParams*)cbData; | ||||
glTexImage2D(GL_TEXTURE_2D, (GLint)level, up->int_fmt, (GLsizei)level_w, (GLsizei)level_h, 0, up->fmt, GL_UNSIGNED_BYTE, level_data); | glTexImage2D(GL_TEXTURE_2D, (GLint)level, up->int_fmt, (GLsizei)level_w, (GLsizei)level_h, 0, up->fmt, GL_UNSIGNED_BYTE, level_data); | ||||
*up->uploaded_size += (u32)level_data_size; | *up->uploaded_size += (u32)level_data_size; | ||||
} | } | ||||
static void upload_compressed_level(size_t level, size_t level_w, size_t level_h, const u8* RESTRICT level_data, size_t level_data_size, void* RESTRICT cbData) | static void upload_compressed_level(size_t level, size_t level_w, size_t level_h, const u8* RESTRICT level_data, size_t level_data_size, void* RESTRICT cbData) | ||||
{ | { | ||||
const UploadParams* up = (const UploadParams*)cbData; | const UploadParams* up = (const UploadParams*)cbData; | ||||
pglCompressedTexImage2DARB(GL_TEXTURE_2D, (GLint)level, up->fmt, (GLsizei)level_w, (GLsizei)level_h, 0, (GLsizei)level_data_size, level_data); | glCompressedTexImage2DARB(GL_TEXTURE_2D, (GLint)level, up->fmt, (GLsizei)level_w, (GLsizei)level_h, 0, (GLsizei)level_data_size, level_data); | ||||
*up->uploaded_size += (u32)level_data_size; | *up->uploaded_size += (u32)level_data_size; | ||||
} | } | ||||
// upload the texture in the specified (internal) format. | // upload the texture in the specified (internal) format. | ||||
// split out of ogl_tex_upload because it was too big. | // split out of ogl_tex_upload because it was too big. | ||||
// | // | ||||
// pre: <t> is valid for OpenGL use; texture is bound. | // pre: <t> is valid for OpenGL use; texture is bound. | ||||
static void upload_impl(Tex* t, GLenum fmt, GLint int_fmt, int levels_to_skip, u32* uploaded_size) | static void upload_impl(Tex* t, GLenum fmt, GLint int_fmt, int levels_to_skip, u32* uploaded_size) | ||||
▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | |||||
// notes: | // notes: | ||||
// - assumes multitexturing is available. | // - assumes multitexturing is available. | ||||
// - not necessary before calling ogl_tex_upload! | // - not necessary before calling ogl_tex_upload! | ||||
// - on error, the unit's texture state is unchanged; see implementation. | // - on error, the unit's texture state is unchanged; see implementation. | ||||
Status ogl_tex_bind(Handle ht, size_t unit) | Status ogl_tex_bind(Handle ht, size_t unit) | ||||
{ | { | ||||
// note: there are many call sites of glActiveTextureARB, so caching | // note: there are many call sites of glActiveTextureARB, so caching | ||||
// those and ignoring redundant sets isn't feasible. | // those and ignoring redundant sets isn't feasible. | ||||
pglActiveTextureARB((int)(GL_TEXTURE0+unit)); | glActiveTextureARB((int)(GL_TEXTURE0+unit)); | ||||
// special case: resets the active texture. | // special case: resets the active texture. | ||||
if(ht == 0) | if(ht == 0) | ||||
{ | { | ||||
glBindTexture(GL_TEXTURE_2D, 0); | glBindTexture(GL_TEXTURE_2D, 0); | ||||
return INFO::OK; | return INFO::OK; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator