eynstyne Posted July 9, 2007 Posted July 9, 2007 (edited) The Example OpenGL script in Dev C++ will work. I translated the C script as best as I can to autoit, but the basic shapes and vertices colors do not appear! I'm looking at my script and logically it should work. What proves that 3D is somewhat possible is that when you comment out glClear, You will get video buffers inside that window. Why doesn't 3D work in autoit? Anyway enough talk here is the code: CODE #include <guiconstants.au3> ;================================ ; 3d UDF (uses opengl and glu32.dll) ; Glu32.dll and other parts omitted for length ; Author :eynstyne ;================================ Const $PFD_TYPE_RGBA = 0 Const $GL_COLOR_BUFFER_BIT = 0x00004000 Const $GL_TRIANGLES = 0x0004 Const $PFD_MAIN_PLANE = 0 Const $PFD_DOUBLEBUFFER = 1 Const $PFD_DRAW_TO_WINDOW = 4 Const $PFD_SUPPORT_OPENGL = 32 Local $dc, $hdc $gui = GuiCreate("OpenGL",256,256,-1,-1) GuiSetBkColor(0x000000) GuiSetstate(@SW_SHOW) EnableOpenGL($gui,$dc,$hc) glFlush() $i = 0 While 1 $i = $i + 1 glClearColor(0,0,0,0) glClear($GL_COLOR_BUFFFER_BIT) glPushMatrix() glRotatei($i,0,0,1) glBegin($GL_TRIANGLES) glColor3i(1.0,0.0,0.0) glVertex2i(0,1) glColor3i(0.0,1.0,0.0) glVertex2i(.87,-.5) glColor3i(0.0,0.0,1.0) glVertex2i(-.87,-.5) glend() glPopMatrix() swapbuffers($dc) $msg = Guigetmsg() Switch $msg Case $GUI_EVENT_CLOSE DisableOpenGL($gui,$dc,$hc) Exit Wend ;===THE OPEN GL FUNCTIONS=== func EnableOpenGL($hwnd,Byref $varhdc,ByRef $varhrc) ;PFD is PIXELFORMATDESCRIPTOR TYPE in WINAPI $PFD=Dllstructcreate("short;short;int;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte;byte ;byte;byte;byte;int;int") $DC = Dllcall("user32.dll","int","GetDC","hwnd",$hwnd) Dllstructsetdata($PFD,1,Dllstructgetsize($PFD)) Dllstructsetdata($PFD,2,1) Dllstructsetdata($PFD,3,$PFD_DRAW_TO_WINDOW+$PFD_SUPPORT_OPENGL+$PFD_DOUBLEBUFFER) Dllstructsetdata($PFD,4,$PFD_TYPE_RGBA) Dllstructsetdata($PFD,5,24) Dllstructsetdata($PFD,19,16) Dllstructsetdata($PFD,22,$PFD_MAIN_PLANE) $format = Dllcall("gdi32.dll","int","ChoosePixelFormat","int",$DC[0],"ptr",Dllstructgetptr($PFD)) $setformat = Dllcall("gdi32.dll","int","SetPixelFormat","int",$DC[0],"int",$format[0],"ptr",Dllstructgetptr($PFD)) $HRC = Dllcall("opengl32.dll","int","wglCreateContext","int",$DC[0]) $ret = Dllcall("opengl32.dll","int","wglMakeCurrent","int",$DC[0],"int",$HRC[0]) $varhdc = $dc[0] $varhrc = $hrc[0] return $ret[0] Endfunc Func DisableOpenGL($HDC,$HRC,$Hwnd) Dllcall("opengl32.dll","int","wglMakeCurrent","int",0,"int",0) Dllcall("opengl32.dll","int","wglDeleteContext","int",$hrc) Dllcall("user32.dll","int","ReleaseDC","hwnd",$hwnd,"int",$HRC) Return endfunc Func glClearColor($r,$g,$b,$a) Dllcall("opengl32.dll","none","glClearColor","int",$r,"int",$g,"int",$b,"int",$a) endfunc Func glClear($mask) Dllcall("opengl32.dll","none","glClear","int",$mask) endfunc Func glPushMatrix() Dllcall("opengl32.dll","none","glPushMatrix") endfunc Func glPopMatrix() Dllcall("opengl32.dll","none","glPopMatrix") endfunc Func glRotatei($angle,$x,$y,$z) Dllcall("opengl32.dll","none","glRotatei","int",$angle,"int",$x,"int",$y,"int",$z) endfunc Func glBegin($mode) Dllcall("opengl32.dll","none","glBegin","int",$mode) endfunc Func glColor3i($r,$g,$ Dllcall("opengl32.dll","none","glColor3i","int",$r,"int",$g,"int",$ endfunc Func glVertex2i($x,$y) Dllcall("opengl32.dll","none","glVertex2i","int",$x,"int",$y) endfunc Func glEnd() Dllcall("opengl32.dll","none","glEnd") endfunc Func glFlush() Dllcall("opengl32.dll","none","glFlush") endfunc Func SwapBuffers($HDC) $ret = Dllcall("gdi32.dll","int","SwapBuffers","int",$HDC) Return $ret[0] endfunc Edited July 9, 2007 by eynstyne F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent]
eynstyne Posted July 9, 2007 Author Posted July 9, 2007 maybe I should just simplify this. Can 3D or OpenGL work with autoit at all? F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent]
mrbond007 Posted July 10, 2007 Posted July 10, 2007 (edited) It's possiblehttp://www.autoitscript.com/forum/index.php?showtopic=38549http://www.autoitscript.com/forum/index.php?showtopic=37385 Edited July 10, 2007 by mrbond007 Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now