Recent

Author Topic: Creating 3+ rendering context on Windows.  (Read 10616 times)

PaulFMichell

  • New Member
  • *
  • Posts: 21
Creating 3+ rendering context on Windows.
« on: October 22, 2016, 10:43:42 am »
Hello All,

I have been experimenting with GLSL in Lazarus and had some success with using TOpenGLControl on Linux and Windows,
both with my NVidia based laptop and Intel HD4000 based workstation.  However, at work my terminal always initialises as a software context:

GL_VERSION: 1.1.0
GL_RENDERER: GDI Generic
GL_VENDOR: Microsoft Corporation

The actual GPU on this system is Intel HD Graphics 2000 with 130 ext.  What is interesting is that GpuCapsViewer from here:

http://www.ozone3d.net/gpu_caps_viewer/

Can run GLSL demos and reports the following OpenGL properties:

GL_VERSION 3.1.0 - Build 9.17.10.4229
GL_RENDERER Intel(R) HD Graphics 2000
GLSL_VERSION 1.40 - Intel Build 9.17.10.4229

Does anybody know how it is initialising the rendering context and can we achieve the same capability within the TOpenGLControl?

Thanks,

Paul

Thaddy

  • Hero Member
  • *****
  • Posts: 14382
  • Sensorship about opinions does not belong here.
Re: Creating 3+ rendering context on Windows.
« Reply #1 on: October 22, 2016, 11:25:39 am »
It should be initialized by the graphics driver. If it does it in software the driver either does not support it or fails on it.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

PaulFMichell

  • New Member
  • *
  • Posts: 21
Re: Creating 3+ rendering context on Windows.
« Reply #2 on: October 22, 2016, 03:27:00 pm »
Thaddy,

Yes, I understand it is supposed to automatically load the hardware driver if available.  I've also read that the early Intel HD chipsets are poorly supported on Windows.  However, I am curious as to what GpuCapsViewer is doing to 'persuade' the driver to run?  It must be using some alternative method for creating a rendering context for these motherboards, I was wondering if anyone knew how?

Thaddy

  • Hero Member
  • *****
  • Posts: 14382
  • Sensorship about opinions does not belong here.
Re: Creating 3+ rendering context on Windows.
« Reply #3 on: October 22, 2016, 05:35:18 pm »
Paul,

Does it also ignore simple C code?
I know you are perfectly capable of that.
Guess this is not a real FPC issue or is it?

I do not have a similar machine available.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

PaulFMichell

  • New Member
  • *
  • Posts: 21
