当前位置: 首页>>代码示例>>C++>>正文


C++ GLView类代码示例

本文整理汇总了C++中GLView的典型用法代码示例。如果您正苦于以下问题:C++ GLView类的具体用法?C++ GLView怎么用?C++ GLView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GLView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CCAssert

void ScreenSizeManager::DoInitFixedScreenSize(float myScreenWidth,
                                              float myScreenHeight)
{
    _isInit = true;
    // cocos2d-x v3.0.0 이상만 지원.
    CCAssert(0x00030000 <= COCOS2D_VERSION, "ScreenSizeManager need to cocos2d-x 3.0.0 or higher!");
    
    Director* kDirector = CCDirector::getInstance();
    
    CCAssert(kDirector->getOpenGLView(), "ScreenSizeManager need to kDirector->getOpenGLView() is not NULL");
    
    Size kWinSize = kDirector->getWinSize();
    
    _screenSize.width = kWinSize.width;
    _screenSize.height = kWinSize.height;
    
    _imageResolutionSize.width = myScreenWidth;
    _imageResolutionSize.height = myScreenHeight;
    
    log("DoInitFixedScreenSizeManager %f %f", _imageResolutionSize.width, _imageResolutionSize.height);
    
    // Cocos2d상의 포인트영역이 _imageResolutionSize.width, _imageResolutionSize.height 으로 설정된다.
    // CCDirector::sharedDirector()->getWinSize()의 width, height 가 _imageResolutionSize.width, _imageResolutionSize.height 로 된다.
    
    ResolutionPolicy kResolutionPolicy = ResolutionPolicy::NO_BORDER;
    
    GLView* kGLView = kDirector->getOpenGLView();
    kGLView->setDesignResolutionSize(_imageResolutionSize.width, _imageResolutionSize.height, kResolutionPolicy);
    
    
}
开发者ID:OhByeongYun,项目名称:1989flanker-cpp,代码行数:31,代码来源:ScreenSizeManager.cpp

示例2: onBeforeVisitScissor

void ClippingRectangleNode::onBeforeVisitScissor()
{
    if (_clippingEnabled) {
        // record old ClipRegion
        GLView* glView = Director::getInstance()->getOpenGLView();
        if (glView->isScissorEnabled()) {
            _preClipRegion = glView->getScissorRect();
        } else {
            _preClipRegion = Rect::ZERO;
        }
        glEnable(GL_SCISSOR_TEST);
        
        float scaleX = _scaleX;
        float scaleY = _scaleY;
        Node *parent = this->getParent();
        while (parent) {
            scaleX *= parent->getScaleX();
            scaleY *= parent->getScaleY();
            parent = parent->getParent();
        }
        
        // push this ClipRegion
        const Point pos = convertToWorldSpace(Point(_clippingRegion.origin.x, _clippingRegion.origin.y));
        glView->setScissorInPoints(pos.x,
                                   pos.y,
                                   _clippingRegion.size.width * scaleX,
                                   _clippingRegion.size.height * scaleY);
    }
}
开发者ID:sebastianleecn,项目名称:Quick-Cocos2dx-Community,代码行数:29,代码来源:CCClippingRectangleNode.cpp

示例3: recreatedEvent

// Creates and restores Cocos2d-x after DirectX and Angle contexts are created or updated
void Cocos2dRenderer::CreateGLResources()
{
    auto director = cocos2d::Director::getInstance();

    if(!mInitialized)
    {
        mInitialized = true;
        GLView* glview = GLView::create("Test Cpp");
	    glview->Create(m_eglDisplay, m_eglContext, m_eglSurface, m_renderTargetSize.Width, m_renderTargetSize.Height,m_orientation);
        director->setOpenGLView(glview);
        CCApplication::getInstance()->run();
        glview->SetXamlEventDelegate(m_delegate);
        glview->SetXamlMessageBoxDelegate(m_messageBoxDelegate);
        glview->SetXamlEditBoxDelegate(m_editBoxDelegate);
   }
    else
    {
        cocos2d::GL::invalidateStateCache();
        cocos2d::ShaderCache::getInstance()->reloadDefaultGLPrograms();
        cocos2d::DrawPrimitives::init();
        cocos2d::VolatileTextureMgr::reloadAllTextures();
        cocos2d::EventCustom recreatedEvent(EVENT_RENDERER_RECREATED);
        director->getEventDispatcher()->dispatchEvent(&recreatedEvent);
        cocos2d::Application::getInstance()->applicationWillEnterForeground();
        director->setGLDefaultValues();
  }

    m_loadingComplete = true;
}
开发者ID:CatalystApps,项目名称:Cocos2dxv3_GAFSampleGame,代码行数:30,代码来源:Cocos2dRenderer.cpp

