DGL
https://delphigl.com/forum/

Checking if GLSL is supported
https://delphigl.com/forum/viewtopic.php?f=19&t=11079
Seite 1 von 1

Autor:  GL123 [ Do Jan 09, 2014 21:30 ]
Betreff des Beitrags:  Checking if GLSL is supported

I have been using dglopengl to support GLSL shaders a while now.

Most of the time it all works as expected, but I have a strange issue on a few PCs. This also seems to only happen with dual monitor setups it seems, but when I got a second monitor for my development PC it didn't show the issue. When I check for GLSL support their screen flickers black for a second. If the person has their desktop scaled to 150% this also causes windows to move around and is annoying.

This is the code I use when checking if the PC can support GLSL

Code:
  1.      try
  2.         GLSL_DC:=form1.canvas.handle;
  3.         InitOpenGL;
  4.         GLSL_RC := CreateRenderingContext(GLSL_DC, [opDoubleBuffered,opGDI], 32, 24, 0, 0, 0, 0);
  5.         ActivateRenderingContext(GLSL_DC, GLSL_RC);
  6.         ReadImplementationProperties;
  7.         ReadOpenGLCore;
  8.         parselst:=tstringlist.create;
  9.         versionstr:=string(glGetString(GL_SHADING_LANGUAGE_VERSION));
  10.         parse(versionstr,' ',parselst,true);
  11.         if strtofloat(parselst[0])<3 then GLSL_Available:=false else GLSL_Available:=true;
  12.         parselst.free;
  13.         GLSL_Available:=true;
  14.      except
  15.            GLSL_Available:=false;
  16.      end;
  17.  

InitOpenGL, ReadImplementationProperties and ReadOpenGLCore are all the default code from dglopengl.
GLSL_DC is a Windows.HDC
GLSL_RC is a Windows.HGLRC

Is there anything I am doing wrong there? Is there a more bullet proof way of checking for GLSL support?

Autor:  Bergmann89 [ Fr Jan 10, 2014 21:22 ]
Betreff des Beitrags:  Re: Checking if GLSL is supported

Hey,

you variable 'GLSL_Available' is always true (see Line 13). Maybe the issue is caused somewhere behind the check, because it returns always true?
Do you need the 'opGDI' flag? I've read about some flickering when this is enabled.
Try to use 'GetDC(form1.Handle)' in line 2. If nothing of this will help, you can also try to use this wrapper class to create your context:
https://github.com/martok/gl-context/bl ... /README.md
viewtopic.php?f=13&t=10979

greetings Bergmann.

Autor:  Sascha Willems [ Sa Jan 11, 2014 11:03 ]
Betreff des Beitrags:  Re: Checking if GLSL is supported

Simply check for the presence of the GL_ARB_SHADING_LANGUAGE_100 extensions, that's the official recommended way of detecting wether an implementation supports shading or not.

Autor:  GL123 [ Mo Jan 13, 2014 01:39 ]
Betreff des Beitrags:  Re: Checking if GLSL is supported

OK, what is the minimal code I need to check if GLSL version 3.0 or higher is supported on the PC?

I manged to cut the above code down to

Code:
  1.      try
  2.         GLSL_DC:=form1.canvas.handle;
  3.         InitOpenGL;
  4.         GLSL_RC := CreateRenderingContext(GLSL_DC, [], 32, 24, 0, 0, 0, 0);
  5.         ActivateRenderingContext(GLSL_DC, GLSL_RC);
  6.         parselst:=tstringlist.create;
  7.         versionstr:=string(glGetString(GL_SHADING_LANGUAGE_VERSION));
  8.         parse(versionstr,' ',parselst,true);
  9.         if strtofloat(parselst[0])<3 then GLSL_Available:=false else GLSL_Available:=true;
  10.         parselst.free;
  11.         optionsform.vendorinfo.caption:='GLSL Version '+glGetString(GL_SHADING_LANGUAGE_VERSION);
  12.         DeactivateRenderingContext;
  13.         DestroyRenderingContext(GLSL_RC);
  14.      except
  15.            GLSL_Available:=false;
  16.      end;

But that still causes the screen to go black and flicker for a second when that code is run.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/