如何替换以下(不建议使用的)OpenGL函数? [英] How to replace following (deprecated) OpenGL functions?

查看:126
本文介绍了如何替换以下(不建议使用的)OpenGL函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的应用程序,显示了使用OpenGL的自定义帧缓冲区(它是帧缓冲区功能的仿真器):

I've got a simple application showing a custom frame buffer (it is sort of an emulator of the frame buffer functionality) using OpenGL:

void GLWidget::resizeGL( int w, int h )
{
    glViewport( 0, 0, w, h );
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    glOrtho( 0, w, 0, h, -1, 1 );
}

void GLWidget::paintGL()
{
    if( pScreen != 0 )
    {
        glRasterPos2i( 0, 2 * pScreen->height );
        glPixelZoom( 2, -2 );
        glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
        glDrawPixels( pScreen->width, pScreen->height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, pScreen->pixels );
    }
}

真的,这就是我想要做的,没有着色器,没有花哨的技巧,仅是双重缩放和显示.该代码已有很长的历史,在将其移植到Windows时,我注意到它不再可以编译了.首先,我认为这是Windows特有的东西,但后来我意识到这实际上是新的OpenGL Windows 7附带的(与我每天使用的Arch Linux不同).

Really, this is all I want to do it, no shaders, no fancy tricks, just the double zoom and show. This code is years old and while porting it to Windows I've noticed that it wont compile anymore. First I thought it's a Windows specific thing but then I realized it's actually the new OpenGL Windows 7 comes with (unlike Arch Linux I'm using on daily basis).

那该怎么办?我真的不希望为矩阵内容安装自定义数学库,我不敢相信最新的OpenGL无法仅显示缓冲区".

So what to do about that? I really don't feel like installing a custom math library for the matrix stuff, I can't believe the latest OpenGL can't "just show the buffer".

推荐答案

我必须自己回答这个问题.经过长时间的研究,我终于找到了这个案例. 此答案可以很好地解释正在发生的事情.另外,我在 Qt下载部分中以某种方式错过了这一点:

I'll have to answer this for myself. After a long research, I finally found the case. This answer gives perfect explanation what's going on. Also, I somehow missed this in the Qt download section:

Windows脱机安装程序默认情况下基于ANGLE.

The Windows offline installers are by default ANGLE based.

什至导致更复杂的解释简而言之:

Windows上的

Qt 5可以配置为使用OpenGL驱动程序,或 通过ANGLE库的DirectX驱动程序.

Qt 5 on Windows can be configured to use either OpenGL drivers, or DirectX drivers through the ANGLE library.

我很惊讶这么少(一个?)的答案提到了这一点.有关上下文,四边形,着色器的许多令人恐惧的内容,但解决方案确实很简单.希望它将对某人有所帮助.

I'm surprised that so few (one?) SO answers mention this. A lot of scary stuff about contexts, quads, shaders but the solution is really simple. Hopefully it will help someone.

这篇关于如何替换以下(不建议使用的)OpenGL函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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