issue #2640: glfw linux version

This commit is contained in:
Huabing.Xu 2013-08-28 12:00:06 +08:00
parent 3bc5f1ed8a
commit 29746d513a
7 changed files with 2680 additions and 288 deletions

View File

@ -10,6 +10,7 @@
#include <string> #include <string>
#include "CCDirector.h" #include "CCDirector.h"
#include "platform/CCFileUtils.h" #include "platform/CCFileUtils.h"
#include "CCEGLView.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -47,16 +48,19 @@ int Application::run()
return 0; return 0;
} }
EGLView* pMainWnd = EGLView::getInstance();
for (;;) { while (!pMainWnd->windowShouldClose())
{
long iLastTime = getCurrentMillSecond(); long iLastTime = getCurrentMillSecond();
Director::getInstance()->mainLoop(); Director::getInstance()->mainLoop();
pMainWnd->pollEvents();
long iCurTime = getCurrentMillSecond(); long iCurTime = getCurrentMillSecond();
if (iCurTime-iLastTime<_animationInterval){ if (iCurTime-iLastTime<_animationInterval){
usleep((_animationInterval - iCurTime+iLastTime)*1000); usleep((_animationInterval - iCurTime+iLastTime)*1000);
} }
} }
return -1; return -1;
} }

View File