Re: Creating 3+ rendering context on Windows.
« Reply #4 on: October 22, 2016, 05:47:57 pm »
It ignores a Pascal translation of a C sample using direct Windows API calls (I haven't tried with the compiled C itself, but I will next week when I'm back at work).  My suspicion is that it will fail as well since the code should be functionally the same (provided I've not fluffed the translation that is ;)).  I would dearly like to see the source of GpuCapsViewer, but it isn't FLOSS unfortunately.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11458
  • FPC developer.
Re: Creating 3+ rendering context on Windows.
« Reply #5 on: October 22, 2016, 07:23:23 pm »
4000 afaik is Sandy Bridge, which should be ok, except for the geometry shaders. (Sandy Bridge does have them, but they are not fully programmable and thus do not match spec. Simple things do work with it though)

Afaik to create a 3+ context you need to first create a basic context, and then load certain extensions (!?!)

Check the source of the dglopengl header, iirc they have some functions for that purpose.

PaulFMichell

  • New Member
  • *
  • Posts: 21
Re: Creating 3+ rendering context on Windows.
« Reply #6 on: November 03, 2016, 02:26:22 pm »
I have made some progress on this. As Thaddy suggested I had a look at some C that worked.  I found that GLEW worked well and it's glewinfo utility is a useful OpenGL capability reporting tool. I tried porting the Windows initialisation code to FreePascal and this worked.  I then adapted it to use the FreePascal GL unit and that worked too!  The version information returned being:

OpenGL renderer: Intel(R) HD Graphics 2000
OpenGL version: 3.1.0 - Build 9.17.10.4229
GLSL version: 1.40 - Intel Build 9.17.10.4229

I then pasted the same code into a Lazarus application and it reverted to the default GDI renderer:

OpenGL renderer: GDI Generic
OpenGL version: 1.1.0
GLSL version:

So my conclusion so far is that the GL/GLExt units work as intended with the Intel HD2000/3000 hardware on Windows (tested on Windows 10 64bit), but that LCL applications somehow interfere with the loading of this version of the Intel driver, but not with HD4000 and later drivers?  I've attached the test programs I've been using if anyone is interested.  I'm going to carry on playing around with the LCL version to see if I can make any further progress.

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: Creating 3+ rendering context on Windows.
« Reply #7 on: November 03, 2016, 04:38:39 pm »
Check out this link : http://forum.drdteam.org/viewtopic.php?t=6696

Windows 10, Intel HD device driver and certain line in the manifest file can cause this bug to occur. And Intel won't fix it.


PaulFMichell

  • New Member
  • *
  • Posts: 21
Re: Creating 3+ rendering context on Windows.
« Reply #8 on: November 03, 2016, 05:02:33 pm »
Wow!  Thank you for pointing that out, I doubt I would have found it out for myself!!!!  For the record for anyone else looking into this, you need to un-tick the 'Use manifest file' option in the Project Options form then 'Clean Up and Build' to force the manifest to be deleted.  It's a pity it wont be fixed as there are still a lot of these motherboards in use.

BlueIcaro

  • Hero Member
  • *****
  • Posts: 793
    • Blog personal
Re: Creating 3+ rendering context on Windows.
« Reply #9 on: November 03, 2016, 10:57:39 pm »
Hi, I ported C headers from GLFW, may be you can play with it.
More info from GLFW project here:
http://www.glfw.org/

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: Creating 3+ rendering context on Windows.
« Reply #10 on: January 27, 2017, 08:10:52 pm »
Just noticed this thread, and although it's been technically "solved" I thought I'd share my preferred method for using Lazarus with OpenGL on Windows without having to care about specific OpenGL versions, which I think is about as simple as it gets:

1) Drop a TOpenGLControl on your form.
2) Do not include any of the FPC OpenGL headers in your uses section (as in no "gl" or "glext" or "glu" or otherwise)
3) Instead, download the latest revision of dglOpenGL.pas from their github repository and do include that in your uses section.
4) Put the following two lines of code in FormShow (specifically FormShow, and not FormCreate):
Code: Pascal  [Select][+][-]
  1. InitOpenGL;
  2. ReadExtensions;
5) That's it. Those two lines will initialize the pointers for each and every single OpenGL function that your GPU supports, from version 1.0 all the way up to version 4.5. You can now use TOpenGLControl as you normally would, and call whichever functions you want from whatever versions of OpenGL you want, in any combination. (Of course, you should generally avoid using deprecated 1.0-era functionality, and REALLY avoid mixing it with non-deprecated functionality if you use it at all, but the point is that it's up to you to decide whether you're going to use modern OpenGL or not.)

To be clear: OpenGL is just a giant collection of functions and procedures contained in one or more dynamic libraries. There is nothing in the API itself that actually checks or cares about what version any given method was introduced in. All that matters is that you have a valid context created and a valid pointer initialized in the relevant library to each method that you intend on using. When someone refers to a "versioned" context, it just means that they intentionally didn't load any functionality that was marked deprecated in the official specification for that version of the API.

Hopefully someone out there finds all that helpful!

Edit: I should also note that dglOpenGL is cross-platform and includes the full suite of Linux and Mac-specific OpenGL API features, so this way of initialization should technically work on those platforms as well. (I believe the recent versions of Mac OSX might have some kind of operating-system-level version restrictions in place though, but don't quote me on that.)
« Last Edit: January 28, 2017, 11:44:17 pm by Akira1364 »

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Creating 3+ rendering context on Windows.
« Reply #11 on: January 27, 2017, 10:43:18 pm »
While it's possible to have more than 1 rendering context and swap between them, efficient apps would only use 1. You can make specific limits in the window to render in just that rectangular area at the time.

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: Creating 3+ rendering context on Windows.
« Reply #12 on: January 28, 2017, 01:01:27 am »
I agree with you, but I'm not sure who you're replying to? Who was talking about multiple contexts?

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Creating 3+ rendering context on Windows.
« Reply #13 on: January 28, 2017, 05:58:17 am »
I agree with you, but I'm not sure who you're replying to? Who was talking about multiple contexts?
The first post and thread title.

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: Creating 3+ rendering context on Windows.
« Reply #14 on: January 28, 2017, 09:41:31 am »
He meant the OpenGL version, as in OpenGL 3.0 and above.

 

TinyPortal © 2005-2018