C++ ';GLEWContext没有命名类型';ubuntu错误
我试图将一个glew_mx项目从windows移植到ubuntu,但由于GLEWContext未定义,我总是会出错C++ ';GLEWContext没有命名类型';ubuntu错误,c++,ubuntu,opengl,glew,C++,Ubuntu,Opengl,Glew,我试图将一个glew_mx项目从windows移植到ubuntu,但由于GLEWContext未定义,我总是会出错 error: ‘GLEWContext’ does not name a type 我知道在linux上我并不真的需要GLEWContext,但是我必须定义它 GLEWContext* glewGetContext(); 为了编译我的项目。因此,我创建了一个全局GLEWContext,并在glewGetContext中简单地返回它 我的window.h代码如下所示: #prag
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
}
#ifdef _WIN32
GLEWContext* window::glewGetContext()
{
//...
}
#else
GLEWContext* window::glewGetContext()
{
return glew_context;
}
#endif
window.cpp中的代码如下所示:
#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
}
#ifdef _WIN32
GLEWContext* window::glewGetContext()
{
//...
}
#else
GLEWContext* window::glewGetContext()
{
return glew_context;
}
#endif
编译window.h中的最后两行时出错
非常感谢您的帮助编译器似乎编译了您的
窗口
类并进入GLEWContext*glew\u上下文
行。但是可能没有定义GLEWContext
,因此可能会有所帮助
由于您要从windows移植到ubuntu,因此必须确保编译器支持#pragma
。您可以将您的防护罩更改为
#ifndef WINDOW_H
#define WINDOW_H
// Your code here
#endif