Ich hab im Moment keine #Includes aber Hier hab ich das komplette Skript.
Du brauchst noch ein Bild mit dem Namen File.png in deinem Skriptordner
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetBatchLines,-1
DllCall("LoadLibrary", "str", "opengl32")
DllCall("LoadLibrary", "str", "glu32")
DllCall("LoadLibrary", "str", "gdiplus")
Gui +LastFound
Gui, % "Color", 0, 0
hWnd := WinExist()
hDC := DllCall("GetDC", "ptr", hWnd, "ptr")
SetFormat,integer,H
VarSetCapacity(pfd, 40, 0)
NumPut(40, pfd, 0, "ushort")
NumPut(1, pfd, 2, "ushort")
NumPut(0x25, pfd, 4, "uint")
NumPut(24, pfd, 9, "uchar")
NumPut(0, pfd, 18, "uchar")
NumPut(16, pfd, 23, "uchar")
NumPut(0, pfd, 24, "uchar")
if (!(pf := DllCall("ChoosePixelFormat", "ptr", hDC, "ptr", &pfd)))
ExitApp, -1
if (!DllCall("SetPixelFormat", "ptr", hDC, "int", pf, "ptr", &pfd))
ExitApp, -1
if (!(hRC := DllCall("opengl32\wglCreateContext", "ptr", hDC, "ptr")))
ExitApp, -1
DllCall("opengl32\wglMakeCurrent", "ptr", hDC, "ptr", hRC)
DllCall("opengl32\glEnable", "uint", 0x0B71)
DllCall("opengl32\glDepthFunc", "uint", 0x0203)
DllCall("opengl32\glEnable", "uint", 0x0DE1)
DllCall("opengl32\glEnable", "uint", 0x0BE2) ;GL_BLEND
DllCall("opengl32\glBlendFunc","uint",0x0302,"uint",0x0303)
DllCall("opengl32\glEnable", "uint", 0x0BC0)
Gui, % "Show", % "w" 800 " h" 600 , test
sleep,200
if (!DllCall("opengl32\wglMakeCurrent", "ptr", hDC, "ptr", hRC))
ExitApp, -1
DllCall("opengl32\glClear", "uint", 0x00004100)
DllCall("opengl32\glMatrixMode", "uint", 0x1701)
DllCall("opengl32\glLoadIdentity")
DllCall("opengl32\glOrtho", "double", -4, "double", 4, "double", -3, "double", 3, "double", 0, "double", 4)
DllCall("opengl32\glMatrixMode", "uint", 0x1700)
DllCall("opengl32\glLoadIdentity")
v:=aglLoadMipmaps2D(0x0DE1, "File.png")
llist:=DllCall("opengl32\glGenLists", "int", 1, "uint")
DllCall("opengl32\glNewList", "uint", llist, "uint", 0x1301)
DllCall("opengl32\glBegin", "uint", 7)
DllCall("opengl32\glBindTexture", "uint", 0x0DE1, "uint",v)
DllCall("opengl32\glTexCoord2f", "float", 0, "float", 1)
DllCall("opengl32\glVertex4f", "float", 1, "float", 1, "float", 0, "float", 1)
DllCall("opengl32\glTexCoord2f", "float", 1, "float", 1)
DllCall("opengl32\glVertex4f", "float", 3, "float", 1, "float", 0, "float", 1)
DllCall("opengl32\glTexCoord2f", "float", 1, "float", 0)
DllCall("opengl32\glVertex4f", "float", 3, "float", -1, "float", 0, "float", 1)
DllCall("opengl32\glTexCoord2f", "float", 0, "float", 0)
DllCall("opengl32\glVertex4f", "float", 1, "float", -1, "float", 0, "float", 1)
DllCall("opengl32\glEnd")
DllCall("opengl32\glBegin", "uint", 7)
DllCall("opengl32\glTexCoord2f", "float", 0, "float", 1)
DllCall("opengl32\glVertex4f", "float", -1, "float", 1, "float", 0, "float", 1)
DllCall("opengl32\glTexCoord2f", "float", 1, "float", 1)
DllCall("opengl32\glVertex4f", "float", -3, "float", 1, "float", 0, "float", 1)
DllCall("opengl32\glTexCoord2f", "float", 1, "float", 0)
DllCall("opengl32\glVertex4f", "float", -3, "float", -1, "float", 0, "float", 1)
DllCall("opengl32\glTexCoord2f", "float", 0, "float", 0)
DllCall("opengl32\glVertex4f", "float", -1, "float", -1, "float", 0, "float", 1)
DllCall("opengl32\glEnd")
DllCall("opengl32\glBegin", "uint", 7)
DllCall("opengl32\glVertex4f", "float", 1, "float", 1, "float", 0, "float", 1)
DllCall("opengl32\glVertex4f", "float", -1, "float", 1, "float", 0, "float", 1)
DllCall("opengl32\glVertex4f", "float", -1, "float", -1, "float", 0, "float", 1)
DllCall("opengl32\glVertex4f", "float", 1, "float", -1, "float", 0, "float", 1)
DllCall("opengl32\glEnd")
DllCall("opengl32\glEndList")
Loop
{
DllCall("opengl32\wglMakeCurrent", "ptr", hDC, "ptr", hRC)
DllCall("opengl32\glLoadIdentity")
DllCall("opengl32\glViewport", "int", 0, "int", 0, "int", 800, "int", 600)
t:=A_Index
loop,3
{
DllCall("opengl32\glPushMatrix")
DllCall("opengl32\glRotatef", "float", 0, "float", 1.0, "float", 0.0, "float", 0.0)
DllCall("opengl32\glRotatef", "float", 0, "float", 0.0, "float", 1.0, "float", 0.0)
DllCall("opengl32\glRotatef", "float", t*A_Index, "float", 0.0, "float", 0.0, "float", 1.0)
DllCall("opengl32\glCallList", "uint", llist)
DllCall("opengl32\glRotatef", "float", -t*A_Index, "float", 0.0, "float", 0.0, "float", 1.0)
DllCall("opengl32\glRotatef", "float", 0, "float", 0.0, "float", 1.0, "float", 0.0)
DllCall("opengl32\glRotatef", "float", 0, "float", 1.0, "float", 0.0, "float", 0.0)
DllCall("opengl32\glPopMatrix")
}
DllCall("opengl32\glPushMatrix")
DllCall("opengl32\glColor4f", "float", 1, "float", 1, "float", 1, "float", 5)
DllCall("opengl32\glBegin", "uint", 7)
DllCall("opengl32\glTexCoord2f", "float", 1, "float", 1)
DllCall("opengl32\glVertex4f", "float", 2, "float", 2, "float", 0, "float", 1)
DllCall("opengl32\glTexCoord2f", "float", 0, "float", 1)
DllCall("opengl32\glVertex4f", "float", -2, "float", 2, "float", 0, "float", 1)
DllCall("opengl32\glTexCoord2f", "float", 0, "float", 0)
DllCall("opengl32\glVertex4f", "float", -2, "float", -2, "float", 0, "float", 1)
DllCall("opengl32\glTexCoord2f", "float", 1, "float", 0)
DllCall("opengl32\glVertex4f", "float", 2, "float", -2, "float", 0, "float", 1)
DllCall("opengl32\glEnd")
DllCall("opengl32\glPopMatrix")
DllCall("opengl32\wglMakeCurrent", "ptr", hDC, "ptr", hRC)
DllCall("SwapBuffers", "ptr", hDC, "ptr", hRC)
DllCall("opengl32\glClear", "uint", 0x00004300)
}
ExitApp
__aglChangeTextureColorDepth(byref hBitmap)
{
ptr := (A_PtrSize) ? "ptr" : "uint"
size := DllCall("GetObject", ptr, hBitmap, "int", 0, ptr, 0)
VarSetCapacity(bmi, size, 0)
DllCall("GetObject", ptr, hBitmap, "int", size, ptr, &bmi)
w := NumGet(bmi, 4, "int")
h := NumGet(bmi, 8, "int")
hDC := DllCall("GetDC", ptr, 0, ptr)
hDCsrc := DllCall("CreateCompatibleDC", ptr, hDC, ptr)
hDCdst := DllCall("CreateCompatibleDC", ptr, hDC, ptr)
DllCall("ReleaseDC", ptr, hDC)
DllCall("SelectObject", ptr, hDCsrc, ptr, hBitmap)
VarSetCapacity(bmi, 40, 0)
NumPut(40, bmi, 0, "uint")
NumPut(w, bmi, 4, "int")
NumPut(h, bmi, 8, "int")
NumPut(1, bmi, 12, "ushort")
NumPut(32, bmi, 14, "ushort")
hBitmapDst := DllCall("CreateDIBSection", ptr, hDCdst, ptr, &bmi, "uint", 0, ptr, 0, ptr, 0, ptr)
DllCall("SelectObject", ptr, hDCdst, ptr, hBitmapDst)
DllCall("BitBlt", ptr, hDCdst, "int", 0, "int", 0, "int", w, "int", h, ptr, hDCsrc, "int", 0, "int", 0, "uint", 0x00CC0020)
DllCall("DeleteDC", ptr, hDCsrc)
DllCall("DeleteDC", ptr, hDCdst)
DllCall("DeleteObject", ptr, hBitmap)
hBitmap := hBitmapDst
return 1
}
aglGetInteger(pname)
{
ptr := (A_PtrSize) ? "ptr" : "uint"
VarSetCapacity(param, 4, 0)
DllCall("opengl32\glGetIntegerv", "uint", pname, ptr, ¶m)
return NumGet(param, 0, "int")
}
aglIsExt(ext)
{
astr := (A_IsUnicode) ? "astr" : "str"
extensions := DllCall("opengl32\glGetString", "uint", 0x1F03, astr)
if (instr(" " extensions " ", " " ext " "))
return 1
return 0
}
aglGetVersion()
{
astr := (A_IsUnicode) ? "astr" : "str"
if (!version := DllCall("opengl32\glGetString", "uint", 0x1F02, astr))
return 0
maj := substr(version, 1, (p := instr(version, "."))-1)
min := substr(version, p+1)
if (p := instr(min, "."))
min := substr(min, 1, p-1)
if (p := instr(min, " "))
min := substr(min, 1, p-1)
if (!min)
min := 0
return maj "." min
}
aglGenTexture()
{
ptr := (A_PtrSize) ? "ptr" : "uint"
VarSetCapacity(tex, 4, 0)
DllCall("opengl32\glGenTextures", "int", 1, ptr, &tex)
return NumGet(tex, 0, "uint")
}
__aglTextureBitmap(filename, resize, byref w, byref h, byref format, byref type, byref data)
{
ptr := (A_PtrSize) ? "ptr" : "uint"
sptr := (A_PtrSize) ? A_PtrSize : 4
if (!fileexist(filename))
return 0
if (!(hBitmap := __aglLoadTextureGdip(filename)))
{
if (!(hBitmap := __aglLoadTextureGdi(filename)))
hBitmap := __aglLoadTextureTga(filename)
}
if (!hBitmap)
return 0
size := DllCall("GetObject", ptr, hBitmap, "int", 0, ptr, 0)
VarSetCapacity(bmi, size, 0)
DllCall("GetObject", ptr, hBitmap, "int", size, ptr, &bmi)
w := NumGet(bmi, 4, "int")
h := NumGet(bmi, 8, "int")
bpp := NumGet(bmi, 14+sptr, "short")
if (resize)
{
__aglCalcTexSize(w, h, neww, newh)
if ((neww != w) || (newh != h))
{
if (!__aglResizeTexture(hBitmap, neww, newh))
{
DllCall("DeleteObject", ptr, hBitmap)
return 0
}
}
}
bmformat := "BGR"
if ((aglGetVersion() < 1.2) || (!resize))
{
if (__aglRecolorTexture(hBitmap))
bmformat := "RGB"
}
DllCall("GetObject", ptr, hBitmap, "int", size, ptr, &bmi)
w := NumGet(bmi, 4, "int")
h := NumGet(bmi, 8, "int")
bpp := NumGet(bmi, 14+sptr, "short")
data := NumGet(bmi, 16+sptr, ptr)
if (bpp=32)
{
format := (bmformat="RGB") ? 0x1908 : 0x80E1 ;GL_RGBA : GL_BGRA_EXT
type := 0x1401 ;GL_UNSIGNED_BYTE
if (data)
return 1
}
else if (bpp=24)
{
format := (bmformat="RGB") ? 0x1907 : 0x80E0 ;GL_RGB : GL_BGR_EXT
type := 0x1401 ;GL_UNSIGNED_BYTE
if (data)
return 1
}
if (!__aglChangeTextureColorDepth(hBitmap))
{
DllCall("DeleteObject", ptr, hBitmap)
return 0
}
DllCall("GetObject", ptr, hBitmap, "int", size, ptr, &bmi)
w := NumGet(bmi, 4, "int")
h := NumGet(bmi, 8, "int")
bpp := NumGet(bmi, 14+sptr, "short")
data := NumGet(bmi, 16+sptr, ptr)
format := (bmformat="RGB") ? 0x1908 : 0x80E1 ;GL_RGBA : GL_BGRA_EXT
type := 0x1401 ;GL_UNSIGNED_BYTE
return 1
}
__aglRecolorTexture(byref hBitmap)
{
static matrixstr := "0|0|1|0|0|0|1|0|0|0|1|0|0|0|0|0|0|0|1|0|0|0|0|0|1"
ptr := (A_PtrSize) ? "ptr" : "uint"
sptr := (A_PtrSize) ? A_PtrSize : 4
size := DllCall("GetObject", ptr, hBitmap, "int", 0, ptr, 0)
VarSetCapacity(bmi, size, 0)
DllCall("GetObject", ptr, hBitmap, "int", size, ptr, &bmi)
w := NumGet(bmi, 4, "int")
h := NumGet(bmi, 8, "int")
if (!DllCall("GetModuleHandle", "str", "gdiplus", ptr))
{
if (!(hGdip := DllCall("LoadLibrary", "str", "gdiplus", ptr)))
nogdip := 1
}
if (!nogdip)
{
VarSetCapacity(token, sptr, 0)
VarSetCapacity(input, 12+sptr, 0)
NumPut(1, input, 0, "uint")
DllCall("gdiplus\GdiplusStartup", ptr, &token, ptr, &input, ptr, 0)
DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", ptr, hBitmap, "int", 0, ptr "*", srcbitmap)
DllCall("DeleteObject", ptr, hBitmap)
DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", w, "int", h, "int", 0, "int", 0x26200A, ptr, 0, ptr "*", dstbitmap)
DllCall("gdiplus\GdipGetImageGraphicsContext", ptr, dstbitmap, ptr "*", dstgraphic)
DllCall("gdiplus\GdipCreateImageAttributes", ptr "*", attrib)
VarSetCapacity(matrix, 100, 0)
Loop, parse, matrixstr, |
NumPut(A_LoopField, matrix, (A_Index-1)*4, "float")
DllCall("gdiplus\GdipSetImageAttributesColorMatrix", ptr, attrib, "int", 1, "int", 1, ptr, &matrix, "int", 0, "int", 0)
DllCall("gdiplus\GdipDrawImageRectRectI", ptr, dstgraphic, ptr, srcbitmap, "int", 0, "int", 0, "int", w, "int", h, "int", 0, "int", 0, "int", w, "int", h, "int", 2, ptr, attrib, ptr, 0, ptr, 0)
DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", ptr, dstbitmap, ptr "*", hBitmap, "uint", 0xFF000000)
DllCall("gdiplus\GdipDeleteGraphics", ptr, dstgraphic)
DllCall("gdiplus\GdipDisposeImage", ptr, srcbitmap)
DllCall("gdiplus\GdipDisposeImage", ptr, dstbitmap)
DllCall("gdiplus\GdipDisposeImageAttributes", ptr, attrib)
DllCall("gdiplus\GdiplusShutdown", ptr, &token)
if (hGdip)
DllCall("FreeLibrary", ptr, hGdip)
return 1
}
return 0
}
__aglResizeTexture(byref hBitmap, neww, newh)
{
ptr := (A_PtrSize) ? "ptr" : "uint"
sptr := (A_PtrSize) ? A_PtrSize : 4
size := DllCall("GetObject", ptr, hBitmap, "int", 0, ptr, 0)
VarSetCapacity(bmi, size, 0)
DllCall("GetObject", ptr, hBitmap, "int", size, ptr, &bmi)
w := NumGet(bmi, 4, "int")
h := NumGet(bmi, 8, "int")
if (!DllCall("GetModuleHandle", "str", "gdiplus", ptr))
{
if (!(hGdip := DllCall("LoadLibrary", "str", "gdiplus", ptr)))
nogdip := 1
}
if (!nogdip)
{
VarSetCapacity(token, sptr, 0)
VarSetCapacity(input, 12+sptr, 0)
NumPut(1, input, 0, "uint")
DllCall("gdiplus\GdiplusStartup", ptr, &token, ptr, &input, ptr, 0)
DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", ptr, hBitmap, "int", 0, ptr "*", srcbitmap)
DllCall("DeleteObject", ptr, hBitmap)
DllCall("gdiplus\GdipCreateBitmapFromScan0", "int", neww, "int", newh, "int", 0, "int", 0x26200A, ptr, 0, ptr "*", dstbitmap)
DllCall("gdiplus\GdipGetImageGraphicsContext", ptr, dstbitmap, ptr "*", dstgraphic)
DllCall("gdiplus\GdipCreateImageAttributes", ptr "*", attrib)
DllCall("gdiplus\GdipSetImageAttributesColorMatrix", ptr, attrib, "int", 1, "int", 1, ptr, 0, "int", 0, "int", 0)
DllCall("gdiplus\GdipSetInterpolationMode", ptr, dstgraphic, "int", 3)
DllCall("gdiplus\GdipDrawImageRectRectI", ptr, dstgraphic, ptr, srcbitmap, "int", 0, "int", 0, "int", neww, "int", newh, "int", 0, "int", 0, "int", w, "int", h, "int", 2, ptr, attrib, ptr, 0, ptr, 0)
DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", ptr, dstbitmap, ptr "*", hBitmap, "uint", 0xFF000000)
DllCall("gdiplus\GdipDeleteGraphics", ptr, dstgraphic)
DllCall("gdiplus\GdipDisposeImage", ptr, srcbitmap)
DllCall("gdiplus\GdipDisposeImage", ptr, dstbitmap)
DllCall("gdiplus\GdipDisposeImageAttributes", ptr, attrib)
DllCall("gdiplus\GdiplusShutdown", ptr, &token)
if (hGdip)
DllCall("FreeLibrary", ptr, hGdip)
return 1
}
hDC := DllCall("GetDC", ptr, 0, ptr)
hDCsrc := DllCall("CreateCompatibleDC", ptr, hDC, ptr)
hDCdst := DllCall("CreateCompatibleDC", ptr, hDC, ptr)
DllCall("ReleaseDC", ptr, hDC)
DllCall("SelectObject", ptr, hDCsrc, ptr, hBitmap)
VarSetCapacity(bmi, 40, 0)
NumPut(40, bmi, 0, "uint")
NumPut(neww, bmi, 4, "int")
NumPut(newh, bmi, 8, "int")
NumPut(1, bmi, 12, "ushort")
NumPut(32, bmi, 14, "ushort")
hBitmapDst := DllCall("CreateDIBSection", ptr, hDCdst, ptr, &bmi, "uint", 0, ptr, 0, ptr, 0, ptr)
DllCall("SelectObject", ptr, hDCdst, ptr, hBitmapDst)
DllCall("SetStretchBltMode", ptr, hDCdst, "int", 4)
DllCall("SetBrushOrgEx", ptr, hDCdst, "int", 2, "int", 2, ptr, 0)
DllCall("StretchBlt", ptr, hDCdst, "int", 0, "int", 0, "int", neww, "int", newh, ptr, hDCsrc, "int", 0, "int", 0, "int", w, "int", h, "uint", 0x00CC0020)
DllCall("DeleteDC", ptr, hDCsrc)
DllCall("DeleteDC", ptr, hDCdst)
DllCall("DeleteObject", ptr, hBitmap)
hBitmap := hBitmapDst
return 1
}
__aglCalcTexSize(w, h, byref neww, byref newh)
{
maxsize := aglGetInteger(0x0D33) ;GL_MAX_TEXTURE_SIZE
if ((w > maxsize) || (h > maxsize) || ((aglGetVersion() < 2.1) && (!aglIsExt("GL_ARB_texture_non_power_of_two"))))
{
sizes := 0
Loop
{
if ((2**(A_Index-1)) > maxsize)
break
sizes ++
}
Loop, % sizes-1
{
if ((2**(A_Index-1))>=w)
break
neww := (2**A_Index)
}
Loop, % sizes-1
{
if ((2**(A_Index-1))>=h)
break
newh := (2**A_Index)
}
return 1
}
neww := w
newh := h
return 1
}
__aglLoadTextureGdi(filename)
{
ptr := (A_PtrSize) ? "ptr" : "uint"
if (hBitmap := DllCall("LoadImage", ptr, 0, "str", filename, "uint", 0, "int", 0, "int", 0, "uint", 0x10))
return hBitmap
return 0
}
__aglLoadTextureTga(filename)
{
ptr := (A_PtrSize) ? "ptr" : "uint"
if (!(hFile := DllCall("CreateFile", "str", filename, "uint", 0x80000000, "uint", 1, ptr, 0, "uint", 3, "uint", 0, ptr, 0, ptr)))
return 0
size := DllCall("GetFileSize", ptr, hFile, ptr, 0, "uint")
if (size > 4096*4096*4 + 300)
return 0
VarSetCapacity(file, size, 0)
if ((!DllCall("ReadFile", ptr, hFile, ptr, &file, "uint", size, "uint*", read, ptr, 0)) || (read < size))
{
DllCall("CloseHandle", ptr, hFile)
return 0
}
DllCall("CloseHandle", ptr, hFile)
identicationlength := NumGet(file, 0, "uchar")
colormaptype := NumGet(file, 1, "uchar")
imagetype := NumGet(file, 2, "uchar")
colormaporign := NumGet(file, 3, "ushort")
colormaplength := NumGet(file, 5, "ushort")
colormapentrysize := NumGet(file, 7, "uchar")
xorign := NumGet(file, 8, "ushort")
yorign := NumGet(file, 10, "ushort")
w := NumGet(file, 12, "ushort")
h := NumGet(file, 14, "ushort")
bitcount := NumGet(file, 16, "uchar")
imagedescriptor := NumGet(file, 17, "uchar")
numattrib := imagedescriptor & 0xF
screenorign := imagedescriptor & 0x20
interleaving := (imagedescriptor & 0xC0) >> 6
identication := &file + 18
colormap := identication + identicationlength
imagedata := colormap + (colormaplength * colormapentrysize)
imagedatalength := size - (18 + identicationlength + (colormaplength * colormapentrysize))
if imagetype not in 1,2,3,9,10,11,32,33 ;all types
return 0
;0 - No image data included.
;1 - Uncompressed, color-mapped images.
;2 - Uncompressed, RGB images.
;3 - Uncompressed, black and white images.
;9 - Runlength encoded color-mapped images.
;10 - Runlength encoded RGB images.
;11 - Compressed, black and white images.
;32 - Compressed color-mapped data, using Huffman, Delta, and runlength encoding.
;33 - Compressed color-mapped data, using Huffman, Delta, and runlength encoding. 4-pass quadtree-type process.
if imagetype not in 2,3 ;currently supportet types
return 0
VarSetCapacity(bmi, 40, 0)
NumPut(40, bmi, 0, "int")
NumPut(w, bmi, 4, "int")
NumPut((screenorign) ? -h : h, bmi, 8, "int")
NumPut(1, bmi, 12, "ushort")
if imagetype in 1,9,32
NumPut(bpp := colormapentrysize, bmi, 14, "ushort")
else
NumPut(bpp := bitcount, bmi, 14, "ushort")
if imagetype in 9,10
NumPut(2, bmi, 16, "uint")
datasize := w*h*Round(bpp/8)
if (imagedatalength > datasize)
imagedatalength := datasize
hDC := DllCall("GetDC", ptr, 0, ptr)
hDCbm := DllCall("CreateCompatibleDC", ptr, hDC, ptr)
DllCall("ReleaseDC", ptr, hDC)
if (hBitmap := DllCall("CreateDIBSection", ptr, hDCbm, ptr, &bmi, "uint", 0, ptr "*", bits, ptr, 0, ptr))
DllCall("RtlMoveMemory", ptr, bits, ptr, imagedata, "uint", imagedatalength)
DllCall("DeleteDC", ptr, hDCbm)
return hBitmap
}
__aglLoadTextureGdip(filename)
{
ptr := (A_PtrSize) ? "ptr" : "uint"
sptr := (A_PtrSize) ? A_PtrSize : 4
astr := (A_IsUnicode) ? "astr" : "str"
if (!DllCall("GetModuleHandle", "str", "gdiplus", ptr))
{
if (!(hGdip := DllCall("LoadLibrary", "str", "gdiplus", ptr)))
return 0
}
VarSetCapacity(token, sptr, 0)
VarSetCapacity(input, 12+sptr, 0)
NumPut(1, input, 0, "uint")
DllCall("gdiplus\GdiplusStartup", ptr, &token, ptr, &input, ptr, 0)
VarSetCapacity(wfilename, wfilenamesize := (strlen(filename)*2+2), 0)
DllCall("MultiByteToWideChar", "uint", 0, "uint", 0, astr, filename, "int", -1, ptr, &wfilename, "int", wfilenamesize)
DllCall("gdiplus\GdipCreateBitmapFromFile", ptr, &wfilename, ptr "*", bitmap)
DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", ptr, bitmap, ptr "*", hBitmap, "uint", 0xFF000000)
DllCall("gdiplus\GdipDisposeImage", ptr, bitmap)
DllCall("gdiplus\GdiplusShutdown", ptr, &token)
if (hGdip)
DllCall("FreeLibrary", ptr, hGdip)
return hBitmap
}
aglLoadMipmaps2D(target, filename, components=4, minfilter=0x2601, magfilter=0x2601, loadonce=0)
{
static
if (loadonce)
{
loop, % loaded
{
if (tex_%A_Index% = filename)
return texnum_%A_Index%
}
}
ptr := (A_PtrSize) ? "ptr" : "uint"
if (!(__aglTextureBitmap(filename, 0, w, h, format, type, data)))
return 0
tex := aglGenTexture()
DllCall("opengl32\glBindTexture", "uint", target, "uint", tex)
DllCall("opengl32\glTexParameteri", "uint", target, "uint", 0x2800, "uint", magfilter)
DllCall("opengl32\glTexParameteri", "uint", target, "uint", 0x2801, "uint", minfilter)
DllCall("glu32\gluBuild2DMipmaps", "uint", target, "uint", components, "int", w, "int", h, "int", format, "uint", type, ptr, data)
DllCall("DeleteObject", ptr, hBitmap)
loaded := (!loaded) ? 1 : loaded+1
tex_%loaded% := filename
texnum_%loaded% := tex
return tex
}