在Visual C++下,我玩过Glut/FreeGlut/GLFW.似乎这些项目的每个人都默认添加了一个CMD窗口.我尝试将其移除:
属性 - > C/C++ - >预处理器 - >预处理器定义
从这里,我删除_CONSOLE并将其替换为_WINDOWS
然后我去了:
属性 - >连接器 - >系统 - >子系统
我将选项设置为Windows(/ SUBSYSTEM:WINDOWS)
然后当我尝试在GLFW下编译时,我得到以下构建错误:
错误1错误LNK2001:未解析的外部符号_WinMain @ 16 MSVCRT.lib
错误2致命错误LNK1120:1未解析的外部glfwWindow.exe
是否可以删除控制台窗口?
我已经读过这篇文章,但这对我来说似乎是一个不同的问题.
在makefile中运行的命令是,
g++ -o main main.cpp -lglfw -framework Cocoa -framework OpenGL
Run Code Online (Sandbox Code Playgroud)
我运行makefile时收到的错误是,
Undefined symbols for architecture x86_64:
"_IOMasterPort", referenced from:
__glfwInitJoysticks in libglfw.a(cocoa_joystick.o)
"_IOServiceMatching", referenced from:
__glfwInitJoysticks in libglfw.a(cocoa_joystick.o)
"_IOServiceGetMatchingServices", referenced from:
__glfwInitJoysticks in libglfw.a(cocoa_joystick.o)
"_IOIteratorNext", referenced from:
__glfwInitJoysticks in libglfw.a(cocoa_joystick.o)
"_IORegistryEntryCreateCFProperties", referenced from:
__glfwInitJoysticks in libglfw.a(cocoa_joystick.o)
"_IOCreatePlugInInterfaceForService", referenced from:
__glfwInitJoysticks in libglfw.a(cocoa_joystick.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [all] Error 1
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Visual C++ 2008(Windows 7)中的GLFW设置OpenGL项目.我已将GLFW include和library目录添加到项目的include和library路径中,并且我已将以下内容添加到其他依赖项中:
GLFW.lib glu32.lib opengl32.lib
Run Code Online (Sandbox Code Playgroud)
这就是我需要做的一切,不是吗?但是当我尝试编译任何OpenGl程序时(除了一个只使用glClear清除屏幕的非常简单的程序)我得到一堆未声明的标识符和标识符未找到错误.知道为什么会这样吗?这是完整的错误列表:
1>Compiling...
1>main.cpp
1>c:\glfw-2.7.3\opengl ikasi\main.cpp(9) : error C2146: syntax error : missing ';' before identifier 'VBO'
1>c:\glfw-2.7.3\opengl ikasi\main.cpp(9) : error C2377: 'GLuint' : redefinition; typedef cannot be overloaded with any other symbol
1> c:\program files\microsoft sdks\windows\v6.0a\include\gl\gl.h(52) : see declaration of 'GLuint'
1>c:\glfw-2.7.3\opengl ikasi\main.cpp(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\glfw-2.7.3\opengl ikasi\main.cpp(43) : error C3861: 'glEnableVertexAttribArray': identifier not found
1>c:\glfw-2.7.3\opengl ikasi\main.cpp(45) : error C2065: …Run Code Online (Sandbox Code Playgroud) 我正在使用Mac,我已经编译并安装了FreeGlut,但我似乎无法使用它获得OpenGL 3.2上下文.但是,在使用GLFW时,我可以毫无问题地获得它.所以在GLFW中,这段代码完全正常:
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwOpenWindow(500, 500, 8, 8, 8, 8, 24, 8, GLFW_WINDOW)
Run Code Online (Sandbox Code Playgroud)
但是使用FreeGlut,这段代码失败了(打开glutCreateWindow):
glutInitContextVersion (3, 2);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutInitWindowSize (width, height);
glutInitWindowPosition (300, 200);
int window = glutCreateWindow (argv[0]);
Run Code Online (Sandbox Code Playgroud)
它失败的错误是:
X Error of failed request: BadRequest (invalid request code or no such operation)
Major opcode of failed request: 34 (X_UngrabKey)
Serial number of failed request: 29
Current serial number in output stream: 29
Run Code Online (Sandbox Code Playgroud)
我在MacOS X 10.8 Mountain Lion上运行,使用Intel HD4000显卡,安装了XQuartz作为我的X11服务器,并从源代码编译和安装了FreeGlut 2.8.
有谁知道可能是什么问题?
我已经开始在单独的线程上进入稍微压倒性的OpenGL资源加载场景,因此主线程可以继续渲染对象.介入时,我注意到GLFW在一个月后发布了更新版本,更容易进行上下文管理.
但是,使用glfwMakeContextCurrent()我无法实现这一点.在加载线程中我使用此函数,在完成后我再次添加它,以便主线程接收上下文以供进一步使用.这不允许我创建和编译着色器或任何其他OpenGL相关的创建.
更新:
需要做什么才能在这种情况下使用GLFW?由于GLFW是可移植的,我很乐意使用包含它的代码.我不知道准备一个保持GLFW API的线程的必要步骤.
正如这篇博客文章所述,我需要创建两个带有OpenGL上下文的线程(不是相同的上下文; D),然后共享信息.但是,显示的说明是特定于平台的.那么我如何才能使用GLFW,以便示例中的步骤尽可能与平台无关?
我一直在互联网上,我根本找不到安装GLFW for OSX的方法,并将其与Xcode一起使用.很多文章使用cmake,我试图安装,但我仍然无法从终端访问它.
我只需要一个简单的分步指南来安装它,因为我会失去理智.
谢谢
GLFW的首字母缩写词代表什么?http://www.glfw.org/是主要网站,但我找不到任何线索.在SO上它有一个标签,但在描述中没有解释首字母缩略词.
我开始学习OpenGL(glfw)并从教程中复制源代码并尝试编译它,但是发生了错误.我想我已经corectly安装了所有头文件(glm,glfw等)
这是我的来源(我没有在头文件中使用这些字符:<,>):
#include iostream
#include stdio.h
#include stdlib.h
#include GL/glew.h
#include GLFW/glfw3.h
#include glm/glm.hpp
#define GLFW_INCLUDE_GL_3
using namespace glm;
using namespace std;
int main(){
if(!glfwInit()){
return -1;
}
GLFWwindow* window; // (In the accompanying source code, this variable is global)
window = glfwCreateWindow( 1024, 768, "Tutorial 01", NULL, NULL);
if( window == NULL ) {
fprintf( stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n" …Run Code Online (Sandbox Code Playgroud) 我用gcc/mingw在eclipse cdt(c ++)中安装了glew,glfw和glm,这些都是静态的.一切正常,但我不喜欢eclipse输出控制台中的警告:
警告:在def文件末尾损坏.drectve
我如何修复和隐藏此警告?这是什么意思 ?
我注意到的是,只有当我调用'glewInit'函数时才会出现此警告.
每当我调整GLFW窗口大小时,在调整窗口大小时都不会绘制。我调整窗口大小后,才可以绘制窗口新暴露的部分。您可以在下面的图片中自己看到它:

这是我的应用程序的代码。我在Visual Studio 2015上运行Windows 10
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void processInput(GLFWwindow *window);
void get_resolution(int* window_width, int* window_height);
void initGlfwSettings();
GLFWwindow* initGlfwWindow();
void initGlad();
// settings
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;
int main()
{
initGlfwSettings();
GLFWwindow* window = initGlfwWindow();
initGlad();
// glad: load all OpenGL function pointers
// ---------------------------------------
// render loop
// -----------
while (!glfwWindowShouldClose(window))
{
int width, height;
glfwGetWindowSize(window, &width, &height);
glClearColor(0.2f, 0.3f, …Run Code Online (Sandbox Code Playgroud)