热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

什么是英特尔HD3000上正确的OpenGL初始化?-WhatistheproperOpenGLinitialisationonIntelHD3000?

IhaveaproblemwithIntelgraphicsHD3000onToshibanotebook(OSWin7x32,langC++).我在Toshiba

I have a problem with Intel graphics HD 3000 on Toshiba notebook (OS Win7 x32, lang C++).

我在Toshiba笔记本电脑上安装了英特尔图形HD 3000(OS Win7 x32,lang C ++)。

Classical single context OpenGL applications work fine but on multiple OpenGL contexts in single App creates weird behavior:

经典的单上下文OpenGL应用程序工作正常但在单个App中的多个OpenGL上下文中会产生奇怪的行为:

  1. on older versions of my apps the Intel driver cannot create second rendering context at all.
  2. 在我的应用程序的旧版本上,英特尔驱动程序根本无法创建第二个渲染上下文。

  3. after major changes in my OpenGL based software architecture behavior changed

    在我的基于OpenGL的软件架构行为的重大变化发生变化之后

    now I am able to create second rendering context but after releasing it (after use / close window) the driver cannot create any next rendering context. This has been tested on more than one app and behaves the same all the time. I wanted to get over this by having the second context at all time active but it does not work too (somehow rendering context is invalidated on Intel). For clarity the second OpenGL rendering context is used for Open/Save dialogs (preview sub-windows).

    现在我能够创建第二个渲染上下文但在释放之后(在使用/关闭窗口之后),驱动程序无法创建任何下一个渲染上下文。这已经在多个应用程序上进行了测试,并且始终表现相同。我想通过让第二个上下文始终处于活动状态来克服这个问题,但它也不起作用(某种程度上,渲染上下文在英特尔上无效)。为清楚起见,第二个OpenGL渲染上下文用于打开/保存对话框(预览子窗口)。

Driver info:

Intel(R) HD Graphics 3000
OpenGL ver: 3.1.0 - Build 9.17.10.2932

Init and exit OpenGL code (from my OpenGL engine):

初始化和退出OpenGL代码(来自我的OpenGL引擎):

//------------------------------------------------------------------------------
int OpenGLscreen::init(void *f,int textures)
    {
    if (_init) exit();
    frm=(formtype*)f;
    hdc = GetDC(frm->Handle);       // get device context
    int i;
    if (!_used)
        {
        int i,_pfid=-1,_zbit=0;
        PIXELFORMATDESCRIPTOR _pfd;
        #define pfd_test i=ChoosePixelFormat(hdc,&pfd); DescribePixelFormat(hdc,i,sizeof(_pfd),&_pfd); if (_zbit<_pfd.cDepthBits) { _zbit=_pfd.cDepthBits; _pfid=i; }
        pfd.cColorBits = 32; pfd.cDepthBits = 32; pfd_test;
        pfd.cColorBits = 24; pfd.cDepthBits = 32; pfd_test;
        pfd.cColorBits = 16; pfd.cDepthBits = 32; pfd_test;
        pfd.cColorBits = 32; pfd.cDepthBits = 24; pfd_test;
        pfd.cColorBits = 24; pfd.cDepthBits = 24; pfd_test;
        pfd.cColorBits = 16; pfd.cDepthBits = 24; pfd_test;
        pfd.cColorBits = 32; pfd.cDepthBits = 16; pfd_test;
        pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd_test;
        pfd.cColorBits = 16; pfd.cDepthBits = 16; pfd_test;
        #undef pfd_test
        pfd.cDepthBits = _zbit; // iba koli warningu
        DescribePixelFormat(hdc,_pfid,sizeof(pfd),&pfd);
        pfid=ChoosePixelFormat(hdc,&pfd);
        SetPixelFormat(hdc,pfid,&pfd);
        DescribePixelFormat(hdc,pfid,sizeof(pfd),&pfd);

        znum=1<<(pfd.cDepthBits-1);
        }

    // create current rendering context
    hrc = wglCreateContext(hdc);

    if(hrc == NULL)
        {
        ShowMessage("Could not initialize OpenGL Rendering context !!!");
        _init=0;
        return 0;
        }
    if(wglMakeCurrent(hdc, hrc) == false)
        {
        ShowMessage("Could not make current OpenGL Rendering context !!!");
        wglDeleteContext(hrc);          // destroy rendering context
        _init=0;
        return 0;
        }
    if (!_used) glewInit();
    _init=1;
    _used=1;
    resize(0,0,128,128);

//  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
//  glFrontFace(GL_CCW);                    // predna strana je proti smeru hod. ruciciek
//  glEnable(GL_CULL_FACE);                 // vynechavaj odvratene steny
//  glEnable(GL_TEXTURE_2D);                // pouzivaj textury, farbu pouzivaj z textury
//  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
//  glEnable(GL_BLEND);                     // priehladnost
//  glBlendFunc(GL_SRC_ALPHA,GL_DST_ALPHA);
/*
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_COLOR_MATERIAL);

    GLdouble MaterialAmbient  [] = {0.25, 0.25, 0.25, 1.00};
    GLdouble MaterialDiffuse  [] = {0.25, 0.25, 0.25, 1.00};
    GLdouble MaterialSpecular [] = {0.50, 0.50, 0.50, 1.00};
    GLdouble MaterialShininess[] = {15.0};                  // 0-ufocused, 128 max focus
    glMaterialfv(GL_FRONT, GL_AMBIENT  , MaterialAmbient  );
    glMaterialfv(GL_FRONT, GL_DIFFUSE  , MaterialDiffuse  );
    glMaterialfv(GL_FRONT, GL_SPECULAR , MaterialSpecular );
    glMaterialfv(GL_FRONT, GL_SHININESS, MaterialShininess);
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);

    GLdouble LightPosition [] = {0.00, 0.00, 0.00, 0.0};
    GLdouble LightAmbient  [] = {0.10, 0.10, 0.10, 1.0};
    GLdouble LightDiffuse  [] = {0.20, 0.20, 0.20, 1.0};
    GLdouble LightSpecular [] = {1.00, 1.00, 1.00, 1.0};
    glLightfv(GL_LIGHT0,GL_AMBIENT ,LightAmbient );
    glLightfv(GL_LIGHT0,GL_DIFFUSE ,LightDiffuse );
    glLightfv(GL_LIGHT0,GL_SPECULAR,LightSpecular);
    glLightfv(GL_LIGHT0,GL_POSITION,LightPosition);
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, LightAmbient);
*/
    glEnable(GL_DEPTH_TEST);                // Zbuf
    glShadeModel(GL_SMOOTH);                // gourard shading
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);   // background color
    glDepthFunc(GL_LEQUAL);

    const GLubyte *p; char a;               // get extensions list
    extensiOns="";
    #define ext_add if ((extensions!="")&&(extensions[extensions.Length()]!=' ')) extensions+=' '; for (i=0;;i++) { a=p[i]; if (!a) break; extensions+=a; }
    p=glGetString(GL_EXTENSIONS); ext_add;
    if (wglGetExtensionsStringARB) p=wglGetExtensionsStringARB(hdc); ext_add;
    if (wglGetExtensionsStringEXT) p=wglGetExtensionsStringEXT(); ext_add;

//  int hnd=FileCreate("glext.txt"); FileWrite(hnd,scr.extensions.c_str(),scr.extensions.Length()); FileClose(hnd);

    OpenGLtexture txr;
    txrs.alloc(textures);           // allocate textures name space
    font_init(txr);
    fOnt=txrs.add(txr);
    s3dl=txrs.add(txr); txrs.sizes[s3dl]._mode=GL_MODULATE;
    s3dr=txrs.add(txr); txrs.sizes[s3dr]._mode=GL_MODULATE;
    return 1;
    }
//------------------------------------------------------------------------------
void OpenGLscreen::exit()
    {
    if (!_init) return;
    wglMakeCurrent(hdc,hrc);        // use this context if multiple OpenGLs are used
    txrs.free();
    wglMakeCurrent(NULL, NULL);     // release current rendering context
    wglDeleteContext(hrc);          // destroy rendering context
    hrc=NULL;
    _init=0;
    }
//------------------------------------------------------------------------------

now the questions:

现在问题:

  1. Am I doing something wrong?

    难道我做错了什么?

    Engine is fully functional GL,GLSL,VBO,VAO,... and tested for years. Weird behavior is present only on Intel. Cards from nVidia works fine and ATI/AMD works almost fine (there are some issues but they are buggy drivers related as always for ATI especially for VBO with indices everything else works fine)

    发动机是功能齐全的GL,GLSL,VBO,VAO ......并经过多年的测试。奇怪的行为仅出现在英特尔上。来自nVidia的卡工作正常并且ATI / AMD工作得很好(有一些问题,但它们是驱动器相关的驱动器,因为ATI总是如此,特别是对于VBO,其他一切工作正常)

  2. Is there a better way to init/exit OpenGL?

    有没有更好的方法来初始化/退出OpenGL?

  3. How to properly switch between different rendering contexts?

    如何在不同的渲染上下文之间正确切换?

    I am using wglMakeCurrent(hdc,hrc) for now but may be I am missing something or there is some workaround on Intel for this.

    我现在正在使用wglMakeCurrent(hdc,hrc),但可能是我遗漏了一些东西,或者英特尔为此做了一些解决方法。

1 个解决方案

#1


0  

Your use of WGL looks correct to me (including your use of wglMakeCurrent), but I haven't used it in a while, so my memory might be foggy (to answer Q1 and Q3).

你对WGL的使用看起来对我来说是正确的(包括你使用wglMakeCurrent),但我有一段时间没用过它,所以我的记忆可能有些模糊(回答Q1和Q3)。

However, there is a better way to initialize OpenGL: use a loader library, as detailed here. As the wiki says, it's highly recommended to use a loader library rather than attempting to do it yourself.

但是,有一种更好的初始化OpenGL的方法:使用加载程序库,如此处所述。正如维基所说,强烈建议使用加载程序库而不是自己尝试。

I like to use SFML to create the OpenGL context and window, plus GLEW (only necessary for Windows) to set up the OpenGL core context functions. I've also had success with glfw, which is good for loading OpenGL 3.2+

我喜欢使用SFML来创建OpenGL上下文和窗口,加上GLEW(仅对Windows来说是必需的)来设置OpenGL核心上下文功能。我也用glfw取得了成功,这对于加载OpenGL 3.2+非常有用


推荐阅读
  • 本文深入探讨了 Java 中的 Serializable 接口,解释了其实现机制、用途及注意事项,帮助开发者更好地理解和使用序列化功能。 ... [详细]
  • 本章将深入探讨移动 UI 设计的核心原则,帮助开发者构建简洁、高效且用户友好的界面。通过学习设计规则和用户体验优化技巧,您将能够创建出既美观又实用的移动应用。 ... [详细]
  • 尽管使用TensorFlow和PyTorch等成熟框架可以显著降低实现递归神经网络(RNN)的门槛,但对于初学者来说,理解其底层原理至关重要。本文将引导您使用NumPy从头构建一个用于自然语言处理(NLP)的RNN模型。 ... [详细]
  • moment 国际化设置中文语言 (全局) 及使用示例 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • Explore how Matterverse is redefining the metaverse experience, creating immersive and meaningful virtual environments that foster genuine connections and economic opportunities. ... [详细]
  • 前言--页数多了以后需要指定到某一页(只做了功能,样式没有细调)html ... [详细]
  • UNP 第9章:主机名与地址转换
    本章探讨了用于在主机名和数值地址之间进行转换的函数,如gethostbyname和gethostbyaddr。此外,还介绍了getservbyname和getservbyport函数,用于在服务器名和端口号之间进行转换。 ... [详细]
  • ImmutableX Poised to Pioneer Web3 Gaming Revolution
    ImmutableX is set to spearhead the evolution of Web3 gaming, with its innovative technologies and strategic partnerships driving significant advancements in the industry. ... [详细]
  • 本文详细介绍了macOS系统的核心组件,包括如何管理其安全特性——系统完整性保护(SIP),并探讨了不同版本的更新亮点。对于使用macOS系统的用户来说,了解这些信息有助于更好地管理和优化系统性能。 ... [详细]
  • 本文介绍如何使用阿里云的fastjson库解析包含时间戳、IP地址和参数等信息的JSON格式文本,并进行数据处理和保存。 ... [详细]
  • 获取计算机硬盘序列号的方法与实现
    本文介绍了如何通过编程方法获取计算机硬盘的唯一标识符(序列号),并提供了详细的代码示例和解释。此外,还涵盖了如何使用这些信息进行身份验证或注册保护。 ... [详细]
  • 本文详细探讨了Java中的24种设计模式及其应用,并介绍了七大面向对象设计原则。通过创建型、结构型和行为型模式的分类,帮助开发者更好地理解和应用这些模式,提升代码质量和可维护性。 ... [详细]
  • 本文介绍了在Windows环境下使用pydoc工具的方法,并详细解释了如何通过命令行和浏览器查看Python内置函数的文档。此外,还提供了关于raw_input和open函数的具体用法和功能说明。 ... [详细]
  • 本文介绍了如何通过配置 Android Studio 和 Gradle 来显著提高构建性能,涵盖内存分配优化、并行构建和性能分析等实用技巧。 ... [详细]
author-avatar
I技男
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有