示例4: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    GLView v;
    v.show();

    return a.exec();
}
开发者ID:LucidNeko,项目名称:QTFPS,代码行数:8,代码来源:main.cpp

示例5: data

void EditBoxImplWin::openKeyboard()
{
    if (_delegate != nullptr)
    {
        _delegate->editBoxEditingDidBegin(_editBox);
    }
    
    CEditBox* pEditBox = this->getEditBox();
    if (nullptr != pEditBox && 0 != pEditBox->getScriptEditBoxHandler())
    {
        CommonScriptData data(pEditBox->getScriptEditBoxHandler(), "began",pEditBox);
        ScriptEvent event(kCommonEvent,(void*)&data);
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
    }
    
	std::string placeHolder = _labelPlaceHolder->getString();
	if (placeHolder.length() == 0)
		placeHolder = "Enter value";

	char pText[100]= {0};
	std::string text = getText();
	if (text.length())
		strncpy(pText, text.c_str(), 100);
	GLView *glView = Director::getInstance()->getOpenGLView();
	GLFWwindow *glfwWindow = glView->getWindow();
	HWND hwnd = glfwGetWin32Window(glfwWindow);
	bool didChange = CWin32InputBox::InputBox("Input", placeHolder.c_str(), pText, 100, false, hwnd) == IDOK;
	
	if (didChange) 	
		setText(pText);

	if (_delegate != nullptr) {
		if (didChange)
			_delegate->editBoxTextChanged(_editBox, getText());
		_delegate->editBoxEditingDidEnd(_editBox);
		_delegate->editBoxReturn(_editBox);
	}
    
#if CC_ENABLE_SCRIPT_BINDING
    if (nullptr != _editBox && 0 != _editBox->getScriptEditBoxHandler())
    {
        CommonScriptData data(_editBox->getScriptEditBoxHandler(), "changed",_editBox);
        ScriptEvent event(kCommonEvent,(void*)&data);
        if (didChange)
        {
            ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
        }
        memset(data.eventName,0,sizeof(data.eventName));
        strncpy(data.eventName,"ended",sizeof(data.eventName));
        event.data = (void*)&data;
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
        memset(data.eventName,0,sizeof(data.eventName));
        strncpy(data.eventName,"return",sizeof(data.eventName));
        event.data = (void*)&data;
        ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
    }
#endif // #if CC_ENABLE_SCRIPT_BINDING
}
开发者ID:mycone,项目名称:Tui-x,代码行数:58,代码来源:CEditBoxImplWin.cpp

示例6: _startGameMenuCallback

void WelcomeMenu::_startGameMenuCallback(Ref* pSender)
{
    Director* director = Director::getInstance();
    GLView*   glView   = director->getOpenGLView();
    Size frameSize      = glView->getFrameSize();
    Size winSize       = director->getWinSize();
    log("winSize %f=%f ",winSize.width, winSize.height );
    log("frameSize %f=%f", frameSize.width, frameSize.height);
}
开发者ID:youngershen,项目名称:FingerStyle,代码行数:9,代码来源:WelcomeMenuScene.cpp

示例7:

// return true if eglSwapBuffers was called by OnRender()
bool Cocos2dRenderer::OnRender()
{
    if(m_loadingComplete)
    {
        GLView* glview = GLView::sharedOpenGLView();
        glview->Render();
        return true; // eglSwapBuffers was called by glview->Render();
    }
    return false;
}
开发者ID:CatalystApps,项目名称:Cocos2dxv3_GAFSampleGame,代码行数:11,代码来源:Cocos2dRenderer.cpp

示例8: onGLFWMouseScrollCallback

void GLViewEventHandler::onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y)
{
    GLView* eglView = Director::getInstance()->getOpenGLView();
    if(nullptr == eglView) return;
    
    EventMouse event(EventMouse::MouseEventType::MOUSE_SCROLL);
    //Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here
    event.setScrollData((float)x, -(float)y);
    event.setCursorPosition(s_mouseX, eglView->getViewPortRect().size.height - s_mouseY);
    Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
}
开发者ID:Zaka,项目名称:yap,代码行数:11,代码来源:CCGLView.cpp

示例9: main

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QGuiApplication app(argc, argv);

    GLView view;
    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setSource(QUrl("qrc:/main.qml"));
    view.show();

    return app.exec();
}
开发者ID:osamu-k,项目名称:QtStudy,代码行数:12,代码来源:main.cpp

