Changeset View
Changeset View
Standalone View
Standalone View
source/lib/res/graphics/ogl_tex.cpp
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* "Software"), to deal in the Software without restriction, including | * "Software"), to deal in the Software without restriction, including | ||||
* without limitation the rights to use, copy, modify, merge, publish, | * without limitation the rights to use, copy, modify, merge, publish, | ||||
* distribute, sublicense, and/or sell copies of the Software, and to | * distribute, sublicense, and/or sell copies of the Software, and to | ||||
* permit persons to whom the Software is furnished to do so, subject to | * permit persons to whom the Software is furnished to do so, subject to | ||||
* the following conditions: | * the following conditions: | ||||
Show All 13 Lines | |||||
/* | /* | ||||
* wrapper for all OpenGL texturing calls. provides caching, hotloading | * wrapper for all OpenGL texturing calls. provides caching, hotloading | ||||
* and lifetime management. | * and lifetime management. | ||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "ogl_tex.h" | #include "ogl_tex.h" | ||||
#include <cstdio> | |||||
#include "lib/app_hooks.h" | #include "lib/app_hooks.h" | ||||
#include "lib/ogl.h" | #include "lib/ogl.h" | ||||
#include "lib/bits.h" | #include "lib/bits.h" | ||||
#include "lib/sysdep/gfx.h" | #include "lib/sysdep/gfx.h" | ||||
#include "lib/tex/tex.h" | #include "lib/tex/tex.h" | ||||
#include "lib/res/h_mgr.h" | #include "lib/res/h_mgr.h" | ||||
#include "lib/fnv_hash.h" | #include "lib/fnv_hash.h" | ||||
#include <cstdio> | |||||
vladislavbelov: Is it needed? | |||||
#include <string> | |||||
//---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||||
// OpenGL helper routines | // OpenGL helper routines | ||||
//---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||||
static bool filter_valid(GLint filter) | static bool filter_valid(GLint filter) | ||||
{ | { | ||||
switch(filter) | switch(filter) | ||||
▲ Show 20 Lines • Show All 425 Lines • ▼ Show 20 Lines | static Status OglTex_reload(OglTex* ot, const PIVFS& vfs, const VfsPath& pathname, Handle h) | ||||
glGenTextures(1, &ot->id); | glGenTextures(1, &ot->id); | ||||
// if it had already been uploaded before this reload, | // if it had already been uploaded before this reload, | ||||
// re-upload it (this also does state_latch). | // re-upload it (this also does state_latch). | ||||
if(ot->flags & OT_NEED_AUTO_UPLOAD) | if(ot->flags & OT_NEED_AUTO_UPLOAD) | ||||
(void)ogl_tex_upload(h); | (void)ogl_tex_upload(h); | ||||
#ifndef NDEBUG | |||||
std::string name = pathname.string8(); | |||||
vladislavbelovUnsubmitted Not Done Inline Actionsconst. vladislavbelov: `const`. | |||||
glBindTexture(GL_TEXTURE_2D, ot->id); | |||||
pglObjectLabelKHR(GL_TEXTURE, ot->id, name.size(), name.c_str()); | |||||
#endif | |||||
return INFO::OK; | return INFO::OK; | ||||
} | } | ||||
static Status OglTex_validate(const OglTex* ot) | static Status OglTex_validate(const OglTex* ot) | ||||
{ | { | ||||
if(ot->flags & OT_TEX_VALID) | if(ot->flags & OT_TEX_VALID) | ||||
{ | { | ||||
RETURN_STATUS_IF_ERR(ot->t.validate()); | RETURN_STATUS_IF_ERR(ot->t.validate()); | ||||
▲ Show 20 Lines • Show All 650 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Is it needed?