本文整理汇总了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);
}
示例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);
}
}
示例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;
}
示例4: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
GLView v;
v.show();
return a.exec();
}
示例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
}
示例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);
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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();
}
}
示例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;
}
示例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);
}
}
}
示例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;
}