Autore Topic: Gambas GPU  (Letto 358 volte)

Offline eloaders

  • Gamberetto
  • *
  • Post: 38
    • Mostra profilo
Gambas GPU
« il: 09 Novembre 2016, 11:50:33 »
What a library can be used in gambas to detect graphics card?
Currently I have something like this. I'm looking for a few days as I can do this using any library.

Codice: [Seleziona]
Public Sub grafika()
  Dim available_resolutions, Kernel_driver_in_use As String
  Dim rozdzielczosc, gpu, memory_prefetchable, memory_non_prefetchable As String
  Dim GLIXNFO As String
  Dim GLX As String[]
  Dim strings As String
 
  Try Exec ["/bin/bash", "/usr/bin/i-nex-lspci", "nonprefetchable"] Wait To memory_non_prefetchable
  Try Exec ["/bin/bash", "/usr/bin/i-nex-lspci", "prefetchable"] Wait To memory_prefetchable
 
  Try Exec ["glxinfo"] Wait To GLIXNFO
  GLX = Split(GLIXNFO, "\n", "")
  For Each strings In GLX
   If strings Like "*OpenGL vendor string:*" Then
    Try Label105.Text = "OpenGL Vendor: " & Replace(strings, "OpenGL vendor string:", "")
   Endif
   If strings Like "*OpenGL renderer string:*" Then
    Try Label106.Text = "OpenGL Renderer: " & Replace(strings, "OpenGL renderer string:", "")
   Endif
   If strings Like "*OpenGL version string:*" Then
    Try Label107.Text = "OpenGL Version: " & Replace(strings, "OpenGL version string:", "")
   Endif
   If strings Like "*server glx vendor string:*" Then
    Try Label220.Text = "Server glx vendor: " & Replace(strings, "server glx vendor string:", "")
   Endif
   If strings Like "*server glx version string:*" Then
    Try Label221.Text = "Server glx version: " & Replace(strings, "server glx version string:", "")
   Endif
   If strings Like "*client glx vendor string:*" Then
    Try Label222.Text = "Client glx vendor: " & Replace(strings, "client glx vendor string:", "")
   Endif
   If strings Like "*client glx version string:*" Then
    Try Label224.Text = "Client glx version: " & Replace(strings, "client glx version string:", "")
   Endif
   If strings Like "*GLX version:*" Then
    Try Label225.Text = "GLX version: " & Replace(strings, "GLX version:", "")
   Endif
   If strings Like "*OpenGL ES profile version string:*" Then
    Try Label246.Text = "OpenGLES PVS: " & Replace(strings, "OpenGL ES profile version string:", "")
   Endif
   If strings Like "*OpenGL ES profile shading language version string:*" Then
    Try Label247.Text = "OpenGLES PSLVS: " & Replace(strings, "OpenGL ES profile shading language version string:", "")
   Endif
  Next

  Shell ChkPrm.ChkExecDir("lspci") & " -v -s `lspci | awk '/VGA/{print $1}'` | grep \"Kernel driver in use:\" | cut -d ':' -f 2" Wait To Kernel_driver_in_use
  Shell ChkPrm.ChkExecDir("lspci") & " | grep 'VGA' | cut -d ':' -f3 | cut -d '(' -f 1 | sed -n '1p'" Wait To gpu
  Shell ChkPrm.ChkExecDir("xrandr") & " | grep current | grep 'Screen 0:' | cut -d ':' -f 2" Wait To available_resolutions
  Shell ChkPrm.ChkExecDir("xdpyinfo") & " | grep 'dimensions:' | cut -d ':' -f 2" Wait To rozdzielczosc
  If IsNull(Kernel_driver_in_use) Or IsSpace(Kernel_driver_in_use) = True Then
   Try Exec [ChkPrm.ChkExecDir("xdriinfo")] Wait To Kernel_driver_in_use
  Endif

  Label136.Text = "Kernel driver in use: " & Replace(Kernel_driver_in_use, "\n", "")
  Try Label64.Text = "Total Memory prefetchable: " & Replace(memory_prefetchable, "\n", " - ")
  Try Label146.Text = "Total Memory non-prefetchable: " & Replace(memory_non_prefetchable, "\n", " - ")
  Label108.Text = "Present resolution: " & Replace(rozdzielczosc, "\n", "")
  TextBox1.Text = RTrim(Replace(gpu, "\n", ""))
  Label109.Text = Replace(available_resolutions, "\n", "")
 
  'GPU Logo Detection
  If RTrim(Replace(gpu, "\n", "")) Like "*ati*" Then
  Finfosys.PictureBox1.Picture = Picture["Data/GPU_LOGO/ati.png"]
  Finfosys.PictureBox1.Name = "ati.png"
  Endif
 
  If RTrim(Replace(gpu, "\n", "")) Like "*intel*" Then
  Finfosys.PictureBox1.Picture = Picture["Data/GPU_LOGO/intel.png"]
  Finfosys.PictureBox1.Name = "intel.png"
  Endif
 
  If RTrim(Replace(gpu, "\n", "")) Like "*nVidia*" Then
  Finfosys.PictureBox1.Picture = Picture["Data/GPU_LOGO/nvidia.png"]
  Finfosys.PictureBox1.Name = "nvidia.png"
  Endif

  If RTrim(Replace(gpu, "\n", "")) Like "*VirtualBox*" Then
  Finfosys.PictureBox1.Picture = Picture["Data/GPU_LOGO/virtualbox.png"]
  Finfosys.PictureBox1.Name = "virtualbox.png"
  Endif
 
  If RTrim(Replace(gpu, "\n", "")) Like "*VMware*" Then
  Finfosys.PictureBox1.Picture = Picture["Data/GPU_LOGO/vmware.png"]
  Finfosys.PictureBox1.Name = "vmware.png"
  Endif
  'GPU Logo Detection End
 
  ComboBox8.Index = 1
End

Offline allegfede

  • Gran Maestro dei Gamberi
  • *****
  • Post: 738
    • Mostra profilo
Re:Gambas GPU
« Risposta #1 il: 11 Novembre 2016, 20:13:35 »
i think is a reasonable way to do it.

I only think you cannot do more than display that info trough gambas, 'cause all avalaible gpu accelearation is (if present) in the modules you are adding to the project (sdl or media or ..)
se corri, morirai stanco (motto degli sniper)

Offline eloaders

  • Gamberetto
  • *
  • Post: 38
    • Mostra profilo
Re:Gambas GPU
« Risposta #2 il: 11 Novembre 2016, 23:06:28 »
The library can also be written in C. If it works I would use it with a Gambas Library and Extern

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.334
  • Ne mors quidem nos iunget
    • Mostra profilo
Re:Gambas GPU
« Risposta #3 il: 12 Novembre 2016, 00:01:34 »
What a library can be used in gambas to detect graphics card?
Currently I have something like this. I'm looking for a few days as I can do this using any library.

Codice: [Seleziona]
 Exec ["glxinfo"] 
In my opinion if you were using "glxinfo" program, you should find its source code....  
http://www.opensource.apple.com/source/X11apps/X11apps-13/glxinfo.c

......so you can be inspired.   
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »