diff --git a/cocos/2d/cocos2d.h b/cocos/2d/cocos2d.h
index 6fbdd40af6..83bb85f6c7 100644
--- a/cocos/2d/cocos2d.h
+++ b/cocos/2d/cocos2d.h
@@ -175,7 +175,7 @@ THE SOFTWARE.
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#include "platform/win32/CCApplication.h"
- #include "platform/win32/CCEGLView.h"
+ #include "platform/desktop/CCEGLView.h"
#include "platform/win32/CCGL.h"
#include "platform/win32/CCStdC.h"
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters
index b9959484bf..c6e71f9d42 100644
--- a/cocos/2d/cocos2d.vcxproj.filters
+++ b/cocos/2d/cocos2d.vcxproj.filters
@@ -112,6 +112,9 @@
{cba0f362-878c-438b-ad0f-43d287516357}
+
+ {32373f63-2c2d-4eab-bc4a-21745ba0b3fb}
+
@@ -351,9 +354,6 @@
platform\win32
-
- platform\win32
-
platform\win32
@@ -595,6 +595,9 @@
label_nodes
+
+ platform\desktop
+
@@ -852,9 +855,6 @@
platform\win32
-
- platform\win32
-
platform\win32
@@ -1198,5 +1198,8 @@
label_nodes
+
+ platform\desktop
+
\ No newline at end of file
diff --git a/cocos/2d/cocos2d_headers.props b/cocos/2d/cocos2d_headers.props
index 766558aa4b..7691b6685b 100644
--- a/cocos/2d/cocos2d_headers.props
+++ b/cocos/2d/cocos2d_headers.props
@@ -7,7 +7,7 @@
- $(EngineRoot)cocos\2d;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\gui;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath\include;$(EngineRoot)cocos\2d\platform\win32;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES
+ $(EngineRoot)cocos\2d;$(EngineRoot)cocos\2d\renderer;$(EngineRoot)cocos\gui;$(EngineRoot)cocos\base;$(EngineRoot)cocos\physics;$(EngineRoot)cocos\math\kazmath\include;$(EngineRoot)cocos\2d\platform\win32;$(EngineRoot)cocos\2d\platform\desktop;$(EngineRoot)external\glfw3\include\win32;$(EngineRoot)external\win32-specific\gles\include\OGLES
_VARIADIC_MAX=10;%(PreprocessorDefinitions)
diff --git a/cocos/2d/platform/desktop/CCEGLView.cpp b/cocos/2d/platform/desktop/CCEGLView.cpp
index b779925406..30aa4dda34 100644
--- a/cocos/2d/platform/desktop/CCEGLView.cpp
+++ b/cocos/2d/platform/desktop/CCEGLView.cpp
@@ -43,7 +43,7 @@ struct keyCodeItem
EventKeyboard::KeyCode keyCode;
};
-static std::map g_keyCodeMap;
+static std::unordered_map g_keyCodeMap;
static keyCodeItem g_keyCodeStructArray[] = {
/* The unknown key */
@@ -505,10 +505,74 @@ EGLView* EGLView::sharedOpenGLView()
return EGLView::getInstance();
}
+#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
+static bool glew_dynamic_binding()
+{
+ const char *gl_extensions = (const char*)glGetString(GL_EXTENSIONS);
+
+ // If the current opengl driver doesn't have framebuffers methods, check if an extension exists
+ if (glGenFramebuffers == NULL)
+ {
+ log("OpenGL: glGenFramebuffers is NULL, try to detect an extension");
+ if (strstr(gl_extensions, "ARB_framebuffer_object"))
+ {
+ log("OpenGL: ARB_framebuffer_object is supported");
+
+ glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbuffer");
+ glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbuffer");
+ glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffers");
+ glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) wglGetProcAddress("glGenRenderbuffers");
+ glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) wglGetProcAddress("glRenderbufferStorage");
+ glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) wglGetProcAddress("glGetRenderbufferParameteriv");
+ glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) wglGetProcAddress("glIsFramebuffer");
+ glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) wglGetProcAddress("glBindFramebuffer");
+ glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) wglGetProcAddress("glDeleteFramebuffers");
+ glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) wglGetProcAddress("glGenFramebuffers");
+ glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) wglGetProcAddress("glCheckFramebufferStatus");
+ glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) wglGetProcAddress("glFramebufferTexture1D");
+ glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) wglGetProcAddress("glFramebufferTexture2D");
+ glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) wglGetProcAddress("glFramebufferTexture3D");
+ glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) wglGetProcAddress("glFramebufferRenderbuffer");
+ glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) wglGetProcAddress("glGetFramebufferAttachmentParameteriv");
+ glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) wglGetProcAddress("glGenerateMipmap");
+ }
+ else
+ if (strstr(gl_extensions, "EXT_framebuffer_object"))
+ {
+ log("OpenGL: EXT_framebuffer_object is supported");
+ glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) wglGetProcAddress("glIsRenderbufferEXT");
+ glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress("glBindRenderbufferEXT");
+ glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress("glDeleteRenderbuffersEXT");
+ glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) wglGetProcAddress("glGenRenderbuffersEXT");
+ glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) wglGetProcAddress("glRenderbufferStorageEXT");
+ glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) wglGetProcAddress("glGetRenderbufferParameterivEXT");
+ glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) wglGetProcAddress("glIsFramebufferEXT");
+ glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) wglGetProcAddress("glBindFramebufferEXT");
+ glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) wglGetProcAddress("glDeleteFramebuffersEXT");
+ glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) wglGetProcAddress("glGenFramebuffersEXT");
+ glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) wglGetProcAddress("glCheckFramebufferStatusEXT");
+ glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) wglGetProcAddress("glFramebufferTexture1DEXT");
+ glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) wglGetProcAddress("glFramebufferTexture2DEXT");
+ glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) wglGetProcAddress("glFramebufferTexture3DEXT");
+ glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) wglGetProcAddress("glFramebufferRenderbufferEXT");
+ glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) wglGetProcAddress("glGetFramebufferAttachmentParameterivEXT");
+ glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) wglGetProcAddress("glGenerateMipmapEXT");
+ }
+ else
+ {
+ log("OpenGL: No framebuffers extension is supported");
+ log("OpenGL: Any call to Fbo will crash!");
+ return false;
+ }
+ }
+ return true;
+}
+#endif
+
// helper
bool EGLView::initGlew()
{
-#if CC_TARGET_PLATFORM == CC_PLATFORM_LINUX
+#if (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
GLenum GlewInitResult = glewInit();
if (GLEW_OK != GlewInitResult)
{
@@ -534,13 +598,18 @@ bool EGLView::initGlew()
log("OpenGL 2.0 not supported");
}
-// if(glew_dynamic_binding() == false)
-// {
-// MessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error");
-// return false;
-// }
+#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
+ if(glew_dynamic_binding() == false)
+ {
+ MessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error");
+ return false;
+ }
-#endif // Linux
+ // Enable point size by default on windows.
+ glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
+#endif
+
+#endif // (CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
return true;
}