• <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>
            隨筆 - 132  文章 - 51  trackbacks - 0
            <2012年7月>
            24252627282930
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(7)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            cocos2d-x

            OGRE

            OPenGL

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            #define GLUT_DISABLE_ATEXIT_HACK
            #include 
            <gl/GLUT.h>
            #include 
            <gl/gl.h>
            #include 
            <tchar.h>
            #include 
            <cegui.h>
            #include 
            <RendererModules\OpenGL\CEGUIOpenGL.h>
            #include 
            <RendererModules\OpenGL\CEGUIOpenGLRenderer.h>

            #pragma comment( lib, 
            "glu32.lib" )
            #pragma comment( lib, 
            "CEGUIBase_d.lib" )
            #pragma comment( lib, 
            "CEGUIOpenGLRenderer_d.lib" )
            #pragma comment ( lib , 
            "CEGUIExpatParser_d.lib" )

            #define EDIT_CONTORL_NAME "Root/EditBox"

            using namespace CEGUI;
            int G_lastFrameTime = 0;
            bool G_quitFlag = false;
            void mouseMotion( int x, int y );
            void mouseButton( int button, int state, int x, int y );
            void KeyCharDown( unsigned char key, int x, int y );
            void KeyCharUp( unsigned char key, int x, int y );
            void RenderScene();
            void InitGUI();

            class GUI
            {
            public:
                GUI()
            {
                }

                
            ~GUI(){}
            public:
                
            static bool handleKeyDown( const CEGUI::EventArgs& args )
                
            {
                    
            using namespace CEGUI;
                    
                    
            const CEGUI::KeyEventArgs& keyArgs = static_cast<const CEGUI::KeyEventArgs&>(args);

                    Window
            * d_root = CEGUI::System::getSingleton().getGUISheet();

                    
            // get the text entry editbox
                    Editbox* editbox = static_cast<Editbox*>(d_root->getChild(EDIT_CONTORL_NAME));
                    
                    
            if ( keyArgs.scancode == CEGUI::Key::Return ){
                        editbox
            ->setText("");
                    }
            else{
                        
            // get text out of the editbox
                        String edit_text(editbox->getText());
                        editbox
            ->setText(edit_text+keyArgs.scancode );
                    }


                    
            // re-activate the text entry box
                    editbox->activate();
                    
            return true;
                }

            }
            ;


            int _tmain(int argc, _TCHAR* argv[])
            {
                glutInit( 
            &argc,argv );
                glutInitDisplayMode( GLUT_DEPTH 
            | GLUT_DOUBLE | GLUT_RGBA );    //GLUT_DOUBLE glutSwapBuffers()
                glutInitWindowPosition( 100,100 );
                glutInitWindowSize( 
            800,600 );
                glutCreateWindow( 
            "GUITest" );
                glutSetCursor( GLUT_CURSOR_NONE );                                
            //否則雙鼠標

                
            // Initilise CEGUI,must initilise OpenGL context before CEGUI::OpenGLRenderer::create();
                
            // or else,OpenGLRenderer failed to initialize the GLEW library. Missing GL version
                InitGUI();

                glutDisplayFunc( RenderScene );
                
                glutMotionFunc( mouseMotion );
                glutPassiveMotionFunc( mouseMotion );
                glutMouseFunc( mouseButton );
                glutKeyboardFunc( KeyCharDown );
                
            //glutKeyboardUpFunc( KeyCharUp );

                glutMainLoop();

                
            return 0;
            }


            void InitGUI()
            {
                
            using namespace CEGUI;
                CEGUI::OpenGLRenderer
            & myRenderer = CEGUI::OpenGLRenderer::create();
                CEGUI::System
            & sys = CEGUI::System::create( myRenderer );

                
            //Init resource directory
                CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());
                rp
            ->setResourceGroupDirectory("schemes""../datafiles/schemes/");  
                rp
            ->setResourceGroupDirectory("imagesets","../datafiles/imagesets/");  
                rp
            ->setResourceGroupDirectory("fonts""../datafiles/fonts/");  
                rp
            ->setResourceGroupDirectory("layouts""../datafiles/layouts/");  
                rp
            ->setResourceGroupDirectory("looknfeels","../datafiles/looknfeel/");  
                rp
            ->setResourceGroupDirectory("lua_scripts","../datafiles/lua_scripts/");  

                CEGUI::Scheme::setDefaultResourceGroup(
            "schemes"); 
                CEGUI::Imageset::setDefaultResourceGroup(
            "imagesets" );
                CEGUI::Font::setDefaultResourceGroup(
            "fonts"); 
                CEGUI::WindowManager::setDefaultResourceGroup(
            "layouts");
                CEGUI::WidgetLookManager::setDefaultResourceGroup(
            "looknfeels");
                CEGUI::ScriptModule::setDefaultResourceGroup(
            "lua_scripts"); 
                
                WindowManager
            & winMgr = WindowManager::getSingleton();
                SchemeManager::getSingleton().create( 
            "TaharezLook.scheme" );
                System::getSingleton().setDefaultMouseCursor( 
            "TaharezLook""MouseArrow" );
                FontManager::getSingleton().create( 
            "Girl.font" );
                
                Window
            * root = winMgr.loadWindowLayout( "Myself.layout" );

                System::getSingleton().setGUISheet( root );

                winMgr.getWindow( EDIT_CONTORL_NAME )
            ->subscribeEvent(  CEGUI::Editbox::EventTextAccepted,  CEGUI::Event::Subscriber(&GUI::handleKeyDown)); 

            }


            void mouseMotion( int x,int y )
            {
                CEGUI::System::getSingleton().injectMousePosition( x,y );
            }


            void mouseButton( int button, int state, int x, int y )
            {
                
            switch( button )
                
            {
                
            case GLUT_LEFT_BUTTON:
                    
            {
                        
            if ( state == GLUT_UP )
                            CEGUI::System::getSingleton().injectMouseButtonUp( CEGUI::LeftButton );
                        
            else
                            CEGUI::System::getSingleton().injectMouseButtonDown( CEGUI::LeftButton );
                    }

                    
            break;
                
            case GLUT_RIGHT_BUTTON:
                    
            {
                        
            if ( state == GLUT_UP )
                            CEGUI::System::getSingleton().injectMouseButtonUp( CEGUI::RightButton );
                        
            else
                            CEGUI::System::getSingleton().injectMouseButtonDown( CEGUI::RightButton );
                    }

                    
            break;
                
            case GLUT_MIDDLE_BUTTON:
                    
            {
                        
            if ( state == GLUT_UP )
                            CEGUI::System::getSingleton().injectMouseButtonUp( CEGUI::MiddleButton );
                        
            else
                            CEGUI::System::getSingleton().injectMouseButtonDown( CEGUI::MiddleButton );
                    }

                    
            break;
                }

            }


            void KeyCharDown( unsigned char key, int x, int y )
            {
                
            if ( key == VK_ESCAPE )
                    G_quitFlag 
            = TRUE;
                CEGUI::System::getSingleton().injectChar( static_cast
            <CEGUI::utf32>(key) );
            }


            void KeyCharUp( unsigned char key, int x, int y )
            {
                
            //CEGUI::System::getSingleton().injectKeyUp( static_cast<CEGUI::utf32>(key) );
            }


            void RenderScene()
            {
                
            int thisTime = glutGet( GLUT_ELAPSED_TIME );
                
            float elapsed = static_cast<float>(thisTime - G_lastFrameTime );
                G_lastFrameTime 
            = thisTime;
                
                
            //inject the time pulse
                CEGUI::System::getSingleton().injectTimePulse( elapsed/1000.f );

                glClear(GL_COLOR_BUFFER_BIT 
            | GL_DEPTH_BUFFER_BIT );
                CEGUI::System::getSingleton().renderGUI();

                glFlush();
                glutPostRedisplay();
                glutSwapBuffers(); 

                
            if ( G_quitFlag )
                    exit(
            0);
            }



            參考:
            http://www.ispinel.com/2010/05/26/961
            http://www.ispinel.com/2010/05/26/971
            http://cache.baidu.com/c?m=9f65cb4a8c8507ed4fece7631046893b4c4380146d96864968d4e414c42246031c2eb8b92127171980852d3d5aeb1e41eaf235702a0121aa9bc2954ddbbb94232c883034074fc70358c75cf28b102a947ed71cfeaf68b6eda575c8b9d3a3c85520dd52756d81839c5b7055812eb6436ef4a7e95f142c07bb9d27648c4e7659ca7406f71ca5b56c3941dcaaca5c3dd42aa77610e7ef62ec6845f546e344&p=8b2a950e8c934eab03f1c93f5f&user=baidu
            posted on 2010-06-19 19:57 風輕云淡 閱讀(1494) 評論(1)  編輯 收藏 引用

            FeedBack:
            # re: 基于GLUT的CEGUI 2010-11-21 13:59 周江
            你好! 看了你的文章 然后測試 怎么提示我 CEGUI::InvalidRequestException in file d:\temp\cegui-0.7.1-vc8\cegui\src\ceguidefaultresourceprovider.cpp(63) : DefaultResourceProvider::load - TaharezLook.scheme does not exist

            能告訴我是怎么回事嗎? 我對CEGUI 還是個新手 要是能把整個運行發給我 那就最好了 麻煩你了 我的郵箱是:zj.john04@gmail.com  回復  更多評論
              
            久久亚洲高清观看| 久久综合国产乱子伦精品免费| 国产精品美女久久久久网| 久久久久久午夜成人影院| 国产精品久久久久9999| 久久精品国产99久久香蕉| 亚洲七七久久精品中文国产 | 久久免费线看线看| 少妇久久久久久被弄到高潮| 久久精品国产日本波多野结衣| 久久免费美女视频| 免费精品久久天干天干| 91久久婷婷国产综合精品青草 | 久久久国产精品亚洲一区| 免费国产99久久久香蕉| 一本一道久久综合狠狠老| 国产高清美女一级a毛片久久w| 伊人久久久AV老熟妇色| 久久精品国产99久久丝袜| 97久久久久人妻精品专区| 中文字幕无码久久久| 99久久国产热无码精品免费久久久久 | 久久久久国色AV免费看图片| 粉嫩小泬无遮挡久久久久久| 2021国内久久精品| 国产精品伦理久久久久久| 久久久精品人妻一区二区三区四| 久久综合久久综合亚洲| 99久久精品国产综合一区| 久久国产免费观看精品| 亚洲AV无码久久| 亚洲va久久久噜噜噜久久 | 亚洲欧洲久久久精品| 久久涩综合| 久久久久国产成人精品亚洲午夜| 国产ww久久久久久久久久| 国产精品无码久久久久久| 婷婷久久久亚洲欧洲日产国码AV| 天天综合久久一二三区| 中文字幕久久亚洲一区| 久久人人爽人人爽人人爽|