获得 OpenGL 纹理或渲染缓冲区的“平均"颜色的任何快速方法? [英] Any fast way to get “average” color of OpenGL texture or render buffer?

查看:61
本文介绍了获得 OpenGL 纹理或渲染缓冲区的“平均"颜色的任何快速方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在操作系统上有一个 OpenGL 应用程序,它可以在应用程序失去焦点时抢走 OpenGL 上下文,即使应用程序保留在内存中.当应用程序返回焦点时,当我将纹理重新加载到新的 OpenGL 上下文时,这会导致屏幕闪烁.

I have an OpenGl application on an operating system that can snatch the OpenGL context away when the application loses focus, even though the application remains in memory. This results in a screen flicker as I re-load textures into the new OpenGL context when the application returns to focus.

我正在努力将重新加载分解为增量,以便看起来更好.但我也想知道这种可能性:

I am working on breaking up the re-loading into increments so it looks better. But I am also wondering about this possibility:

  1. 当程序注意到它将失去焦点时,捕捉显示(或主要纹理)的平均"颜色.
  2. 当程序重新获得焦点时,使用步骤 1 中捕获的颜色非常快速地执行 glClearColor(r,g,b).
  3. 然后,当用户看到第 2 步中设置的颜色时,正常重新加载纹理.

我认为这是一种使闪烁不那么明显的视觉技巧.有一个问题:我认为通过平均每个像素来捕获聚合颜色会花费太长时间并且不值得.

I am thinking this would be sort of a visual trick to make the flicker less noticeable. There’s a catch: I am thinking that capturing an aggregate color by averaging every pixel would take too long and not be worth it.

所以我想知道是否有任何 OpenGl 技巧可以让应用程序粗略估计用户在屏幕上看到的平均颜色?

So I am wondering if there is any OpenGl trick that would let an application get a rough estimate of the average color that a user sees on the screen?

推荐答案

我听说过的平均屏幕颜色的最快方法是将其复制到纹理,调用 glGenerateMipmap,并抓取最小层(1x1 mip 级别),其中将包含颜色的平均值像素.不过,这对我来说听起来并不是特别快,所以不确定它是否对您的目的有帮助.

The fastest way I've heard of to average a screen's color is to copy it to a texture, call glGenerateMipmap, and grab the smallest layer (1x1 mip level), which will contain an average of the colors of the pixel. That doesn't sound particularly fast to me though, so not sure if it will be helpful for your purposes.

这篇关于获得 OpenGL 纹理或渲染缓冲区的“平均"颜色的任何快速方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