【发布时间】:2016-06-11 11:28:52
【问题描述】:
我正在尝试将 glew_mx 项目从 windows 移植到 ubuntu,但由于 GLEWContext 未定义,我总是遇到错误。
error: ‘GLEWContext’ does not name a type
我知道我真的不需要在 linux 上使用 GLEWContext,但是我必须定义
GLEWContext* glewGetContext();
为了编译我的项目。所以我创建了一个全局 GLEWContext 并在 glewGetContext 中简单地返回它。
我的 window.h 代码如下所示:
#pragma once
#define GLEW_MX
#define GLEW_STATIC
#include "GL/glew.h"
#include "GLFW/glfw3.h"
#define GLM_SWIZZLE
#include "glm/glm.hpp"
#include "glm/ext.hpp"
#ifdef _WIN32
#define CONTEXT_PREFIX window
#else
#define CONTEXT_PREFIX
#endif
namespace window
{
class Window
{
public:
Window() {}
~Window() {}
//...
#ifdef _WIN32
static void makeContextCurrent(Window* window_handle);
#endif
static Window* createWindow(int win_width, int win_height, const std::string& title, GLFWmonitor* monitor, Window* share);
GLFWwindow* window;
#ifdef _WIN32
GLEWContext* glew_context;
#endif
//...
private:
//...
};
GLEWContext* glewGetContext();
#ifdef _WIN32
//...
#else
GLEWContext* glew_context;
#endif
}
window.cpp 中的代码如下所示:
#ifdef _WIN32
GLEWContext* window::glewGetContext()
{
//...
}
#else
GLEWContext* window::glewGetContext()
{
return glew_context;
}
#endif
编译window.h最后两行时出现错误 非常感谢您的帮助
【问题讨论】: