opengl_print_buffer.cpp

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

CPP
251
字号
/* * =========================================================================== * PRODUCTION $Log: opengl_print_buffer.cpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 20:51:54  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7 * PRODUCTION * =========================================================================== *//*  $Id: opengl_print_buffer.cpp,v 1000.1 2004/06/01 20:51:54 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:  Peter Meric * * File Description: *   COpenGLPrintBuffer - GL feedback buffer * */#include <ncbi_pch.hpp>#include <gui/opengl/opengl_print_buffer.hpp>#include <gui/opengl/glfont.hpp>#include <gui/print/vector_object.hpp>BEGIN_NCBI_SCOPECOpenGLPrintBuffer::COpenGLPrintBuffer(){}COpenGLPrintBuffer::~COpenGLPrintBuffer(){}/*   void COpenGLPrintBuffer::x_Print3DcolorVertex(CNcbiOstream& ostream, GLint& count)   {   ostream << "  ";   for (int i = 0;  i < 7;  i++) {//printf("%4.2f ", buffer[m_DataLength - count--]);ostream << buffer[m_DataLength - count--];}ostream << endl;}void COpenGLPrintBuffer::x_Print(CNcbiOstream& ostream){GLint count = m_DataLength;int token, nvertices;while (count) {token = buffer[m_DataLength - count--];switch (token) {case GL_PASS_THROUGH_TOKEN:ostream << "GL_PASS_THROUGH_TOKEN\n";ostream << "  %4.2f\n", buffer[m_DataLength - count--];break;case GL_POINT_TOKEN:ostream << "GL_POINT_TOKEN\n";print3DcolorVertex(ostream, count);break;case GL_LINE_TOKEN:ostream << "GL_LINE_TOKEN\n";print3DcolorVertex(ostream, count);print3DcolorVertex(ostream, count);break;case GL_LINE_RESET_TOKEN:ostream << "GL_LINE_RESET_TOKEN\n";print3DcolorVertex(ostream, count);print3DcolorVertex(ostream, count);break;case GL_POLYGON_TOKEN:printf("GL_POLYGON_TOKEN\n");for (nvertices = buffer[m_DataLength - count--];  nvertices > 0;  nvertices--) {print3DcolorVertex(ostream, count);}break;}}}*/void COpenGLPrintBuffer::Parse(const GLfloat* buffer, GLint data_length){    // 7 ints per vertex(x, y, z, R, G, B, A)    static const unsigned int VERTEX_SIZE = 7;    const GLfloat* endptr = buffer + data_length;    for (const GLfloat* bufptr = buffer;  bufptr < endptr;  ++bufptr) {        const int token = GLint(*bufptr);        int N = 0;        const GLfloat* ptr = bufptr + 1;        switch (token) {        case GL_PASS_THROUGH_TOKEN:            {                ptr = bufptr;                if (ptr[1] != CGlFeedbackFont::eBeginText) {                    // skip the data for this pass - through token                    ++bufptr;                    break;                }                //                // every second float will be GL_PASS_THROUGH_TOKEN                //                const size_t size = size_t(ptr[3]);                vector<float> textbuf;                textbuf.reserve(size);                const size_t num_floats = size << 1;                for (unsigned int i = 0;  i < num_floats;  ++i) {                    if (ptr[i] != GL_PASS_THROUGH_TOKEN) {                        LOG_POST(Error << "COpenGLPrintBuffer::Parse: expecting GL_PASS_THROUGH_TOKEN");                    }                    textbuf.push_back(ptr[++i]);                }                GLfloat pos[4], col[4];                string text;                CGlFeedbackFont::DecodeText(textbuf, pos, col, text);                CGlColor c(col, 4);                m_VectObjs.push_back(CRef<CObject > (new CPVecText(text, pos, c)));                bufptr += num_floats - 1;                break;            }        case GL_POINT_TOKEN:            {                N = 1;                m_VectObjs.push_back(CRef<CObject > (new CPVecPoint(ptr)));                break;            }        case GL_LINE_TOKEN:        case GL_LINE_RESET_TOKEN:            {                N = 2;                m_VectObjs.push_back(CRef<CObject > (new CPVecLine(ptr)));                break;            }        case GL_POLYGON_TOKEN:            {                // increment the buffer pointers to account for the                // single - float size parameter                N = int(*++bufptr);                m_VectObjs.push_back(CRef<CObject > (new CPVecPolygon(N, ++ptr)));                break;            }        default:            //LOG_POST(Error << "COpenGLPrintBuffer::Parse: unexpected token: " << token << ", offset: " << (bufptr - buffer) << ", endptr: " << (endptr - buffer));            break;        }        if (N < 1) {            continue;        }        m_BoundingBox.Add(ptr, N, VERTEX_SIZE);        bufptr += N * VERTEX_SIZE;    }    // buffer is not empty    SetEmpty(false);}CBBox<3> COpenGLPrintBuffer::GetBoundingBox(void) const{    return m_BoundingBox;}END_NCBI_SCOPE/* * =========================================================================== * $Log: opengl_print_buffer.cpp,v $ * Revision 1000.1  2004/06/01 20:51:54  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7 * * Revision 1.7  2004/05/21 22:27:45  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.6  2003/08/15 17:08:33  meric * Update include paths for print-related files moved from gui/utils to gui/print * * Revision 1.5  2003/06/25 17:58:03  meric * Added #include for vector_object.hpp * * Revision 1.4  2003/06/18 17:26:57  meric * Final phase of print reorg: print classes now in gui/utils * * Revision 1.3  2003/06/18 16:40:33  meric * First phase of print reorg: remove dependence on gui/opengl and OpenGL * except for class COpenGLPrintBuffer * * Revision 1.2  2003/06/16 12:44:52  dicuccio * Clean-up after initial commit * * Revision 1.1  2003 / 06 / 13 18:13:56  meric * Initial version * * * =========================================================================== */

⌨️ 快捷键说明

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