gloscontext.cpp
来自「ncbi源码」· C++ 代码 · 共 133 行
CPP
133 行
/* * =========================================================================== * PRODUCTION $Log: gloscontext.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 20:53:05 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3 * PRODUCTION * =========================================================================== *//* $Id: gloscontext.cpp,v 1000.1 2004/06/01 20:53: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: * CGlOsContext -- wrapper for Mesa3D's off-screen rendering extension */#include <ncbi_pch.hpp>#include <gui/opengl/mesa/gloscontext.hpp>BEGIN_NCBI_SCOPE//// CGlOsContext ctor// initialize our renderer with a virtual frame buffer of a given size.// This frame buffer will always be initialized as an RGBA image.CGlOsContext::CGlOsContext(size_t width, size_t height) : m_Image(new CImage(width, height, 4)){ // create our off-screen mesa rendering context // this context will use the screen image we've defined#if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305 m_Ctx = OSMesaCreateContextExt( OSMESA_RGBA, 16, 0, 0, NULL );#else m_Ctx = OSMesaCreateContext( OSMESA_RGBA, NULL );#endif if ( !m_Ctx ) { LOG_POST(Error << "CGlOsContext(): " "Failed to create off-screen rendering context"); }}// destructor for cleaning up our OSMesa contextCGlOsContext::~CGlOsContext(){ if (m_Ctx) { OSMesaDestroyContext(m_Ctx); }}// make the current frame buffer the active buffer for renderingbool CGlOsContext::MakeCurrent(void){ if ( !m_Ctx ) { LOG_POST(Error << "CGlOsContext::MakeCurrent(): " "Attempt to make an invalid context current"); return false; } if ( !OSMesaMakeCurrent(m_Ctx, m_Image->SetData(), GL_UNSIGNED_BYTE, m_Image->GetWidth(), m_Image->GetHeight()) ) { LOG_POST(Error << "CGlOsContext::MakeCurrent(): " "Failed to make image surface current"); return false; } return true;}// access the image we use for the virtual frame bufferconst CImage& CGlOsContext::GetBuffer(void) const{ return *m_Image;}// access the image we use for the virtual frame bufferCImage& CGlOsContext::SetBuffer(void){ return *m_Image;}END_NCBI_SCOPE/* * =========================================================================== * $Log: gloscontext.cpp,v $ * Revision 1000.1 2004/06/01 20:53: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 2003/06/12 19:46:21 dicuccio * Added non-const accessor for the image buffer * * Revision 1.1 2003/06/09 19:21:44 dicuccio * Initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?