GLFW与GLES在简单的c++ Emscripten文件不会构建
opengl es 2.0 - GLFW with GLES in simple C++ Emscripten file wont build
我试图设置一个OpenGL上下文与窗口和viewport使用最小的代码来做到这一点与emscripten。
我已经开始编码了,这是以下代码:
#include<stdio.h>
#include<stdlib.h>
#include<GLES2/gl2.h>
#include<GL/glfw.h>
#include<emscripten/emscripten.h>
int init_gl()
{
const int width = 480,
height = 800;
if (glfwInit() != GL_TRUE) {
printf("glfwInit() failedn");
return GL_FALSE;
}
if (glfwOpenWindow(width, height, 8, 8, 8, 8, 16, 0, GLFW_WINDOW) != GL_TRUE) {
printf("glfwOpenWindow() failedn");
return GL_FALSE;
}
return GL_TRUE;
}
void do_frame()
{
glfwSwapBuffers();
}
void shutdown_gl()
{
glfwTerminate();
}
int main() {
printf("hello GL testn");
if (init_gl() == GL_TRUE) {
printf("initGL was true!n");
emscripten_set_main_loop(do_frame, 0, 1);
} else {
printf("could not init GLn");
}
shutdown_gl();
return 0;
}
当我尝试使用emscripten 1.30.0构建它时,我得到以下错误:
Someones-MacBook:1.30.0 igloomedialtd$ ./emcc ~/Desktop/myGLTest.cpp -o hello.html
In file included from /Users/igloomedialtd/Desktop/myGLTest.cpp:4:
In file included from /Users/igloomedialtd/emsdk_portable/emscripten/1.30.0/system/include/GL/glfw.h:176:
In file included from /Users/igloomedialtd/emsdk_portable/emscripten/1.30.0/system/include/GL/gl.h:2091:
/Users/igloomedialtd/emsdk_portable/emscripten/1.30.0/system/include/GL/glext.h:5072:19: error:
typedef redefinition with different types ('ptrdiff_t' (aka 'int') vs
'khronos_intptr_t' (aka 'long'))
typedef ptrdiff_t GLintptr;
^
/Users/igloomedialtd/emsdk_portable/emscripten/1.30.0/system/include/GLES2/gl2.h:38:26: note:
previous definition is here
typedef khronos_intptr_t GLintptr;
^
In file included from /Users/igloomedialtd/Desktop/myGLTest.cpp:4:
In file included from /Users/igloomedialtd/emsdk_portable/emscripten/1.30.0/system/include/GL/glfw.h:176:
In file included from /Users/igloomedialtd/emsdk_portable/emscripten/1.30.0/system/include/GL/gl.h:2091:
/Users/igloomedialtd/emsdk_portable/emscripten/1.30.0/system/include/GL/glext.h:5073:19: error:
typedef redefinition with different types ('ptrdiff_t' (aka 'int') vs
'khronos_ssize_t' (aka 'long'))
typedef ptrdiff_t GLsizeiptr;
^
/Users/igloomedialtd/emsdk_portable/emscripten/1.30.0/system/include/GLES2/gl2.h:39:26: note:
previous definition is here
typedef khronos_ssize_t GLsizeiptr;
^
2 errors generated.
ERROR root: compiler frontend failed to generate LLVM bitcode, halting
Someones-MacBook:1.30.0 igloomedialtd$
看起来GLFW库正在重新定义GLES2中的一些定义,我能做些什么?
编辑:2015年6月7日
我通过删除#include并在# include_es2之前添加#define GLFW_INCLUDE_ES2;GL/glfw.h>行,使GLFW导入正确的GL文件。
然而,现在我有一个单独的问题;当尝试在Firefox中运行输出时,我得到:'抛出异常:ReferenceError: GL未定义'
有人知道是什么引起的吗?
这显然是由于只使用GLFW命令时缺少对GL的依赖。如果您添加一个gl*调用,它将编译良好:https://github.com/kripken/emscripten/issues/3530
相关文章:
- .cpp和.h文件中的模板专用化声明
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 文本文件中的单词链表
- CMake-按正确顺序将项目与C运行时对象文件链接
- 使用新行和不使用新行读取文件
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- 挂起和取消挂起一个文件DLL
- 如何确定我已使用非编码文件到达 EOF?
- 命名空间中具有.h和.cpp文件的类
- glfw 的基本设置会导致与 emscripten 生成的 js 文件中的事件侦听器有关的运行时错误
- 使用emscripten将c++文件转换为wasm时出错
- Emscripten - 在 CMakeList 文件中传递 emscripten 选项
- 从Emscripten生成的JavaScript文件中使用C API
- 减小 Wasm 文件大小(libc、optimization、emscripten)
- Emscripten 安装错误:"./emcc 没有这样的文件或目录"
- Emscripten:提供下载/保存生成的MEMFS文件
- 在 Edge 和 Safari 中播放带有SDL_mixer.ogg文件(emscripten)
- Emscripten:找不到算法.h文件
- Emscripten:在 HTML 文件中显示图像
- GLFW与GLES在简单的c++ Emscripten文件不会构建