小编Ylf*_*aue的帖子

GLSL 中作为参数的函数

是否可以在 OpenGL 着色语言中将一个函数作为其他函数的参数传递?如果是的话,那该怎么办呢?

opengl glsl

3
推荐指数
1
解决办法
1767
查看次数

使用GLFW和GLEW的OpenGL - 在Windows上使用gcc进行编译

我正在尝试运行一个使用我自己构建的GLFW和GLEW库的OpenGL程序.我使用的入门代码是

#include <iostream>

// GLEW
#define GLEW_STATIC
#include <glew.h>

// GLFW
#include <glfw3.h>


// Function prototypes
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);

// Window dimensions
const GLuint WIDTH = 800, HEIGHT = 600;

// The MAIN function, from here we start the application and run the game loop
int main()
{
    std::cout << "Starting GLFW context, OpenGL 3.3" << std::endl;
    // Init GLFW
    glfwInit();
    // Set all the required options for GLFW
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, …
Run Code Online (Sandbox Code Playgroud)

c++ gcc opengl-3

2
推荐指数
1
解决办法
3382
查看次数

从回调函数中检索数据

假设我要在 GLFW 中设置回调函数

glfwSetCursorPosCallback(window, mouse);
Run Code Online (Sandbox Code Playgroud)

检索光标位置的最明显的方法是

vec2 m;

void mouse (GLFWwindow* window, GLdouble x, GLdouble y)
{
    m = vec2 (x, y);
}
Run Code Online (Sandbox Code Playgroud)

但是,我更愿意在不使用全局变量的情况下这样做。能做到吗?

c++ global-variables glfw

1
推荐指数
1
解决办法
426
查看次数

标签 统计

c++ ×2

gcc ×1

glfw ×1

global-variables ×1

glsl ×1

opengl ×1

opengl-3 ×1