Changeset View
Changeset View
Standalone View
Standalone View
source/lib/res/graphics/ogl_tex.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | static bool filter_valid(GLint filter) | ||||
{ | { | ||||
case GL_NEAREST: | case GL_NEAREST: | ||||
case GL_LINEAR: | case GL_LINEAR: | ||||
case GL_NEAREST_MIPMAP_NEAREST: | case GL_NEAREST_MIPMAP_NEAREST: | ||||
case GL_LINEAR_MIPMAP_NEAREST: | case GL_LINEAR_MIPMAP_NEAREST: | ||||
case GL_NEAREST_MIPMAP_LINEAR: | case GL_NEAREST_MIPMAP_LINEAR: | ||||
case GL_LINEAR_MIPMAP_LINEAR: | case GL_LINEAR_MIPMAP_LINEAR: | ||||
return true; | return true; | ||||
case GL_EXT_texture_filter_anisotropic: | |||||
return ogl_tex_has_anisotropy(); | |||||
default: | default: | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
static bool wrap_valid(GLint wrap) | static bool wrap_valid(GLint wrap) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 357 Lines • ▼ Show 20 Lines | struct OglTex | ||||
u32 uploaded_size; | u32 uploaded_size; | ||||
}; | }; | ||||
H_TYPE_DEFINE(OglTex); | H_TYPE_DEFINE(OglTex); | ||||
static void OglTex_init(OglTex* ot, va_list args) | static void OglTex_init(OglTex* ot, va_list args) | ||||
{ | { | ||||
ONCE(detect_gl_upload_caps()); | |||||
Tex* wrapped_tex = va_arg(args, Tex*); | Tex* wrapped_tex = va_arg(args, Tex*); | ||||
if(wrapped_tex) | if(wrapped_tex) | ||||
{ | { | ||||
ot->t = *wrapped_tex; | ot->t = *wrapped_tex; | ||||
// indicate ot->t is now valid, thus skipping loading from file. | // indicate ot->t is now valid, thus skipping loading from file. | ||||
// note: ogl_tex_wrap prevents actual reloads from happening. | // note: ogl_tex_wrap prevents actual reloads from happening. | ||||
ot->flags |= OT_TEX_VALID; | ot->flags |= OT_TEX_VALID; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 469 Lines • ▼ Show 20 Lines | |||||
// q_flags_ovr : global default "quality vs. performance" flags; | // q_flags_ovr : global default "quality vs. performance" flags; | ||||
// int_fmt_ovr : internal format (e.g. GL_RGB8) decided from fmt / q_flags. | // int_fmt_ovr : internal format (e.g. GL_RGB8) decided from fmt / q_flags. | ||||
// | // | ||||
// side effects: | // side effects: | ||||
// - enables texturing on TMU 0 and binds the texture to it; | // - enables texturing on TMU 0 and binds the texture to it; | ||||
// - frees the texel data! see ogl_tex_get_data. | // - frees the texel data! see ogl_tex_get_data. | ||||
Status ogl_tex_upload(const Handle ht, GLenum fmt_ovr, int q_flags_ovr, GLint int_fmt_ovr) | Status ogl_tex_upload(const Handle ht, GLenum fmt_ovr, int q_flags_ovr, GLint int_fmt_ovr) | ||||
{ | { | ||||
ONCE(detect_gl_upload_caps()); | |||||
H_DEREF(ht, OglTex, ot); | H_DEREF(ht, OglTex, ot); | ||||
Tex* t = &ot->t; | Tex* t = &ot->t; | ||||
ENSURE(q_flags_valid(q_flags_ovr)); | ENSURE(q_flags_valid(q_flags_ovr)); | ||||
// we don't bother verifying *fmt_ovr - there are too many values | // we don't bother verifying *fmt_ovr - there are too many values | ||||
// upload already happened; no work to do. | // upload already happened; no work to do. | ||||
// (this also happens if a cached texture is "loaded") | // (this also happens if a cached texture is "loaded") | ||||
if(ot->flags & OT_IS_UPLOADED) | if(ot->flags & OT_IS_UPLOADED) | ||||
▲ Show 20 Lines • Show All 215 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator