Abend zusammen,
ich habe im Englischen Forum OpenGL Funktionen und Constants gefunden
Spoiler anzeigen
ich habe es auch schon soweit hinbekommen Kreise, Rechtecke usw zu zeichen jedoch nicht Texturen zu laden oder gar darzustellen. Bei Google habe ich nur die Info gefunden das OpenGL selber nicht die Texturen laden kann sonder das man sie selber irgentwie öffnen muss. Bis jetzt war ich soweit:
Spoiler anzeigen
#include <OpenGLfunctions.au3>
#include <OpenGLconstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global Const $PFD_TYPE_RGBA = 0
Global Const $PFD_MAIN_PLANE = 0
Global Const $PFD_DOUBLEBUFFER = 1
Global Const $PFD_DRAW_TO_WINDOW = 4
Global Const $PFD_SUPPORT_OPENGL = 32
Global $bild
Global $width = @DesktopHeight
Global $height = @DesktopHeight
Global $gui = GUICreate("OpenGL", $width,$height,$WS_POPUP, $WS_EX_TOPMOST);@DesktopWidth,@DesktopHeight)
GUISetBkColor(0xFFFFFF)
Global $dc
EnableOpenGL($gui, $dc)
glMatrixMode($GL_PROJECTION)
glViewport(0, 0,$width,$height)
glClear(BitOR($GL_COLOR_BUFFER_BIT, $GL_DEPTH_BUFFER_BIT)) ; initially cleaning buffers
GUISetState(@SW_SHOW)
GUISetOnEvent(-3, "Quit")
glGenTextures(1, $bild)
glBindTexture($GL_TEXTURE_2D, $bild)
glTexEnvf( $GL_TEXTURE_ENV, $GL_TEXTURE_ENV_MODE, $GL_MODULATE )
glTexParameterf( $GL_TEXTURE_2D, $GL_TEXTURE_MIN_FILTER, $GL_LINEAR_MIPMAP_NEAREST );
glTexParameterf( $GL_TEXTURE_2D, $GL_TEXTURE_MAG_FILTER, $GL_LINEAR );
glTexParameterf( $GL_TEXTURE_2D, $GL_TEXTURE_WRAP_S, $GL_REPEAT );
glTexParameterf( $GL_TEXTURE_2D, $GL_TEXTURE_WRAP_T, $GL_REPEAT );
Global $texture1 = glTexImage2D($GL_TEXTURE_2D, 0, $Gl_RGBA, 256, 256, 0, $Gl_RGBA, $GL_UNSIGNED_BYTE, @ScriptDir & "\bild.bmp")
While 1
glClear($GL_COLOR_BUFFER_BIT)
glEnable($GL_TEXTURE_2D)
glBindTexture($GL_TEXTURE_2D, $bild)
glBegin($GL_QUADS)
glTexcoord2f(0, 0)
glTexcoord2f(0, 0)
glTexcoord2f(0, 1)
glTexcoord2f(0, 1)
glTexcoord2f(1, 1)
glTexcoord2f(1, 1)
glTexcoord2f(1, 0)
glTexcoord2f(1, 0)
glEnd()
; _DrawViereck(500,500,800,500,800,800,500,800)
; _DrawViereck(10,10,10,800,80,800,50,10)
; _DrawQuadrat(100,100,20,20)
SwapBuffers($dc)
WEnd
Func _DrawViereck($x1,$y1,$x2,$y2,$x3,$y3,$x4,$y4)
glBegin($GL_QUADS)
glColor3f(0, 1, 0)
glVertex2f(($x1 - ($width / 2)) / ($width / 2), ($y1 - $height / 2) / ($height / 2))
glColor3f(1, 0, 0)
glVertex2f(($x2 - ($width / 2)) / ($width / 2), ($y2 - $height / 2) / ($height / 2))
glColor3f(0, 0, 1)
glVertex2f(($x3 - ($width / 2)) / ($width / 2), ($y3 - $height / 2) / ($height / 2))
glColor3f(1, 1, 0)
glVertex2f(($x4 - ($width / 2)) / ($width / 2), ($y4 - $height / 2) / ($height / 2))
glEnd()
EndFunc
Func _DrawQuadrat($x1,$y1,$width1,$height1)
glBegin($GL_QUADS)
glColor3f(0, 1, 0)
glVertex2f(($x1 - ($width / 2)) / ($width / 2), ($y1 - $height / 2) / ($height / 2))
glColor3f(1, 0, 0)
glVertex2f((($x1 + $width1) - ($width / 2)) / ($width / 2), ($y1 - $height / 2) / ($height / 2))
glColor3f(0, 0, 1)
glVertex2f((($x1 + $width1) - ($width / 2)) / ($width / 2), (($y1 + $height1) - $height / 2) / ($height / 2))
glColor3f(1, 1, 0)
glVertex2f(($x1 - ($width / 2)) / ($width / 2), (($y1 + $height1) - $height / 2) / ($height / 2))
;ToolTip (($x1 - ($width / 2)) / ($width / 2) & " | " & ($y1 - $height / 2) / ($height / 2) & " | " & ($x2 - ($width / 2)) / ($width / 2) & " | " & ($y2 - $height / 2) / ($height / 2) & " | " &($x3 - ($width / 2)) / ($width / 2) & " | " & ($y3 - $height / 2) / ($height / 2) & " | " &($x4 - ($width / 2)) / ($width / 2) & " | " & ($y4 - $height / 2) / ($height / 2))
glEnd()
EndFunc
Func EnableOpenGL($hwnd, ByRef $hDC)
Local $pfd = DllStructCreate("short nSize;" & _
"short nVersion;" & _
"dword dwFlags;" & _
"byte iPixelType;" & _
"byte cColorBits;" & _
"byte cRedBits;" & _
"byte cRedShift;" & _
"byte cGreenBits;" & _
"byte cGreenShift;" & _
"byte cBlueBits;" & _
"byte cBlueShift;" & _
"byte cAlphaBits;" & _
"byte cAlphaShift;" & _
"byte cAccumBits;" & _
"byte cAccumRedBits;" & _
"byte cAccumGreenBits;" & _
"byte cAccumBlueBits;" & _
"byte cAccumAlphaBits;" & _
"byte cDepthBits;" & _
"byte cStencilBits;" & _
"byte cAuxBuffers;" & _
"byte iLayerType;" & _
"byte bReserved;" & _
"dword dwLayerMask;" & _
"dword dwVisibleMask;" & _
"dword dwDamageMask;")
Local $h_dc = DllCall("user32.dll", "hwnd", "GetDC", "hwnd", $hwnd)
DllStructSetData($pfd, "nSize", DllStructGetSize($pfd))
DllStructSetData($pfd, "nVersion", $GL_VERSION_1_1)
DllStructSetData($pfd, "dwFlags", BitOR($PFD_DRAW_TO_WINDOW, $PFD_SUPPORT_OPENGL, $PFD_DOUBLEBUFFER))
DllStructSetData($pfd, "iPixelType", $PFD_TYPE_RGBA)
DllStructSetData($pfd, "cColorBits", 24)
DllStructSetData($pfd, "cDepthBits", 32)
DllStructSetData($pfd, "iLayerType", $PFD_MAIN_PLANE)
DllOpen("gdi32.dll")
DllOpen("opengl32.dll")
DllOpen("glu32.dll")
Local $iFormat = DllCall("gdi32.dll", "int", "ChoosePixelFormat", "hwnd", $h_dc[0], "ptr", DllStructGetPtr($pfd))
Local $iSetFormat = DllCall("gdi32.dll", "int", "SetPixelFormat", "hwnd", $h_dc[0], "int", $iFormat[0], "ptr", DllStructGetPtr($pfd))
Local $h_cont = DllCall("opengl32.dll", "hwnd", "wglCreateContext", "hwnd", $h_dc[0])
Local $iRet = DllCall("opengl32.dll", "int", "wglMakeCurrent", "int", $h_dc[0], "int", $h_cont[0])
$hDC = $h_dc[0]
Return 1
EndFunc ;==>EnableOpenGL
Func gluNewQuadric()
$h_qu = DllCall("glu32.dll", "hwnd", "gluNewQuadric")
Return $h_qu[0]
EndFunc ;==>gluNewQuadric
Func SwapBuffers($hDC)
DllCall("gdi32.dll", "int", "SwapBuffers", "hwnd", $hDC)
EndFunc ;==>SwapBuffers
Func Quit()
Exit
EndFunc ;==>Quit
Wäre cool wenn einer von den Profs hier ne Idee hätte
Edit: Hat den keiner ne Idee???