Ich experimentiere gerade etwas mit OpenGL und bin dabei über ein Problem gestolpert.
Die glOrtho zeigt keine Reaktion, ich weiß aber auch nicht wo der Fehler liegen sollte.
Kennt sich jemand damit aus???
Spoiler anzeigen
#include <GuiConstants.au3>
#include <OpenGL.au3>
#include <Math.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>
Global $GUI, $DC, $OpenGL
[/autoit] [autoit][/autoit] [autoit]$GUI = GuiCreate("OpenGl", 800, 600, -1, -1 , $WS_SIZEBOX + $WS_SYSMENU + $WS_MINIMIZEBOX + $WS_MAXIMIZEBOX)
$OpenGL = GUICtrlCreateOpenGL($DC, 0, 0, 800, 600)
If @Error Then Exit
GUICtrlSetResizing($OpenGL, $GUI_DOCKBORDERS)
_GUIScrollBars_Init($GUI)
_GUIScrollBars_SetScrollInfoPage($GUI, $SB_VERT, 600)
_GUIScrollBars_SetScrollInfoPage($GUI, $SB_HORZ, 800)
_GUIScrollBars_ShowScrollBar($gui, $SB_BOTH)
$pos = ControlGetPos($GUI, "", $OpenGL)
glViewport(0, 0, $pos[2], $pos[3])
glMatrixMode($GL_PROJECTION)
glLoadIdentity()
glOrtho(0, 9, 0, 9, -1, 1)
glMatrixMode($GL_MODELVIEW)
glLoadIdentity()
glColor3f(0, 0, 1)
glClearColor(1, 1, 1, 1)
GuiSetState()
While 1
$msg = GuiGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
glClear($GL_COLOR_BUFFER_BIT)
[/autoit] [autoit][/autoit] [autoit]glBegin($GL_QUADS)
glVertex2i(0,
glVertex2i(8,
glVertex2i(8, 0)
glVertex2i(0, 0)
glEnd()
SwapBuffers($DC)
WEnd
Func GUICtrlCreateOpenGL(ByRef $hDC, $x, $y, $width, $height)
Local $control = GUICtrlCreateLabel("", $x, $y, $width, $height)
Local Const $PFD_TYPE_RGBA = 0
Local Const $PFD_MAIN_PLANE = 0
Local Const $PFD_DOUBLEBUFFER = 1
Local Const $PFD_DRAW_TO_WINDOW = 4
Local Const $PFD_SUPPORT_OPENGL = 32
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", GUICtrlGetHandle($control))
[/autoit] [autoit][/autoit] [autoit]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", 16)
DllStructSetData($pfd, "iLayerType", $PFD_MAIN_PLANE)
Global $gdi = DllOpen("gdi32.dll")
If @Error Then
SetError(1)
Return 0
EndIf
Global $opengl = DllOpen("opengl32.dll")
If @Error Then
SetError(1)
Return 0
EndIf
Local $iFormat = DllCall($gdi, "int", "ChoosePixelFormat", "hwnd", $h_dc[0], "ptr", DllStructGetPtr($pfd))
Local $iSetFormat = DllCall($gdi, "int", "SetPixelFormat", "hwnd", $h_dc[0], "int", $iFormat[0], "ptr", DllStructGetPtr($pfd))
Local $h_cont = DllCall($opengl, "hwnd", "wglCreateContext", "hwnd", $h_dc[0])
Local $iRet = DllCall($opengl, "int", "wglMakeCurrent", "int", $h_dc[0], "int", $h_cont[0])
$hDC = $h_dc[0]
[/autoit] [autoit][/autoit] [autoit]Return $control
EndFunc ;==>EnableOpenGL
Func SwapBuffers($hDC)
DllCall($gdi, "int", "SwapBuffers", "hwnd", $hDC)
EndFunc ;==>SwapBuffers
Edit: Auf die Nutzung des Plugin würde ich gerne verzichten. Das macht das umschreiben in eine andere Sprache nur kompliziert, falls Autoit zu langsam ist.
Edit2: OK, doofe Frage. glOrtho legt nur den Zeichenbereich fest, Transformiert wird mit glScalef und glTranslatef. Gelöst^^