@ -15,261 +15,131 @@
#include "keyboard_dispatcher/CCKeyboardDispatcher.h" #include "keyboard_dispatcher/CCKeyboardDispatcher.h"
#include <unistd.h> #include <unistd.h>
bool initExtensions() NS_CC_BEGIN
//begin EGLViewEventHandler
class EGLViewEventHandler
{ {
// Do nothing, on Linux we use GLEW. public:
static bool s_captured;
static float s_mouseX;
static float s_mouseY;
static void OnGLFWError(int errorID, const char* errorDesc);
static void OnGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify);
static void OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y);
};
bool EGLViewEventHandler::s_captured = false;
float EGLViewEventHandler::s_mouseX = 0;
float EGLViewEventHandler::s_mouseY = 0;
void EGLViewEventHandler::OnGLFWError(int errorID, const char* errorDesc)
{
CCLOGERROR("GLFWError #%d Happen, %s\n", errorID, errorDesc);
} }
NS_CC_BEGIN void EGLViewEventHandler::OnGLFWMouseCallBack(GLFWwindow* window, int button, int action, int modify)
{
EGLView* eglView = EGLView::getInstance();
if(nullptr == eglView) return;
if(GLFW_MOUSE_BUTTON_LEFT == button)
{
if(GLFW_PRESS == action)
{
s_captured = true;
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
{
int id = 0;
eglView->handleTouchesBegin(1, &id, &s_mouseX, &s_mouseY);
}
}
else if(GLFW_RELEASE == action)
{
s_captured = false;
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,s_mouseY)))
{
int id = 0;
eglView->handleTouchesEnd(1, &id, &s_mouseX, &s_mouseY);
}
}
}
}
void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
{
s_mouseX = (float)x;
s_mouseY = (float)y;
EGLView* eglView = EGLView::getInstance();
if(nullptr == eglView) return;
s_mouseX /= eglView->getFrameZoomFactor();
s_mouseY /= eglView->getFrameZoomFactor();
if(s_captured)
{
if (eglView->getViewPortRect().equals(Rect::ZERO) || eglView->getViewPortRect().containsPoint(Point(s_mouseX,eglView->getFrameSize().height - s_mouseY)))
{
int id = 0;
eglView->handleTouchesMove(1, &id, &s_mouseX, &s_mouseY);
}
}
}
//end EGLViewEventHandler
//////////////////////////////////////////////////////////////////////////
// impliment EGLView
//////////////////////////////////////////////////////////////////////////
EGLView* EGLView::s_pEglView = nullptr;
EGLView::EGLView() EGLView::EGLView()
: _wasInit(false) : _captured(false)
, _frameZoomFactor(1.0f) , _frameZoomFactor(1.0f)
,_window(nullptr) , _supportTouch(false)
,_context(nullptr) , _mainWindow(nullptr)
{ {
CCASSERT(nullptr == s_pEglView, "EGLView is singleton, Should be inited only one time\n");
s_pEglView = this;
strcpy(_viewName, "Cocos2dxWin32");
glfwSetErrorCallback(EGLViewEventHandler::OnGLFWError);
glfwInit();
} }
EGLView::~EGLView() EGLView::~EGLView()
{ {
glfwTerminate();
s_pEglView = nullptr;
} }
static std::string getApplicationName() bool EGLView::create()
{ {
char fullpath[256] = {0}; if(nullptr != _mainWindow) return true;
ssize_t length = readlink("/proc/self/exe", fullpath, sizeof(fullpath)-1); glfwWindowHint(GLFW_RESIZABLE,GL_FALSE);
_mainWindow = glfwCreateWindow(_screenSize.width, _screenSize.height, _viewName, nullptr, nullptr);
glfwMakeContextCurrent(_mainWindow);
glfwSetMouseButtonCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseCallBack);
glfwSetCursorPosCallback(_mainWindow,EGLViewEventHandler::OnGLFWMouseMoveCallBack);
if (length <= 0) { // check OpenGL version at first
return "Cocos2dx-Linux"; const GLubyte* glVersion = glGetString(GL_VERSION);
} CCLOG("OpenGL version = %s", glVersion);
fullpath[length] = '\0'; if ( atof((const char*)glVersion) < 1.5 )
const std::string appPath = fullpath;
return appPath.substr(appPath.find_last_of('/') + 1);
}
void checkSDLError(int line)
{
#if COCOS2D_DEBUG > 0
const char *error = SDL_GetError();
if (*error != '\0')
{ {
if (line != -1) char strComplain[256] = {0};
CCLOG("SDL Error: %s, line: %i", error, line); sprintf(strComplain,
else "OpenGL 1.5 or higher is required (your version is %s). Please upgrade the driver of your video card.",
CCLOG("SDL Error: %s", error); glVersion);
SDL_ClearError(); MessageBox(strComplain, "OpenGL version too old");
} return false;
#endif
}
void EGLView::setFrameSize(float width, float height)
{
bool eResult = false;
//create the window by SDL2.
//check
CCAssert(width!=0&&height!=0, "invalid window's size equal 0");
//Inits SDL2
eResult = SDL_Init(SDL_INIT_VIDEO) == 0;
if (!eResult) {
CCAssert(0, "fail to init the SDL");
} }
const std::string appName = getApplicationName();
const int iDepth = 16; // set default value
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
_window = SDL_CreateWindow(appName.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
width, height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, iDepth);
checkSDLError(__LINE__);
_context = SDL_GL_CreateContext(_window);
if (!_window || !_context) {
CCAssert(0, "Failed to initialize OpenGL context");
} else {
SDL_GL_SetSwapInterval(1);
checkSDLError(__LINE__);
_wasInit = true;
EGLViewProtocol::setFrameSize(width, height);
initGL();
if (!GLEW_ARB_framebuffer_object)
CCAssert(0, "fail to init OpenGL extension ARB_framebuffer_object");
if (!GLEW_ARB_vertex_buffer_object)
CCAssert(0, "fail to init OpenGL extension ARB_vertex_buffer_object");
}
}
void EGLView::setFrameZoomFactor(float fZoomFactor)
{
_frameZoomFactor = fZoomFactor;
SDL_SetWindowSize(_window, _screenSize.width * fZoomFactor, _screenSize.height * fZoomFactor);
Director::getInstance()->setProjection(Director::getInstance()->getProjection());
}
float EGLView::getFrameZoomFactor()
{
return _frameZoomFactor;
}
void EGLView::setViewPortInPoints(float x , float y , float w , float h)
{
glViewport((GLint)(x * _scaleX * _frameZoomFactor+ _viewPortRect.origin.x * _frameZoomFactor),
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
(GLsizei)(w * _scaleX * _frameZoomFactor),
(GLsizei)(h * _scaleY * _frameZoomFactor));
}
void EGLView::setScissorInPoints(float x , float y , float w , float h)
{
glScissor((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
(GLsizei)(w * _scaleX * _frameZoomFactor),
(GLsizei)(h * _scaleY * _frameZoomFactor));
}
bool EGLView::isOpenGLReady()
{
return _wasInit;
}
void EGLView::end()
{
SDL_GL_DeleteContext(_context);
SDL_DestroyWindow(_window);
SDL_Quit();
delete this;
exit(0);
}
void EGLView::swapBuffers() {
if (_wasInit) {
/* Swap buffers */
SDL_GL_SwapWindow(_window);
}
}
// Polls events if SDL backend is on.
// Note that finger events allow multi-touch on Linux, but libsdl with X11
// backend does not support multitouch. However multitouch should work
// out of the box on upcoming Weston and Mir display servers.
// Also supports mouse touches emulation, keyboard events, text events.
void EGLView::pollInputEvents()
{
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
Director::sharedDirector()->end();
break;
case SDL_MOUSEBUTTONDOWN:
if (event.button.button == SDL_BUTTON_LEFT) {
int id = event.button.which;
_pressedMouseInstances.insert(id);
Point oPoint((float)event.button.x, (float)event.button.y);
oPoint.x /= _frameZoomFactor;
oPoint.y /= _frameZoomFactor;
handleTouchesBegin(1, &id, &oPoint.x, &oPoint.y);
}
break;
case SDL_MOUSEBUTTONUP:
if (event.button.button == SDL_BUTTON_LEFT) {
int id = event.button.which;
_pressedMouseInstances.erase(id);
Point oPoint((float)event.button.x, (float)event.button.y);
oPoint.x /= _frameZoomFactor;
oPoint.y /= _frameZoomFactor;
handleTouchesEnd(1, &id, &oPoint.x, &oPoint.y);
}
break;
case SDL_MOUSEMOTION:
if (_pressedMouseInstances.count(event.motion.which)) {
int id = event.motion.which;
Point oPoint((float)event.motion.x, (float)event.motion.y);
oPoint.x /= _frameZoomFactor;
oPoint.y /= _frameZoomFactor;
handleTouchesMove(1, &id, &oPoint.x, &oPoint.y);
}
break;
case SDL_FINGERDOWN: {
int fingerId = event.tfinger.fingerId;
Point oPoint((float)event.tfinger.x, (float)event.tfinger.y);
oPoint.x /= _frameZoomFactor;
oPoint.y /= _frameZoomFactor;
handleTouchesBegin(1, &fingerId, &oPoint.x, &oPoint.y);
}
break;
case SDL_FINGERUP: {
int fingerId = event.tfinger.fingerId;
Point oPoint((float)event.tfinger.x, (float)event.tfinger.y);
oPoint.x /= _frameZoomFactor;
oPoint.y /= _frameZoomFactor;
handleTouchesEnd(1, &fingerId, &oPoint.x, &oPoint.y);
break;
}
case SDL_FINGERMOTION: {
int fingerId = event.tfinger.fingerId;
Point oPoint((float)event.tfinger.x, (float)event.tfinger.y);
oPoint.x /= _frameZoomFactor;
oPoint.y /= _frameZoomFactor;
handleTouchesMove(1, &fingerId, &oPoint.x, &oPoint.y);
}
break;
case SDL_TEXTINPUT: {
const std::string text = event.text.text;
IMEDispatcher::sharedDispatcher()->dispatchInsertText(text.c_str(), text.size());
}
break;
case SDL_TEXTEDITING:
// TODO: not implemented.
// In SDL text editing is similar to patching. Each patch consists of
// selected text range and string that replaces selected text.
break;
case SDL_KEYDOWN: {
if (event.key.keysym.sym == SDLK_BACKSPACE)
IMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
Director::sharedDirector()->getKeyboardDispatcher()->dispatchKeyboardEvent(event.key.keysym.sym, true);
break;
case SDL_KEYUP:
Director::sharedDirector()->getKeyboardDispatcher()->dispatchKeyboardEvent(event.key.keysym.sym, false);
}
break;
}
}
}
void EGLView::setIMEKeyboardState(bool bOpen)
{
_IMEKeyboardOpened = bOpen;
Rect zeroRect(0, 0, 0, 0);
IMEKeyboardNotificationInfo info;
info.begin = zeroRect;
info.end = zeroRect;
info.duration = 0;
if (bOpen) {
IMEDispatcher::sharedDispatcher()->dispatchKeyboardWillShow(info);
IMEDispatcher::sharedDispatcher()->dispatchKeyboardDidShow(info);
} else {
IMEDispatcher::sharedDispatcher()->dispatchKeyboardWillHide(info);
IMEDispatcher::sharedDispatcher()->dispatchKeyboardDidHide(info);
}
}
bool EGLView::initGL()
{
GLenum GlewInitResult = glewInit(); GLenum GlewInitResult = glewInit();
if (GLEW_OK != GlewInitResult) if (GLEW_OK != GlewInitResult)
{ {
fprintf(stderr,"ERROR: %s\n",glewGetErrorString(GlewInitResult)); MessageBox((char *)glewGetErrorString(GlewInitResult), "OpenGL error");
return false; return false;
} }
@ -291,23 +161,88 @@ bool EGLView::initGL()
log("OpenGL 2.0 not supported"); log("OpenGL 2.0 not supported");
} }
// Enable point size by default on linux. // if(glew_dynamic_binding() == false)
// {
// MessageBox("No OpenGL framebuffer support. Please upgrade the driver of your video card.", "OpenGL error");
// return false;
// }
//
// Enable point size by default on windows.
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
return true; return true;
} }
void EGLView::destroyGL() bool EGLView::isOpenGLReady()
{ {
return nullptr != _mainWindow;
}
void EGLView::end()
{
if(_mainWindow)
glfwSetWindowShouldClose(_mainWindow,1);
}
void EGLView::swapBuffers()
{
if(_mainWindow)
glfwSwapBuffers(_mainWindow);
}
bool EGLView::windowShouldClose()
{
if(_mainWindow)
return glfwWindowShouldClose(_mainWindow);
else
return true;
}
void EGLView::pollEvents()
{
glfwPollEvents();
}
void EGLView::setIMEKeyboardState(bool /*bOpen*/)
{
}
void EGLView::setFrameZoomFactor(float fZoomFactor)
{
_frameZoomFactor = fZoomFactor;
Director::getInstance()->setProjection(Director::getInstance()->getProjection());
}
float EGLView::getFrameZoomFactor()
{
return _frameZoomFactor;
}
void EGLView::setFrameSize(float width, float height)
{
EGLViewProtocol::setFrameSize(width, height);
}
void EGLView::setViewPortInPoints(float x , float y , float w , float h)
{
glViewport((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
(GLsizei)(w * _scaleX * _frameZoomFactor),
(GLsizei)(h * _scaleY * _frameZoomFactor));
}
void EGLView::setScissorInPoints(float x , float y , float w , float h)
{
glScissor((GLint)(x * _scaleX * _frameZoomFactor + _viewPortRect.origin.x * _frameZoomFactor),
(GLint)(y * _scaleY * _frameZoomFactor + _viewPortRect.origin.y * _frameZoomFactor),
(GLsizei)(w * _scaleX * _frameZoomFactor),
(GLsizei)(h * _scaleY * _frameZoomFactor));
} }
EGLView* EGLView::getInstance() EGLView* EGLView::getInstance()
{ {
static EGLView* s_pEglView = NULL; CCASSERT(nullptr != s_pEglView, "EGL singleton should not be null");
if (s_pEglView == NULL)
{
s_pEglView = new EGLView();
}
return s_pEglView; return s_pEglView;
} }

View File

@ -11,6 +11,7 @@
#include "platform/CCCommon.h" #include "platform/CCCommon.h"
#include "cocoa/CCGeometry.h" #include "cocoa/CCGeometry.h"
#include "platform/CCEGLViewProtocol.h" #include "platform/CCEGLViewProtocol.h"
#include "platform/third_party/linux/glfw/glfw3.h"
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <set> #include <set>
@ -18,36 +19,36 @@ bool initExtensions();
NS_CC_BEGIN NS_CC_BEGIN
class EGLView : public EGLViewProtocol{ class CC_DLL EGLView : public EGLViewProtocol
{
public: public:
EGLView(); EGLView();
virtual ~EGLView(); virtual ~EGLView();
friend void keyEventHandle(int,int); /* override functions */
friend void mouseButtonEventHandle(int,int); virtual bool isOpenGLReady();
friend void mousePosEventHandle(int,int); virtual void end();
friend void charEventHandle(int,int); virtual void swapBuffers();
/**
* iPixelWidth, height: the window's size
* iWidth ,height: the point size, which may scale.
* iDepth is not the buffer depth of opengl, it indicate how may bits for a pixel
*/
virtual void setFrameSize(float width, float height); virtual void setFrameSize(float width, float height);
virtual void setViewPortInPoints(float x , float y , float w , float h); virtual void setIMEKeyboardState(bool bOpen);
virtual void setScissorInPoints(float x , float y , float w , float h);
//void setWndProc(CUSTOM_WND_PROC proc);
virtual bool create();
public:
//void resize(int width, int height);
/* /*
* Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop. * Set zoom factor for frame. This method is for debugging big resolution (e.g.new ipad) app on desktop.
*/ */
void setFrameZoomFactor(float fZoomFactor); void setFrameZoomFactor(float fZoomFactor);
float getFrameZoomFactor(); float getFrameZoomFactor();
virtual bool isOpenGLReady(); //void centerWindow();
virtual void end();
virtual void swapBuffers();
virtual void pollInputEvents();
virtual void setIMEKeyboardState(bool bOpen);
virtual void setViewPortInPoints(float x , float y , float w , float h);
virtual void setScissorInPoints(float x , float y , float w , float h);
// static function
/** /**
@brief get the shared main open gl window @brief get the shared main open gl window
*/ */
@ -55,21 +56,21 @@ public:
/** @deprecated Use getInstance() instead */ /** @deprecated Use getInstance() instead */
CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView(); CC_DEPRECATED_ATTRIBUTE static EGLView* sharedOpenGLView();
protected:
private: private:
bool initGL(); bool _captured;
void destroyGL(); bool _supportTouch;
//store current mouse point for moving, valid if and only if the mouse pressed
Point _mousePoint;
bool _wasInit;
float _frameZoomFactor; float _frameZoomFactor;
static EGLView* s_pEglView;
public:
bool windowShouldClose();
SDL_Window *_window; void pollEvents();
SDL_GLContext _context; GLFWwindow* getWindow() const { return _mainWindow; }
// Several mouse instances are possible. private:
std::set<int> _pressedMouseInstances; GLFWwindow* _mainWindow;
bool _IMEKeyboardOpened;
}; };
NS_CC_END NS_CC_END

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,181 @@
/*************************************************************************
* GLFW - An OpenGL library
* API version: 3.0
* WWW: http://www.glfw.org/
*------------------------------------------------------------------------
* Copyright (c) 2002-2006 Marcus Geelnard
* Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would
* be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not
* be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*
*************************************************************************/
#ifndef _glfw3_native_h_
#define _glfw3_native_h_
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************
* Doxygen documentation
*************************************************************************/
/*! @defgroup native Native access
*
* **By using the native API, you assert that you know what you are doing and
* how to fix problems caused by using it. If you don't, you shouldn't be
* using it.**
*
* Before the inclusion of @ref glfw3native.h, you must define exactly one
* window API macro and exactly one context API macro. Failure to do this
* will cause a compile-time error.
*
* The available window API macros are:
* * `GLFW_EXPOSE_NATIVE_WIN32`
* * `GLFW_EXPOSE_NATIVE_COCOA`
* * `GLFW_EXPOSE_NATIVE_X11`
*
* The available context API macros are:
* * `GLFW_EXPOSE_NATIVE_WGL`
* * `GLFW_EXPOSE_NATIVE_NSGL`
* * `GLFW_EXPOSE_NATIVE_GLX`
* * `GLFW_EXPOSE_NATIVE_EGL`
*
* These macros select which of the native access functions that are declared
* and which platform-specific headers to include. It is then up your (by
* definition platform-specific) code to handle which of these should be
* defined.
*/
/*************************************************************************
* System headers and types
*************************************************************************/
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
#include <windows.h>
#elif defined(GLFW_EXPOSE_NATIVE_COCOA)
#if defined(__OBJC__)
#import <Cocoa/Cocoa.h>
#else
typedef void* id;
#endif
#elif defined(GLFW_EXPOSE_NATIVE_X11)
#include <X11/Xlib.h>
#else
#error "No window API specified"
#endif
#if defined(GLFW_EXPOSE_NATIVE_WGL)
/* WGL is declared by windows.h */
#elif defined(GLFW_EXPOSE_NATIVE_NSGL)
/* NSGL is declared by Cocoa.h */
#elif defined(GLFW_EXPOSE_NATIVE_GLX)
#include <GL/glx.h>
#elif defined(GLFW_EXPOSE_NATIVE_EGL)
#include <EGL/egl.h>
#else
#error "No context API specified"
#endif
/*************************************************************************
* Functions
*************************************************************************/
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
/*! @brief Returns the `HWND` of the specified window.
* @return The `HWND` of the specified window.
* @ingroup native
*/
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_WGL)
/*! @brief Returns the `HGLRC` of the specified window.
* @return The `HGLRC` of the specified window.
* @ingroup native
*/
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_COCOA)
/*! @brief Returns the `NSWindow` of the specified window.
* @return The `NSWindow` of the specified window.
* @ingroup native
*/
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
/*! @brief Returns the `NSOpenGLContext` of the specified window.
* @return The `NSOpenGLContext` of the specified window.
* @ingroup native
*/
GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_X11)
/*! @brief Returns the `Display` used by GLFW.
* @return The `Display` used by GLFW.
* @ingroup native
*/
GLFWAPI Display* glfwGetX11Display(void);
/*! @brief Returns the `Window` of the specified window.
* @return The `Window` of the specified window.
* @ingroup native
*/
GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_GLX)
/*! @brief Returns the `GLXContext` of the specified window.
* @return The `GLXContext` of the specified window.
* @ingroup native
*/
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
#endif
#if defined(GLFW_EXPOSE_NATIVE_EGL)
/*! @brief Returns the `EGLDisplay` used by GLFW.
* @return The `EGLDisplay` used by GLFW.
* @ingroup native
*/
GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
/*! @brief Returns the `EGLContext` of the specified window.
* @return The `EGLContext` of the specified window.
* @ingroup native
*/
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
/*! @brief Returns the `EGLSurface` of the specified window.
* @return The `EGLSurface` of the specified window.
* @ingroup native
*/
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _glfw3_native_h_ */

View File

@ -120,7 +120,7 @@ SHAREDLIBS += -lfmodex
endif endif
endif endif
SHAREDLIBS += -lSDL2 -lGLEW -lfontconfig -lpthread -lGL -lpng SHAREDLIBS += -lSDL2 -lGLEW -lfontconfig -lpthread -lGL -lpng `pkg-config --libs glfw3`
SHAREDLIBS += -L$(FMOD_LIBDIR) -Wl,-rpath,$(abspath $(FMOD_LIBDIR)) SHAREDLIBS += -L$(FMOD_LIBDIR) -Wl,-rpath,$(abspath $(FMOD_LIBDIR))
SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(abspath $(LIB_DIR)) SHAREDLIBS += -L$(LIB_DIR) -Wl,-rpath,$(abspath $(LIB_DIR))

View File

@ -13,7 +13,9 @@ int main(int argc, char **argv)
{ {
// create the application instance // create the application instance
AppDelegate app; AppDelegate app;
EGLView* eglView = EGLView::getInstance(); EGLView* eglView = new EGLView();
eglView->setFrameSize(800, 480); eglView->setViewName("TestCpp");
eglView->setFrameSize(900, 640);
eglView->create();
return Application::getInstance()->run(); return Application::getInstance()->run();
} }