Last active
May 16, 2019 17:36
-
-
Save jNizM/97f12722cc22c3b1065f to your computer and use it in GitHub Desktop.
[AHK] NVIDIA Graphics Memory Size and Usage in OpenGL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; =============================================================================================================================== | |
; Title .........: GPU_MEMORY_INFO | |
; AHK Version ...: 1.1.15.01 x64 Unicode | |
; Win Version ...: Windows 7 Professional x64 SP1 | |
; Description ...: GPU_MEMORY_INFO | |
; NVIDIA Graphics Memory Size and Usage in OpenGL | |
; Version .......: v1.00 | |
; Modified ......: 2014.06.27-2150 | |
; Author(s) .....: jNIzM | |
; =============================================================================================================================== | |
;@Ahk2Exe-SetName GPU_MEMORY_INFO | |
;@Ahk2Exe-SetDescription GPU_MEMORY_INFO | |
;@Ahk2Exe-SetVersion v1.00 | |
;@Ahk2Exe-SetCopyright Copyright (c) 2013-2014`, jNizM | |
;@Ahk2Exe-SetOrigFilename GPU_MEMORY_INFO.ahk | |
; =============================================================================================================================== | |
; GLOBAL SETTINGS =============================================================================================================== | |
#NoEnv | |
SetBatchLines, -1 | |
; SCRIPT ======================================================================================================================== | |
NV := New NVDLg() | |
MsgBox % "OpenGL memory:`nTotal:`t" NV.total "`nCurrent:`t" NV.current "`nUsage:`t" NV.total - NV.current | |
; CLASS ========================================================================================================================= | |
Class NVDlg | |
{ | |
__New() | |
{ | |
this.hmodule := DllCall("LoadLibrary", "str", "opengl32.dll", "ptr") | |
Gui, +LastFound +Resize | |
this.hdc := DllCall("user32.dll\GetDC", "ptr", WinExist()) | |
NumPut(VarSetCapacity(pfd, 40), pfd, "ushort"), NumPut(1, pfd, 2, "ushort") | |
, NumPut(37, pfd, 4, "uint"), NumPut(0, pfd, 8, "uchar") | |
, NumPut(32, pfd, 9, "uchar"), NumPut(24, pfd, 23, "uchar") | |
DllCall("gdi32.dll\SetPixelFormat", "ptr", this.hdc, "int", DllCall("gdi32.dll\ChoosePixelFormat", "ptr", this.hdc, "ptr", &pfd), "ptr", &pfd) | |
this.hglrc := DllCall("opengl32.dll\wglCreateContext", "ptr", this.hdc) | |
DllCall("opengl32.dll\wglMakeCurrent", "ptr", this.hdc, "ptr", this.hglrc) | |
} | |
__Get(name) | |
{ | |
enum := (name = "total") ? 0x9048 : (name = "current") ? 0x9049 : 0x9047 | |
VarSetCapacity(param, 4, 0), DllCall("opengl32.dll\glGetIntegerv", "uint", enum, "ptr", ¶m) | |
return Round(NumGet(param, 0, "int") / 1024, 0) | |
} | |
__Delete() | |
{ | |
DllCall("opengl32.dll\wglMakeCurrent", "uint", 0, "uint", 0) | |
DllCall("opengl32.dll\wglDeleteContext", "uint", this.hglrc) | |
DllCall("user32.dll\ReleaseDC", "ptr", this.hdc) | |
DllCall("FreeLibrary", "ptr", this.hmodule) | |
} | |
} | |
; EXIT ========================================================================================================================== | |
ExitApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment