gltexmanager.cpp

来自「ncbi源码」· C++ 代码 · 共 145 行

CPP
145
字号
/* * =========================================================================== * PRODUCTION $Log: gltexmanager.cpp,v $ * PRODUCTION Revision 1000.2  2004/06/01 20:51:05  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3 * PRODUCTION * =========================================================================== *//*  $Id: gltexmanager.cpp,v 1000.2 2004/06/01 20:51:05 gouriano Exp $ * =========================================================================== * *                            PUBLIC DOMAIN NOTICE *               National Center for Biotechnology Information * *  This software/database is a "United States Government Work" under the *  terms of the United States Copyright Act.  It was written as part of *  the author's official duties as a United States Government employee and *  thus cannot be copyrighted.  This software/database is freely available *  to the public for use. The National Library of Medicine and the U.S. *  Government have not placed any restriction on its use or reproduction. * *  Although all reasonable efforts have been taken to ensure the accuracy *  and reliability of the software and data, the NLM and the U.S. *  Government do not and cannot warrant the performance or results that *  may be obtained by using this software or data. The NLM and the U.S. *  Government disclaim all warranties, express or implied, including *  warranties of performance, merchantability or fitness for any particular *  purpose. * *  Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors:  Mike DiCuccio * * File Description: * */#include <ncbi_pch.hpp>#include <gui/opengl/glteximage.hpp>#include <gui/opengl/gltexmanager.hpp>#include <util/image/image_io.hpp>BEGIN_NCBI_SCOPE// our list of imagesCTexManager::TImages CTexManager::sm_TexImages;// mutex guarding access to our imagesDEFINE_STATIC_FAST_MUTEX(sm_Mutex);//// GetTexture()// request an image by filename.  if this image is already loaded, return the// previously loaded image.//CTexImage* CTexManager::GetTexture(const string& filename){    CFastMutexGuard LOCK(sm_Mutex);    // first, scan through our list of images to see if the    // requested image was already loaded    TImages::iterator iter = sm_TexImages.begin();    for ( ; iter != sm_TexImages.end(); ++iter) {        if ((*iter)->GetFileName() == filename) {            return (*iter);        }    }    //    // okay, image not found.  read from disk.    //    CRef<CTexImage> tex_image(new CTexImage(filename));    sm_TexImages.push_back(tex_image);    return tex_image;}//// Release()// dispose of an image, once done//void CTexManager::Release(CTexImage *image){    CFastMutexGuard LOCK(sm_Mutex);    if (!image) {        return;    }    // scan through the list of loaded images, looking for the    // image in question    CRef<CTexImage> handle(image);    LOG_POST(Info             << "CTexManager::Release(): releasing texture "             << image << " (" << image->GetFileName());    TImages::iterator iter = sm_TexImages.begin();    while (iter != sm_TexImages.end()) {        while (iter != sm_TexImages.end()  &&  *iter == image) {            iter = sm_TexImages.erase(iter);        }        ++iter;    }}//// ReleaseAll()// unload all images.  This is meant as a final clean-up operation//void CTexManager::ReleaseAll(void){    CFastMutexGuard LOCK(sm_Mutex);    sm_TexImages.clear();}END_NCBI_SCOPE/* * =========================================================================== * $Log: gltexmanager.cpp,v $ * Revision 1000.2  2004/06/01 20:51:05  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3 * * Revision 1.3  2004/05/21 22:27:45  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.2  2004/03/24 13:49:04  friedman * Added  DEFINE_STATIC_FAST_MUTEX to replace 'static CFastMutex' member * * Revision 1.1  2003/06/03 17:42:06  dicuccio * Added texture support.  Added classes to handle OpenGL camera setup and * viewport specification. * * =========================================================================== */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?