示例10: glClear

void GLUINavigationProgram::Handle_Display()
{
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  DEBUG_GL_ERRORS()

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  //SetWorldLights();

  camera.toCamera(viewport);

  GLView view;
  view.setViewport(viewport);
  view.setCurrentGL();
  SetWorldLights();

  DEBUG_GL_ERRORS()
  if(stereo_mode){
    glColorMask(GL_FALSE,GL_TRUE,GL_TRUE,GL_TRUE); // draw only to green, blue and alpha
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glTranslatef(-stereo_offset*camera.dist,0,0);
    RenderWorld();
    glPopMatrix();
    glClear(GL_DEPTH_BUFFER_BIT); // leave the blue image but clear Z (NOTE: may need to clear alpha as well for transparency effects!)
    glColorMask(GL_TRUE,GL_FALSE,GL_FALSE,GL_TRUE); // draw only to red and alpha
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glTranslatef(stereo_offset*camera.dist,0,0);
    RenderWorld();
    glPopMatrix();
    glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);}
  else {
    RenderWorld();
    if(show_view_target) DisplayCameraTarget();
  }
  DEBUG_GL_ERRORS()

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(0,viewport.w,viewport.h,0,-100,100);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  RenderScreen();
  DEBUG_GL_ERRORS()

  ++frames_rendered;
  glutSwapBuffers();
  SleepIdleCallback(0);
}
开发者ID:HargisJ,项目名称:KrisLibrary,代码行数:50,代码来源:GLUINavigationProgram.cpp

示例11: detachWithIME

bool TextFieldTTF::detachWithIME()
{
    bool ret = IMEDelegate::detachWithIME();
    if (ret)
    {
        // close keyboard
        GLView * glView = Director::getInstance()->getOpenGLView();
        if (glView)
        {
            glView->setIMEKeyboardState(false);
        }
    }
    return ret;
}
开发者ID:JeeLiu,项目名称:tutorial-puzzle,代码行数:14,代码来源:CCTextFieldTTF.cpp

示例12: IdleDisplay

void GLView::IdleDisplay() {
  const unsigned n_views = inherited_views_.size();
  for (unsigned i = 0; i < n_views; ++i) {
    GLView* view = inherited_views_[i];
    const unsigned n_listeners = view->listeners_.size();
    for (unsigned i = 0; i < n_listeners; ++i) {
      if (view->listeners_[i]->IsEnabled()) {
        view->listeners_[i]->DoEvents();
      }
    }
    glutSetWindow(view->window_handle_);
    view->Display();
  }
}
开发者ID:dkurtaev,项目名称:planets_factory,代码行数:14,代码来源:glview.cpp

示例13: attachWithIME

bool TextFieldTTF::attachWithIME()
{
    bool ret = IMEDelegate::attachWithIME();
    if (ret)
    {
        // open keyboard
        GLView * pGlView = Director::getInstance()->getOpenGLView();
        if (pGlView)
        {
            pGlView->setIMEKeyboardState(true);
        }
    }
    return ret;
}
开发者ID:JeeLiu,项目名称:tutorial-puzzle,代码行数:14,代码来源:CCTextFieldTTF.cpp

示例14: onAfterVisitScissor

void ClippingRectangleNode::onAfterVisitScissor()
{
    if (_clippingEnabled)
    {
        // rollback to old ClipRegion
        if (_preClipRegion.size.width > 0) {
            GLView* glView = Director::getInstance()->getOpenGLView();
            glView->setScissorInPoints(_preClipRegion.origin.x,
                                       _preClipRegion.origin.y,
                                       _preClipRegion.size.width,
                                       _preClipRegion.size.height);
        } else {
            glDisable(GL_SCISSOR_TEST);
        }
    }
}
开发者ID:sebastianleecn,项目名称:Quick-Cocos2dx-Community,代码行数:16,代码来源:CCClippingRectangleNode.cpp

示例15: init

bool WelcomeMenu::init()
{
    if(!Layer::init())
    {
    return false;
    }
    GLView* glView      = Director::getInstance()->getOpenGLView();
    enum ResolutionPolicy policy = ResolutionPolicy::SHOW_ALL;
    glView->setDesignResolutionSize(960, 640, policy);
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin     = Director::getInstance()->getVisibleOrigin();
    auto menu = this->_createMenu();
    menu->setPosition(480, 320);
    this->addChild(menu);
    return true;
}
开发者ID:youngershen,项目名称:FingerStyle,代码行数:16,代码来源:WelcomeMenuScene.cpp


注:本文中的GLView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。