- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试在 OpenGL 中使用累积缓冲区,但由于某种原因,缓冲区似乎没有被填充。我构建了一个简单的测试应用程序,一个正在渲染的 2D 平面,仅此而已。这很好。然后我尝试做我能想到的最简单的累积缓冲区操作,将渲染帧加载到累积缓冲区,清除屏幕,然后将累积缓冲区返回到屏幕。当我这样做时,累积缓冲区似乎根本不包含任何信息,图像只是屏幕被清除的颜色,就好像累积缓冲区根本没有返回一样。我还尝试过进行更传统的运动模糊设置,在返回之前对场景和缓冲区进行多次更新并获得相同的结果。
这是简单测试的主循环:
SDL_Event eve;
while (true)
{
//Normal stuff
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
//Accumulation///////////////////////
glAccum(GL_LOAD, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glAccum(GL_RETURN, 1.0f);
//Accumulation///////////////////////
SDL_GL_SwapWindow(window);
SDL_PollEvent(&eve);
}
这是运动模糊测试的主循环:
float x = 0.0f;
int step = 0;
int steps = 4;
SDL_Event eve;
while (true)
{
//Test stuff
x += 0.005f;
GLfloat newVerts[] = {
-0.5f + x, 0.5f,
0.5f + x, 0.5f,
0.5f + x, -0.5f,
-0.5f + x, -0.5f,
};
glBufferData(GL_ARRAY_BUFFER, sizeof(newVerts), newVerts, GL_STATIC_DRAW);
//Normal stuff
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
//Accumulation///////////////////////
if (step == 0)
{
glAccum(GL_LOAD, 1.0f / steps);
}
else
{
glAccum(GL_ACCUM, 1.0f / steps);
}
step++;
if (step < steps)
{
continue;
}
step = 0;
glAccum(GL_RETURN, 1.0f);
//Accumulation///////////////////////
SDL_GL_SwapWindow(window);
SDL_PollEvent(&eve);
}
这是完整的应用程序源代码(它只有大约 100 行,我将其包括在内只是为了防止我的 glEnable
或 SDL_GL_SetAttribute
调用出现问题):
#include "tools.h"
static string vertexSource = getFile("D:/test.vsh");
static string fragmentSource = getFile("D:/test.fsh");
int main(int argc, char *argv[])
{
//SDL///////////////////////////////////////////////
SDL_Init(SDL_INIT_EVERYTHING);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 5);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 8);
SDL_Window *window = SDL_CreateWindow("Test", 50, 50, 1600, 900, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
SDL_GLContext context = SDL_GL_CreateContext(window);
//GLEW///////////////////////////////////////////////
glewExperimental = GL_TRUE;
GLint result = glewInit();
if (result != GLEW_OK)
{
cout << glewGetErrorString(result) << "\n";
cout << "GLEW initialization failed.\n";
}
//OpenGL///////////////////////////////////////////////
glEnable(GL_DEPTH);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
glClearDepth(1.0f);
//Object///////////////////////////////////////////
//Vertex Array
GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
//Vertex Buffer
GLuint vbo;
glGenBuffers(1, &vbo);
GLfloat vertices[] = {
-0.5f, 0.5f,
0.5f, 0.5f,
0.5f, -0.5f,
-0.5f, -0.5f,
};
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
//Element Buffer
GLuint ebo;
glGenBuffers(1, &ebo);
GLuint elements[] = {
0, 1, 2,
2, 3, 0
};
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(elements), elements, GL_STATIC_DRAW);
//Shader
GLuint shaderProgram = createShader(vertexSource, fragmentSource);
glUseProgram(shaderProgram);
GLint posAttrib = glGetAttribLocation(shaderProgram, "position");
glEnableVertexAttribArray(posAttrib);
glVertexAttribPointer(posAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0);
//Loop///////////////////////////////////////////////
float x = 0.0f;
int step = 0;
int steps = 4;
SDL_Event eve;
while (true)
{
//Test stuff
x += 0.005f;
GLfloat newVerts[] = {
-0.5f + x, 0.5f,
0.5f + x, 0.5f,
0.5f + x, -0.5f,
-0.5f + x, -0.5f,
};
glBufferData(GL_ARRAY_BUFFER, sizeof(newVerts), newVerts, GL_STATIC_DRAW);
//Normal stuff
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
//Accumulation///////////////////////
if (step == 0)
{
glAccum(GL_LOAD, 1.0f / steps);
}
else
{
glAccum(GL_ACCUM, 1.0f / steps);
}
step++;
if (step < steps)
{
continue;
}
step = 0;
glAccum(GL_RETURN, 1.0f);
//Accumulation///////////////////////
SDL_GL_SwapWindow(window);
SDL_PollEvent(&eve);
}
}
我使用 GLEW 访问 OpenGL 调用,我使用 SDL 进行上下文创建和窗口管理。
我运行此平台的一般规范:
最佳答案
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
^^^^^^^^^^^^^^^^^^^^^^^^^^^
移除的功能(如累积缓冲区)在 Core 上下文中不起作用。
OpenGL 3.2 Core spec, appendix E, page 329 & 333:
E.2 Deprecated and Removed Features
...
Functions which have been removed will generate an
INVALID_OPERATION
error if called in the core profile or in a forward-compatible context....
E.2.2 Removed Features
...
Accumulation buffers -
ClearAccum
, andACCUM_BUFFER_BIT
is not valid as a bit in the argument toClear
(section 4.2.3);Accum
; theACCUM_*_-BITS
framebuffer state describing the size of accumulation buffer components; and all associated state.Window system-binding APIs such as GLX and WGL may choose to either not expose window configs containing accumulation buffers, or to ignore accumulation buffers when the default framebuffer bound to a GL context contains them.
关于c++ - OpenGL 累积缓冲区不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33933655/
这个问题在这里已经有了答案: Possible to make an event handler wait until async / Promise-based code is done? (2
我经常有多个运行的进程(R,Python,eshell/shell),对于每个进程,我经常都有一个相关的脚本,可以从中发送摘要。为此,我通常将每个框架垂直地分成两个窗口,以便脚本文件(例如.py)位于
如何修改 emacs 在关闭缓冲区后选择要显示的缓冲区的方式? 当我有多个列显示相同的缓冲区,然后在其中一个缓冲区中打开另一个文件,然后关闭新打开的缓冲区时,它不会切换回前一个缓冲区,而是切换到另一个
如何将 ex 命令复制到剪贴板或粘贴到缓冲区? 在 Windows 上使用 gvim。 最佳答案 windows剪贴板可以通过the buffer + 访问.因此,可以使用 + 将剪贴板粘贴为前命令。
在 javascript 中如何以比以下更简单的方式获取 b 缓冲区? var num=6553599 var a = new Buffer(4); a.writeInt32LE(num)
每次我在 Google 上搜索有关 OpenGL 编程的文章时,我都会找到一些文章,但似乎所有文章都提到了着色器和缓冲区。那些是什么?你能解释其中的一些吗: 深度缓冲区 模板缓冲区 像素着色器 帧缓冲
我有java考试,当我学习时,我看到了这个练习,我尝试解决它,但我发现一些困难,所以请帮助我考虑实用程序中方法的以下注释、 header 和部分代码名为 Atbash 的加密类。 /**
每次我在 Google 上搜索有关 OpenGL 编程的文章时,我都会找到一些文章,但似乎所有文章都提到了着色器和缓冲区。那些是什么?你能解释其中的一些吗: 深度缓冲区 模板缓冲区 像素着色器 帧缓冲
对于每个属性使用跨步顶点缓冲区与紧密打包缓冲区有何优缺点?我的意思是例如: 步幅:xyzrgb xyzrgb xyzrgb 紧:xyzxyzxyz rgbrgbrgb 乍一看,使用步幅时您似乎可以轻松
我正在尝试将文本文件中每行的数字读取到 ArrayList 中。当我执行以下函数时,它总是跳过最后一个元素。有人可以帮我吗?因为我在这里没有遇到问题,因为它读取直到缓冲区为空,所以他应该在到达 Fil
#include #include int main () { time_t time_raw_format; struct tm * ptr_time; char *buff
基本上我有一个包含不同类型数据的自定义结构。例如: typedef struct example_structure{ uint8_t* example_1[4]; int example_2[4];
我之前的列表实现是一个简单的 LinearLayout,位于一个装满我的项目的 ScrollView 中。 我切换到 ListView 的 Android 实现以简单地使用 CursorAdapter
我想创建一个可变长度的输入事件窗口/缓冲区,当它接收到额外的事件时会变长。 这是为了实现“键入时搜索”功能。我想捕获点击,但为了不给服务器造成压力,我想明智地进行服务调用。 我想到的逻辑是缓冲击键,从
我想将 yuv420P 像素写入缓冲区而不是二进制文件。假设我在指针中存储了 luma 、 Cb 和 Cr。 luma = output_pixel.luma; cb = output_pixel.c
我想在 Go 中构建一个支持多个并发读取器和一个写入器的缓冲区。所有写入缓冲区的内容都应由所有读者读取。允许新读者随时加入,这意味着已经写入的数据必须能够为迟到的读者回放。 缓冲区应满足以下接口(in
本文转载自微信公众号「小明菜市场」,作者小明菜市场。转载本文请联系小明菜市场公众号。 前言 Java NIO 需要理解的主要有缓冲区,通道,选择器,这三个主要的部分。 基础
一 点睛 NIO,可以称为 New IO 或 Non Blocking IO,是在 JDK 1.4 后提供的新 API。传统的I/O 是阻塞式的 I/O、面向流的操作;而 NIO 是非阻塞 I/O 、
我正在寻找一种切换到包含搜索文本的缓冲区的方法。 例如。如果我打开了 100 个缓冲区,我想切换到一个包含 'fooBar = 1' 的缓冲区 最佳答案 我写了一个 Vim 插件来做到这一点:buff
我正在尝试将提取的视频帧(我使用 ffmpeg)推送到 FFMPEG 缓冲区中。我已经查看了 ffmpeg 的缓冲区源文件,例如 buffersrc.c 和 fifo.c,以确定我是否可以这样做,但我
我是一名优秀的程序员,十分优秀!