- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在使用 codeblocks 10.05 识别我机器上的 GLFW 库时遇到了一些困难。当我创建一个空项目并复制粘贴从这个 GLFW 教程中找到的代码时 >> http://content.gpwiki.org/index.php/GLFW:Tutorials:Basics
#include <stdlib.h>
#include <GL/glfw.h>
void Init(void);
void Shut_Down(int return_code);
void Main_Loop(void);
void Draw_Square(float red, float green, float blue);
void Draw(void);
float rotate_y = 0,
rotate_z = 0;
const float rotations_per_tick = .2;
int main(void)
{
Init();
Main_Loop();
Shut_Down(0);
}
void Init(void)
{
const int window_width = 800,
window_height = 600;
if (glfwInit() != GL_TRUE)
Shut_Down(1);
// 800 x 600, 16 bit color, no depth, alpha or stencil buffers, windowed
if (glfwOpenWindow(window_width, window_height, 5, 6, 5,
0, 0, 0, GLFW_WINDOW) != GL_TRUE)
Shut_Down(1);
glfwSetWindowTitle("The GLFW Window");
// set the projection matrix to a normal frustum with a max depth of 50
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float aspect_ratio = ((float)window_height) / window_width;
glFrustum(.5, -.5, -.5 * aspect_ratio, .5 * aspect_ratio, 1, 50);
glMatrixMode(GL_MODELVIEW);
}
void Shut_Down(int return_code)
{
glfwTerminate();
exit(return_code);
}
void Main_Loop(void)
{
// the time of the previous frame
double old_time = glfwGetTime();
// this just loops as long as the program runs
while(1)
{
// calculate time elapsed, and the amount by which stuff rotates
double current_time = glfwGetTime(),
delta_rotate = (current_time - old_time) * rotations_per_tick * 360;
old_time = current_time;
// escape to quit, arrow keys to rotate view
if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS)
break;
if (glfwGetKey(GLFW_KEY_LEFT) == GLFW_PRESS)
rotate_y += delta_rotate;
if (glfwGetKey(GLFW_KEY_RIGHT) == GLFW_PRESS)
rotate_y -= delta_rotate;
// z axis always rotates
rotate_z += delta_rotate;
// clear the buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// draw the figure
Draw();
// swap back and front buffers
glfwSwapBuffers();
}
}
void Draw_Square(float red, float green, float blue)
{
// Draws a square with a gradient color at coordinates 0, 10
glBegin(GL_QUADS);
{
glColor3f(red, green, blue);
glVertex2i(1, 11);
glColor3f(red * .8, green * .8, blue * .8);
glVertex2i(-1, 11);
glColor3f(red * .5, green * .5, blue * .5);
glVertex2i(-1, 9);
glColor3f(red * .8, green * .8, blue * .8);
glVertex2i(1, 9);
}
glEnd();
}
void Draw(void)
{
// reset view matrix
glLoadIdentity();
// move view back a bit
glTranslatef(0, 0, -30);
// apply the current rotation
glRotatef(rotate_y, 0, 1, 0);
glRotatef(rotate_z, 0, 0, 1);
// by repeatedly rotating the view matrix during drawing, the
// squares end up in a circle
int i = 0, squares = 15;
float red = 0, blue = 1;
for (; i < squares; ++i){
glRotatef(360.0/squares, 0, 0, 1);
// colors change for each square
red += 1.0/12;
blue -= 1.0/12;
Draw_Square(red, .6, blue);
}
}
并使用代码块编译它返回了这个错误:
/home/user/Graphics/Project_2/test.c|27|undefined reference to `glfwInit'|
/home/user/Graphics/Project_2/test.c|30|undefined reference to `glfwOpenWindow'|
......
.....
....
...
但是当我创建一个简单的 *.c 文件并编译它时:
gcc myprog.c -o myprog -lglfw -lGL -lpthread
它有效.. 我怎样才能使代码块与 GLFW 一起工作?谢谢
最佳答案
按照以下步骤操作。
关于codeblocks - GLFW 和代码块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14784156/
GLFW 首字母缩写词代表什么? http://www.glfw.org/是主要网站,但我在那里找不到任何线索。 Evenhere on SO 它有一个标签,但在描述中没有解释首字母缩略词。 最佳答案
我正尝试在我的 mac 上使用 xcode 使用 glfw 2.7.5,但出现以下错误: Undefined symbols for architecture i386: "_glfwGetKey
当我们必须运行多线程glfw应用程序时,如果在MainProcess中调用了glfw.create_window(),程序将停止。 这基本上是更大代码的一部分,我无法更改架构(包括多处理架构),但这是
如何使用 glfw 检测小写字母?我可以检测大写字母。例如, if ( key == 'A' && action == GLFW_PRESS ) std::cout << (char)
如何使用 glfw 检测小写字母?我可以检测大写字母。例如, if ( key == 'A' && action == GLFW_PRESS ) std::cout << (char)
我正在尝试将 GLFW 用于学校项目,并遵循了以下步骤: 1) 从 glfw.org 下载 win32 zip 2) 将/include 添加到我的解决方案的 includes 3) 将/lib-ms
我已经完成了以下视频 https://www.youtube.com/watch?v=shpdt6hCsT4 但是,我的世界窗口看起来像这样: http://s1303.photobucket.com
当我使用 GLFW 创建窗口(在 Windows 操作系统上)并通过 glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, 1); 将 GLFW_TRANSPARE
我一直在试图让我的窗口可拖动。 这是我的代码, #include #include #include #include "include/GLFW/glfw3.h" void cursor_po
我在识别我机器上的 GLFW 库的代码块 10.05 时遇到了一些困难。当我创建一个空项目并复制粘贴此 GLFW 教程中的代码时 >> http://content.gpwiki.org/index.
在我寻找跨平台框架/库的过程中,GLFW 被多次提及。所以,我决定尝试一下。现在,似乎我什至无法启动窗口。 :-/ #include #include #include int main(int ar
我想将 OpenGL 图形绘制到多个窗口中。据我所知,所有窗口都“通向”同一个“世界”: 在窗口之间共享上下文。这对 GLFW 来说是非常简单的任务,我在这方面取得了一些进展,但是,代码变得越来越模糊
最近我开始了一个涉及 GLFW(64 位,带有 GLEW)的项目。但是,我似乎无法让它正确链接。我的设置方式如下: 操作系统:Windows 8 64位 编译器:mingw64 集成开发环境:ecli
我想将 OpenGL 图形绘制到多个窗口中。据我所知,所有窗口都“通向”同一个“世界”: 在窗口之间共享上下文。这对 GLFW 来说是非常简单的任务,我在这方面取得了一些进展,但是,代码变得越来越模糊
标题已经说明了一切。使用 C 语言的 GLFW 库,我怎样才能防止窗口宽度低于 20 像素,或者 10。怎样才能防止高度不超过 100?我尝试为窗口大小调整时创建一个回调函数,如下所示: void w
所以基本上是从页面上的教程学习 OpenGL 和 GLFW 库:http://www.opengl-tutorial.org/beginners-tutorials/tutorial-6-keyboa
我正在用 OpenGL 和 GLFW 编写游戏引擎。但是,不知何故我的窗口无法关闭。我尝试了很多东西,但没有效果。我的代码有什么问题? 我找不到其中的错误 - 我觉得一切都很好。 代码: int ru
我在创建 GLFW 窗口时遇到了一些问题。我想要一个能够在窗口模式和全屏模式之间切换的程序。要在 GLFW 2.7.8 中执行此操作,必须首先销毁事件窗口,然后创建一个新窗口。我读到 3.0 版支持多
在 GLFW 中设置回调函数时要使用什么数据类型? 我尝试设置一个函数来键入 void,但给我一个编译错误。将其更改为 void __stdcall 会给我一个 RT 错误,但我如何使用 GLFW 的
为了让结果保持打开状态(窗口屏幕),我必须执行以下操作: while (glfwGetWindowParam(GLFW_OPENED)) { // do some stuff glDr
我是一名优秀的程序员,十分优秀!