mirror of https://github.com/axmolengine/axmol.git
Support use google angle support on windows.
This commit is contained in:
parent
cd656f8b8b
commit
3d3fea28c6
|
@ -117,5 +117,7 @@ THE SOFTWARE.
|
||||||
#define CC_USE_GL
|
#define CC_USE_GL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define CC_USE_GLES_ON_DESKTOP 1
|
||||||
|
|
||||||
/// @endcond
|
/// @endcond
|
||||||
#endif // __BASE_CC_PLATFORM_CONFIG_H__
|
#endif // __BASE_CC_PLATFORM_CONFIG_H__
|
||||||
|
|
|
@ -47,8 +47,6 @@ THE SOFTWARE.
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
GLViewImpl* GLFWEventHandler::_view = nullptr;
|
|
||||||
|
|
||||||
const std::string GLViewImpl::EVENT_WINDOW_RESIZED = "glview_window_resized";
|
const std::string GLViewImpl::EVENT_WINDOW_RESIZED = "glview_window_resized";
|
||||||
const std::string GLViewImpl::EVENT_WINDOW_FOCUSED = "glview_window_focused";
|
const std::string GLViewImpl::EVENT_WINDOW_FOCUSED = "glview_window_focused";
|
||||||
const std::string GLViewImpl::EVENT_WINDOW_UNFOCUSED = "glview_window_unfocused";
|
const std::string GLViewImpl::EVENT_WINDOW_UNFOCUSED = "glview_window_unfocused";
|
||||||
|
@ -194,6 +192,91 @@ static keyCodeItem g_keyCodeStructArray[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// GLFW Event forward handler
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
class GLFWEventHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void onGLFWError(int errorID, const char* errorDesc)
|
||||||
|
{
|
||||||
|
if (_view)
|
||||||
|
_view->onGLFWError(errorID, errorDesc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify)
|
||||||
|
{
|
||||||
|
if (_view)
|
||||||
|
_view->onGLFWMouseCallBack(window, button, action, modify);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
|
||||||
|
{
|
||||||
|
if (_view)
|
||||||
|
_view->onGLFWMouseMoveCallBack(window, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y)
|
||||||
|
{
|
||||||
|
if (_view)
|
||||||
|
_view->onGLFWMouseScrollCallback(window, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
if (_view)
|
||||||
|
_view->onGLFWKeyCallback(window, key, scancode, action, mods);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onGLFWCharCallback(GLFWwindow* window, unsigned int character)
|
||||||
|
{
|
||||||
|
if (_view)
|
||||||
|
_view->onGLFWCharCallback(window, character);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y)
|
||||||
|
{
|
||||||
|
if (_view)
|
||||||
|
_view->onGLFWWindowPosCallback(windows, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onGLFWFrameBufferSizeCallback(GLFWwindow* window, int w, int h)
|
||||||
|
{
|
||||||
|
if (_view)
|
||||||
|
_view->onGLFWFramebufferSizeCallback(window, w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onGLFWWindowSizeCallback(GLFWwindow* window, int width, int height)
|
||||||
|
{
|
||||||
|
if (_view)
|
||||||
|
_view->onGLFWWindowSizeCallback(window, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setGLViewImpl(GLViewImpl* view)
|
||||||
|
{
|
||||||
|
_view = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified)
|
||||||
|
{
|
||||||
|
if (_view)
|
||||||
|
{
|
||||||
|
_view->onGLFWWindowIconifyCallback(window, iconified);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void onGLFWWindowFocusCallback(GLFWwindow* window, int focused)
|
||||||
|
{
|
||||||
|
if (_view)
|
||||||
|
{
|
||||||
|
_view->onGLFWWindowFocusCallback(window, focused);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static GLViewImpl* _view;
|
||||||
|
};
|
||||||
|
GLViewImpl* GLFWEventHandler::_view = nullptr;
|
||||||
|
|
||||||
// implement GLViewImpl
|
// implement GLViewImpl
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -286,6 +369,13 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram
|
||||||
|
|
||||||
_frameZoomFactor = frameZoomFactor;
|
_frameZoomFactor = frameZoomFactor;
|
||||||
|
|
||||||
|
#if CC_USE_GLES_ON_DESKTOP
|
||||||
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
glfwWindowHint(GLFW_RESIZABLE,resizable?GL_TRUE:GL_FALSE);
|
glfwWindowHint(GLFW_RESIZABLE,resizable?GL_TRUE:GL_FALSE);
|
||||||
glfwWindowHint(GLFW_RED_BITS,_glContextAttrs.redBits);
|
glfwWindowHint(GLFW_RED_BITS,_glContextAttrs.redBits);
|
||||||
glfwWindowHint(GLFW_GREEN_BITS,_glContextAttrs.greenBits);
|
glfwWindowHint(GLFW_GREEN_BITS,_glContextAttrs.greenBits);
|
||||||
|
@ -348,21 +438,19 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram
|
||||||
glfwSetCharCallback(_mainWindow, GLFWEventHandler::onGLFWCharCallback);
|
glfwSetCharCallback(_mainWindow, GLFWEventHandler::onGLFWCharCallback);
|
||||||
glfwSetKeyCallback(_mainWindow, GLFWEventHandler::onGLFWKeyCallback);
|
glfwSetKeyCallback(_mainWindow, GLFWEventHandler::onGLFWKeyCallback);
|
||||||
glfwSetWindowPosCallback(_mainWindow, GLFWEventHandler::onGLFWWindowPosCallback);
|
glfwSetWindowPosCallback(_mainWindow, GLFWEventHandler::onGLFWWindowPosCallback);
|
||||||
glfwSetFramebufferSizeCallback(_mainWindow, GLFWEventHandler::onGLFWframebuffersize);
|
glfwSetFramebufferSizeCallback(_mainWindow, GLFWEventHandler::onGLFWFrameBufferSizeCallback);
|
||||||
glfwSetWindowSizeCallback(_mainWindow, GLFWEventHandler::onGLFWWindowSizeFunCallback);
|
glfwSetWindowSizeCallback(_mainWindow, GLFWEventHandler::onGLFWWindowSizeCallback);
|
||||||
glfwSetWindowIconifyCallback(_mainWindow, GLFWEventHandler::onGLFWWindowIconifyCallback);
|
glfwSetWindowIconifyCallback(_mainWindow, GLFWEventHandler::onGLFWWindowIconifyCallback);
|
||||||
glfwSetWindowFocusCallback(_mainWindow, GLFWEventHandler::onGLFWWindowFocusCallback);
|
glfwSetWindowFocusCallback(_mainWindow, GLFWEventHandler::onGLFWWindowFocusCallback);
|
||||||
|
|
||||||
setFrameSize(rect.size.width, rect.size.height);
|
setFrameSize(rect.size.width, rect.size.height);
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
|
|
||||||
|
|
||||||
loadGL();
|
loadGL();
|
||||||
|
|
||||||
// check OpenGL version at first
|
// check OpenGL version at first
|
||||||
const GLubyte* glVersion = glGetString(GL_VERSION);
|
const GLubyte* glVersion = glGetString(GL_VERSION);
|
||||||
|
|
||||||
if ( utils::atof((const char*)glVersion) < 1.5 )
|
if ( utils::atof((const char*)glVersion) < 1.5 && nullptr == strstr((const char*)glVersion, "ANGLE") )
|
||||||
{
|
{
|
||||||
char strComplain[256] = {0};
|
char strComplain[256] = {0};
|
||||||
sprintf(strComplain,
|
sprintf(strComplain,
|
||||||
|
@ -371,23 +459,23 @@ bool GLViewImpl::initWithRect(const std::string& viewName, Rect rect, float fram
|
||||||
ccMessageBox(strComplain, "OpenGL version too old");
|
ccMessageBox(strComplain, "OpenGL version too old");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Will cause OpenGL error 0x0500 when use ANGLE-GLES on desktop
|
||||||
|
#if !CC_USE_GLES_ON_DESKTOP
|
||||||
// Enable point size by default.
|
// Enable point size by default.
|
||||||
#if defined(GL_VERSION_2_0)
|
#if defined(GL_VERSION_2_0)
|
||||||
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
|
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
|
||||||
#else
|
#else
|
||||||
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
|
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
|
||||||
#endif
|
#endif
|
||||||
|
if (_glContextAttrs.multisamplingCount > 0)
|
||||||
if(_glContextAttrs.multisamplingCount > 0)
|
|
||||||
glEnable(GL_MULTISAMPLE);
|
glEnable(GL_MULTISAMPLE);
|
||||||
|
#endif
|
||||||
CHECK_GL_ERROR_DEBUG();
|
CHECK_GL_ERROR_DEBUG();
|
||||||
|
|
||||||
// // GLFW v3.2 no longer emits "onGLFWWindowSizeFunCallback" at creation time. Force default viewport:
|
// // GLFW v3.2 no longer emits "onGLFWWindowSizeFunCallback" at creation time. Force default viewport:
|
||||||
// setViewPortInPoints(0, 0, neededWidth, neededHeight);
|
// setViewPortInPoints(0, 0, neededWidth, neededHeight);
|
||||||
//
|
//
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -816,12 +904,10 @@ void GLViewImpl::onGLFWMouseScrollCallback(GLFWwindow* /*window*/, double x, dou
|
||||||
|
|
||||||
void GLViewImpl::onGLFWKeyCallback(GLFWwindow* /*window*/, int key, int /*scancode*/, int action, int /*mods*/)
|
void GLViewImpl::onGLFWKeyCallback(GLFWwindow* /*window*/, int key, int /*scancode*/, int action, int /*mods*/)
|
||||||
{
|
{
|
||||||
if (GLFW_REPEAT != action)
|
// x-studio spec, for repeat press key support.
|
||||||
{
|
EventKeyboard event(g_keyCodeMap[key], action);
|
||||||
EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action);
|
auto dispatcher = Director::getInstance()->getEventDispatcher();
|
||||||
auto dispatcher = Director::getInstance()->getEventDispatcher();
|
dispatcher->dispatchEvent(&event);
|
||||||
dispatcher->dispatchEvent(&event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GLFW_RELEASE != action)
|
if (GLFW_RELEASE != action)
|
||||||
{
|
{
|
||||||
|
@ -876,8 +962,9 @@ void GLViewImpl::onGLFWWindowPosCallback(GLFWwindow* /*window*/, int /*x*/, int
|
||||||
Director::getInstance()->setViewport();
|
Director::getInstance()->setViewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLViewImpl::onGLFWframebuffersize(GLFWwindow* window, int w, int h)
|
void GLViewImpl::onGLFWFramebufferSizeCallback(GLFWwindow* window, int w, int h)
|
||||||
{
|
{ // win32 glfw never invoke this callback
|
||||||
|
#if CC_TARGET_PLATFORM != CC_PLATFORM_WIN32
|
||||||
float frameSizeW = _screenSize.width;
|
float frameSizeW = _screenSize.width;
|
||||||
float frameSizeH = _screenSize.height;
|
float frameSizeH = _screenSize.height;
|
||||||
float factorX = frameSizeW / w * _retinaFactor * _frameZoomFactor;
|
float factorX = frameSizeW / w * _retinaFactor * _frameZoomFactor;
|
||||||
|
@ -895,7 +982,7 @@ void GLViewImpl::onGLFWframebuffersize(GLFWwindow* window, int w, int h)
|
||||||
_retinaFactor = 2;
|
_retinaFactor = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetWindowSize(window, static_cast<int>(frameSizeW * 0.5f * _retinaFactor * _frameZoomFactor), static_cast<int>(frameSizeH * 0.5f * _retinaFactor * _frameZoomFactor));
|
glfwSetWindowSize(window, static_cast<int>(frameSizeW * 0.5f * _retinaFactor * _frameZoomFactor) , static_cast<int>(frameSizeH * 0.5f * _retinaFactor * _frameZoomFactor));
|
||||||
}
|
}
|
||||||
else if (std::abs(factorX - 2.0f) < FLT_EPSILON && std::abs(factorY - 2.0f) < FLT_EPSILON)
|
else if (std::abs(factorX - 2.0f) < FLT_EPSILON && std::abs(factorY - 2.0f) < FLT_EPSILON)
|
||||||
{
|
{
|
||||||
|
@ -903,20 +990,16 @@ void GLViewImpl::onGLFWframebuffersize(GLFWwindow* window, int w, int h)
|
||||||
_retinaFactor = 1;
|
_retinaFactor = 1;
|
||||||
glfwSetWindowSize(window, static_cast<int>(frameSizeW * _retinaFactor * _frameZoomFactor), static_cast<int>(frameSizeH * _retinaFactor * _frameZoomFactor));
|
glfwSetWindowSize(window, static_cast<int>(frameSizeW * _retinaFactor * _frameZoomFactor), static_cast<int>(frameSizeH * _retinaFactor * _frameZoomFactor));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLViewImpl::onGLFWWindowSizeFunCallback(GLFWwindow* /*window*/, int width, int height)
|
void GLViewImpl::onGLFWWindowSizeCallback(GLFWwindow* /*window*/, int w, int h)
|
||||||
{
|
{
|
||||||
if (width && height && _resolutionPolicy != ResolutionPolicy::UNKNOWN)
|
if (w && h && _resolutionPolicy != ResolutionPolicy::UNKNOWN)
|
||||||
{
|
{
|
||||||
Size baseDesignSize = _designResolutionSize;
|
// x-studio spec, fix view size incorrect when window size changed.
|
||||||
ResolutionPolicy baseResolutionPolicy = _resolutionPolicy;
|
updateDesignResolutionSize();
|
||||||
|
|
||||||
float frameWidth = width / _frameZoomFactor;
|
|
||||||
float frameHeight = height / _frameZoomFactor;
|
|
||||||
setFrameSize(frameWidth, frameHeight);
|
|
||||||
setDesignResolutionSize(baseDesignSize.width, baseDesignSize.height, baseResolutionPolicy);
|
|
||||||
Director::getInstance()->setViewport();
|
|
||||||
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(GLViewImpl::EVENT_WINDOW_RESIZED, nullptr);
|
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent(GLViewImpl::EVENT_WINDOW_RESIZED, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1033,6 +1116,7 @@ bool GLViewImpl::loadGL()
|
||||||
|
|
||||||
// glad: load all OpenGL function pointers
|
// glad: load all OpenGL function pointers
|
||||||
// ---------------------------------------
|
// ---------------------------------------
|
||||||
|
#if !CC_USE_GLES_ON_DESKTOP
|
||||||
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
|
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
|
||||||
{
|
{
|
||||||
log("glad: Failed to Load GL");
|
log("glad: Failed to Load GL");
|
||||||
|
@ -1045,15 +1129,16 @@ bool GLViewImpl::loadGL()
|
||||||
{
|
{
|
||||||
log("Not totally ready :(");
|
log("Not totally ready :(");
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
if (!loadFboExtensions())
|
if (!gladLoadGLES2Loader((GLADloadproc)glfwGetProcAddress))
|
||||||
|
{
|
||||||
|
log("glad: Failed to Load GLES2");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
|
||||||
// close _vsync_ default for nvidia display card
|
|
||||||
::glfwSwapInterval(0);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
loadFboExtensions();
|
||||||
|
|
||||||
#endif // (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
|
#endif // (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -54,7 +54,7 @@ THE SOFTWARE.
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
class GLFWEventHandler;
|
||||||
class CC_DLL GLViewImpl : public GLView
|
class CC_DLL GLViewImpl : public GLView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -149,8 +149,8 @@ protected:
|
||||||
void onGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
void onGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
void onGLFWCharCallback(GLFWwindow* window, unsigned int character);
|
void onGLFWCharCallback(GLFWwindow* window, unsigned int character);
|
||||||
void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y);
|
void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y);
|
||||||
void onGLFWframebuffersize(GLFWwindow* window, int w, int h);
|
void onGLFWFramebufferSizeCallback(GLFWwindow* window, int w, int h);
|
||||||
void onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int height);
|
void onGLFWWindowSizeCallback(GLFWwindow *window, int width, int height);
|
||||||
void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified);
|
void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified);
|
||||||
void onGLFWWindowFocusCallback(GLFWwindow* window, int focused);
|
void onGLFWWindowFocusCallback(GLFWwindow* window, int focused);
|
||||||
|
|
||||||
|
@ -181,89 +181,4 @@ private:
|
||||||
CC_DISALLOW_COPY_AND_ASSIGN(GLViewImpl);
|
CC_DISALLOW_COPY_AND_ASSIGN(GLViewImpl);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CC_DLL GLFWEventHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void onGLFWError(int errorID, const char* errorDesc)
|
|
||||||
{
|
|
||||||
if (_view)
|
|
||||||
_view->onGLFWError(errorID, errorDesc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify)
|
|
||||||
{
|
|
||||||
if (_view)
|
|
||||||
_view->onGLFWMouseCallBack(window, button, action, modify);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
|
|
||||||
{
|
|
||||||
if (_view)
|
|
||||||
_view->onGLFWMouseMoveCallBack(window, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void onGLFWMouseScrollCallback(GLFWwindow* window, double x, double y)
|
|
||||||
{
|
|
||||||
if (_view)
|
|
||||||
_view->onGLFWMouseScrollCallback(window, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void onGLFWKeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
|
||||||
{
|
|
||||||
if (_view)
|
|
||||||
_view->onGLFWKeyCallback(window, key, scancode, action, mods);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void onGLFWCharCallback(GLFWwindow* window, unsigned int character)
|
|
||||||
{
|
|
||||||
if (_view)
|
|
||||||
_view->onGLFWCharCallback(window, character);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void onGLFWWindowPosCallback(GLFWwindow* windows, int x, int y)
|
|
||||||
{
|
|
||||||
if (_view)
|
|
||||||
_view->onGLFWWindowPosCallback(windows, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void onGLFWWindowSizeFunCallback(GLFWwindow *window, int width, int height)
|
|
||||||
{
|
|
||||||
if (_view)
|
|
||||||
_view->onGLFWWindowSizeFunCallback(window, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void onGLFWframebuffersize(GLFWwindow *window, int width, int height)
|
|
||||||
{
|
|
||||||
if (_view)
|
|
||||||
_view->onGLFWframebuffersize(window, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setGLViewImpl(GLViewImpl* view)
|
|
||||||
{
|
|
||||||
_view = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void onGLFWWindowIconifyCallback(GLFWwindow* window, int iconified)
|
|
||||||
{
|
|
||||||
if (_view)
|
|
||||||
{
|
|
||||||
_view->onGLFWWindowIconifyCallback(window, iconified);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void onGLFWWindowFocusCallback(GLFWwindow* window, int focused)
|
|
||||||
{
|
|
||||||
if (_view)
|
|
||||||
{
|
|
||||||
_view->onGLFWWindowFocusCallback(window, focused);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
static GLViewImpl* _view;
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_CC_END // end of namespace cocos2d
|
NS_CC_END // end of namespace cocos2d
|
||||||
|
|
|
@ -25,6 +25,64 @@ THE SOFTWARE.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "platform/CCPlatformConfig.h"
|
||||||
|
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||||
|
|
||||||
#include "glad/glad.h"
|
#include "glad/glad.h"
|
||||||
|
|
||||||
|
#if CC_USE_GLES_ON_DESKTOP
|
||||||
|
#undef glClearDepth
|
||||||
|
#undef glMapBuffer
|
||||||
|
#undef glUnmapBuffer
|
||||||
|
#undef glBindVertexArray
|
||||||
|
#undef glDeleteVertexArrays
|
||||||
|
#undef glGenVertexArrays
|
||||||
|
// #undef glBlendFuncSeparate
|
||||||
|
// #undef glBlendEquation
|
||||||
|
#if defined(GL_VERSION_ES_CM_1_0)
|
||||||
|
#undef glIsRenderbuffer
|
||||||
|
#undef glBindRenderbuffer
|
||||||
|
#undef glDeleteRenderbuffers
|
||||||
|
#undef glGenRenderbuffers
|
||||||
|
#undef glRenderbufferStorage
|
||||||
|
#undef glIsFramebuffer
|
||||||
|
#undef glBindFramebuffer
|
||||||
|
#undef glDeleteFramebuffers
|
||||||
|
#undef glGenFramebuffers
|
||||||
|
#undef glCheckFramebufferStatus
|
||||||
|
#undef glFramebufferRenderbuffer
|
||||||
|
#undef glFramebufferTexture2D
|
||||||
|
#undef glGetFramebufferAttachmentParameteriv
|
||||||
|
#undef glGenerateMipmap
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define glClearDepth glClearDepthf
|
||||||
|
#define glMapBuffer glMapBufferOES
|
||||||
|
#define glUnmapBuffer glUnmapBufferOES
|
||||||
|
#define glBindVertexArray glBindVertexArrayOES
|
||||||
|
#define glDeleteVertexArrays glDeleteVertexArraysOES
|
||||||
|
#define glGenVertexArrays glGenVertexArraysOES
|
||||||
|
// #define glBlendFuncSeparate glBlendFuncSeparateOES
|
||||||
|
// #define glBlendEquation glBlendEquationOES
|
||||||
|
#if defined(GL_VERSION_ES_CM_1_0)
|
||||||
|
#define glIsRenderbuffer glIsRenderbufferOES
|
||||||
|
#define glBindRenderbuffer glBindRenderbufferOES
|
||||||
|
#define glDeleteRenderbuffers glDeleteRenderbuffersOES
|
||||||
|
#define glGenRenderbuffers glGenRenderbuffersOES
|
||||||
|
#define glRenderbufferStorage glRenderbufferStorageOES
|
||||||
|
#define glIsFramebuffer glIsFramebufferOES
|
||||||
|
#define glBindFramebuffer glBindFramebufferOES
|
||||||
|
#define glDeleteFramebuffers glDeleteFramebuffersOES
|
||||||
|
#define glGenFramebuffers glGenFramebuffersOES
|
||||||
|
#define glCheckFramebufferStatus glCheckFramebufferStatusOES
|
||||||
|
#define glFramebufferRenderbuffer glFramebufferRenderbufferOES
|
||||||
|
#define glFramebufferTexture2D glFramebufferTexture2DOES
|
||||||
|
#define glGetFramebufferAttachmentParameteriv glGetFramebufferAttachmentParameterivOES
|
||||||
|
#define glGenerateMipmap glGenerateMipmapOES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8
|
#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8
|
||||||
|
|
||||||
|
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace {
|
||||||
ProgramGL::ProgramGL(const std::string& vertexShader, const std::string& fragmentShader)
|
ProgramGL::ProgramGL(const std::string& vertexShader, const std::string& fragmentShader)
|
||||||
: Program(vertexShader, fragmentShader)
|
: Program(vertexShader, fragmentShader)
|
||||||
{
|
{
|
||||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_USE_GLES_ON_DESKTOP
|
||||||
// some device required manually specify the precision qualifiers for vertex shader.
|
// some device required manually specify the precision qualifiers for vertex shader.
|
||||||
_vertexShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newVertexShaderModule(SHADER_PREDEFINE + _vertexShader));
|
_vertexShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newVertexShaderModule(SHADER_PREDEFINE + _vertexShader));
|
||||||
_fragmentShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newFragmentShaderModule(SHADER_PREDEFINE + _fragmentShader));
|
_fragmentShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newFragmentShaderModule(SHADER_PREDEFINE + _fragmentShader));
|
||||||
|
|
Loading…
Reference in New Issue