• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Shuffy

            不斷的學習,不斷的思考,才能不斷的進步.Let's do better together!
            posts - 102, comments - 43, trackbacks - 0, articles - 19

            wglUseFontBitmaps函數(shù)

            The wglUseFontBitmaps() function creates a set of bitmap display lists based on the glyphs in the currently selected font in the current DC for use in the current OpenGL RC. It basically creates a series of sequential display lists which can be executed using the function glCallLists. The function takes care of aligning the raster positions of subsequent bitmaps once we specify the raster position for the first bitmap. We use the glRasterPos function to set the current raster position, where the bitmapped text would start appearing.

            The  glRasterPos function works exactly the same way as glVertex function, the only difference being that the position is being transformed and not the object. Thus when we use wglUseFontBitmaps to generate display lists and then call them, the resulting text is displayed, starting at the current raster position, and the bitmaps are copied to the raster buffer, giving the effect of always having the text positioned in the xy plane of the screen. 

            Thus we would use wglUseFontBitmaps when we need the text to be visible to the user and that the size of the text relative to its distance from the viewpoint doesn't matter.

            wglUseFontOutlines函數(shù)

            The wglUseFontOutlines function creates a set of 3D polygon or line based primitive display lists, based on the glyphs in the currently selected TrueType font in the current DC for use in the current OpenGL RC. Stroke and Raster fonts are not supported. These objects can then be used to draw 3D characters. This function also has additional arguments that control the extrusion of the 3D characters in the +Z direction, the deviation of the generated primitive vertices from the design outline of the font, whether to generated filled polygons or a wireframe primitives and an array of structures to hold the metrics of each of the generated characters.

            1,在CCY457OpenGLView類中加入下述變量:


                
            //For Text
                GLuint m_3DTextList;
                GLuint m_2DTextList;
                BOOL m_b3DText, m_b2DText;

            并在構造函數(shù)中進行初始化:

            CCY457OpenGLView::CCY457OpenGLView()
            {
                m_xRot 
            = 0.0f;
                m_yRot 
            = 0.0f;
                m_b3DText 
            = FALSE;
                m_b2DText 
            = FALSE;
            }

            2,加入兩個用來創(chuàng)建文本的菜單項及其事件處理函數(shù)

            void CCY457OpenGLView::OnText2dtext() 
            {
                m_b3DText 
            = FALSE;
                m_b2DText 
            = TRUE;
                InvalidateRect(NULL,FALSE);
            }
            void CCY457OpenGLView::OnText3dtext() 
            {
                m_b3DText 
            = TRUE;
                m_b2DText 
            = FALSE;
                InvalidateRect(NULL,FALSE);    
            }
            void CCY457OpenGLView::OnUpdateText2dtext(CCmdUI* pCmdUI) 
            {
                pCmdUI
            ->SetRadio(m_b2DText);        
            }
            void CCY457OpenGLView::OnUpdateText3dtext(CCmdUI* pCmdUI) 
            {
                pCmdUI
            ->SetRadio(m_b3DText);
            }

            3,實際創(chuàng)建2D3D文本列表的函數(shù):

            void CCY457OpenGLView::Create3DTextLists()
            {
                CFont m_font;
                GLYPHMETRICSFLOAT agmf[
            256]; 
                m_font.CreateFont(    
            -12,                            // Height Of Font
                                    0,                                // Width Of Font
                                    0,                                // Angle Of Escapement
                                    0,                                // Orientation Angle
                                    FW_BOLD,                        // Font Weight
                                    FALSE,                            // Italic
                                    FALSE,                            // Underline
                                    FALSE,                            // Strikeout
                                    ANSI_CHARSET,                    // Character Set Identifier
                                    OUT_TT_PRECIS,                    // Output Precision
                                    CLIP_DEFAULT_PRECIS,            // Clipping Precision
                                    ANTIALIASED_QUALITY,            // Output Quality
                                    FF_DONTCARE|DEFAULT_PITCH,        // Family And Pitch
                                    "Algerian");
                CFont
            * m_pOldFont = m_pDC->SelectObject(&m_font);
                 
            // create display lists for glyphs 0 through 255 with 0.1 extrusion 
                
            // and default deviation. The display list numbering starts at 1000 
                
            // (it could be any number) 
                m_3DTextList = glGenLists(256);
                wglUseFontOutlines(m_pDC
            ->GetSafeHdc(), 0255, m_3DTextList, 0.0f0.5f,WGL_FONT_POLYGONS, agmf); 
                m_pDC
            ->SelectObject(m_pOldFont);
            }
            void CCY457OpenGLView::Create2DTextLists()
            {
                CFont m_font;
                m_font.CreateFont(    
            -24,                            // Height Of Font
                                    0,                                // Width Of Font
                                    0,                                // Angle Of Escapement
                                    0,                                // Orientation Angle
                                    FW_NORMAL,                        // Font Weight
                                    FALSE,                            // Italic
                                    FALSE,                            // Underline
                                    FALSE,                            // Strikeout
                                    ANSI_CHARSET,                    // Character Set Identifier
                                    OUT_TT_PRECIS,                    // Output Precision
                                    CLIP_DEFAULT_PRECIS,            // Clipping Precision
                                    DEFAULT_QUALITY,                // Output Quality
                                    FF_DONTCARE|DEFAULT_PITCH,        // Family And Pitch
                                    "Algerian");
                CFont
            * m_pOldFont = m_pDC->SelectObject(&m_font);
                 
            // create display lists for glyphs 0 through 255 with 0.1 extrusion 
                
            // and default deviation. The display list numbering starts at 1000 
                
            // (it could be any number) 
                m_2DTextList = glGenLists(256);
                wglUseFontBitmaps(m_pDC
            ->GetSafeHdc(), 0255, m_2DTextList); 
                m_pDC
            ->SelectObject(m_pOldFont);
            }

            4, InitializeOpenGL函數(shù)中調用上述兩個函數(shù):

            BOOL CCY457OpenGLView::InitializeOpenGL()
            {
                
            //Get a DC for the Client Area
                m_pDC = new CClientDC(this);
                
            //Failure to Get DC
                if(m_pDC == NULL)
                {
                    MessageBox(
            "Error Obtaining DC");
                    
            return FALSE;
                }
                
            //Failure to set the pixel format
                if(!SetupPixelFormat())
                {
                    
            return FALSE;
                }
                
            //Create Rendering Context
                m_hRC = ::wglCreateContext (m_pDC->GetSafeHdc ());
                
            //Failure to Create Rendering Context
                if(m_hRC == 0)
                {
                    MessageBox(
            "Error Creating RC");
                    
            return FALSE;
                }
                
            //Make the RC Current
                if(::wglMakeCurrent (m_pDC->GetSafeHdc (), m_hRC)==FALSE)
                {
                    MessageBox(
            "Error making RC Current");
                    
            return FALSE;
                }
                
                
            //Specify Black as the clear color
                ::glClearColor(0.0f,0.0f,0.0f,0.0f);
                
            //Specify the back of the buffer as clear depth
                ::glClearDepth(1.0f);
                
            //Enable Depth Testing
                ::glEnable(GL_DEPTH_TEST);
                glShadeModel(GL_FLAT);
                SetupLighting();
                
            //Create Font Display Lists
                Create2DTextLists();
                Create3DTextLists();
                
            return TRUE;
            }

            5,繪制函數(shù)修改如下:

            void CCY457OpenGLView::RenderScene ()
            {
            //繪制函數(shù)
                glTranslatef(-1.0f,0.0f,-5.0f);
                glRotatef(
            -10.0,1.0f,0.0f,0.0f);    
                glRotatef(
            -10.0,0.0f,1.0f,0.0f);    
                
            if(m_b2DText)
                {
            //2D文本
                    
            // Position The Text On The Screen
                    glDisable(GL_LIGHTING);
                    glColor3f(
            1.0f,1.0f,0.0f);
                    glRasterPos2f(
            0,0);
                    glListBase(m_2DTextList);
                    glCallLists(
            6, GL_UNSIGNED_BYTE ,"OpenGL");
                    glEnable(GL_LIGHTING);
                }
                
            if(m_b3DText)
                {
            //3D文本
                    glListBase(m_3DTextList);
                    glCallLists(
            6, GL_UNSIGNED_BYTE ,"OpenGL");
                }
            }

            作者:洞庭散人

            出處:http://phinecos.cnblogs.com/    

            本文版權歸作者和博客園共有,歡迎轉載,但未經(jīng)作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。
            原文鏈接:http://www.cnblogs.com/phinecos/archive/2008/11/06/1328250.html
            久久精品亚洲欧美日韩久久| 国产亚洲婷婷香蕉久久精品| 国产精品久久精品| 国产精品久久久久AV福利动漫| 精品久久久噜噜噜久久久| 精品久久久久久国产潘金莲| 99久久国产综合精品网成人影院| 亚洲乱码日产精品a级毛片久久| 97精品伊人久久久大香线蕉| 狠狠色婷婷综合天天久久丁香| 久久se精品一区二区影院| 人人狠狠综合久久亚洲婷婷| 亚洲伊人久久精品影院| 99精品久久精品| 97精品伊人久久久大香线蕉| 久久本道综合久久伊人| 久久国产亚洲精品无码| 午夜欧美精品久久久久久久| 久久中文字幕人妻丝袜| 久久久综合香蕉尹人综合网| 久久综合九色综合久99| 久久99九九国产免费看小说| 狠狠人妻久久久久久综合蜜桃| 亚洲中文字幕久久精品无码APP| 日韩欧美亚洲综合久久影院Ds | 99re这里只有精品热久久| 香港aa三级久久三级老师2021国产三级精品三级在 | 国产精品嫩草影院久久| 久久中文娱乐网| 99久久精品午夜一区二区| 亚洲国产另类久久久精品小说| 亚洲AⅤ优女AV综合久久久| 合区精品久久久中文字幕一区| 精品国产青草久久久久福利| 久久国产热这里只有精品| 国产精品久久久天天影视香蕉| 老司机国内精品久久久久| 国产精品一久久香蕉国产线看| 日韩精品久久久久久久电影蜜臀| 久久福利青草精品资源站免费| 久久精品国产一区二区三区日韩|