Logty Posted March 8, 2011 Share Posted March 8, 2011 I was having some trouble with this code because I am trying to get gluLookAt() (for those of you who are familiar with opengl) to work, but for some reason my script freezes up every time I run it, does anybody know how to fix this problem? expandcollapse popupGlobal Const $GL_VERSION_1_1 = 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 Const $GL_PROJECTION = 0x1701 Global Const $GL_COLOR_BUFFER_BIT = 0x00004000 Global Const $GL_TRIANGLES = 0x0004 Global $gui = GUICreate("OpenGL", 250, 250) GUISetBkColor(0x000000) Global $dc EnableOpenGL($gui, $dc) ;glMatrixMode($GL_PROJECTION) ;glViewport(0, 0, 250, 250) GUISetState(@SW_SHOW) While GUIGetMsg() <> -3 glClear($GL_COLOR_BUFFER_BIT) glBegin($GL_TRIANGLES) glColor3f(0, 1, 0) glVertex3f(-.75, -.5, 0) glColor3f(1, 0, 0) glVertex3f(0, .75, 0) glColor3f(0, 0, 1) glVertex3f( .75, -.5, 0) glEnd() SwapBuffers($dc) glMatrixMode("GL_PROJECTION" ) glLoadIdentity() gluPerspective(10.0, 1.0, 0.0, 60.0) glMatrixMode( "GL_MODELVIEW" ) glLoadIdentity() gluLookAt( 1.0, 1.0,1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ) WEnd 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", 16) 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 ; absolutley no error checking at this moment EndFunc ;==>EnableOpenGL Func glBegin($mode) DllCall("opengl32.dll", "none", "glBegin", "uint", $mode) EndFunc ;==>glBegin Func glClear($mask) DllCall("opengl32.dll", "none", "glClear", "uint", $mask) EndFunc ;==>glClear Func glColor3f($red, $green, $blue) DllCall("opengl32.dll", "none", "glColor3f", "float", $red, "float", $green, "float", $blue) EndFunc ;==>glColor3f Func glEnd() DllCall("opengl32.dll", "none", "glEnd") EndFunc ;==>glEnd Func glLoadIdentity() DllCall("opengl32.dll", "none", "glLoadIdentity") EndFunc ;==>_glLoadIdentity Func gluLookAt($x1, $y1, $z1,$x2, $y2, $z2, $0, $1, $00) DllCall( "Glu32.dll", "none", "gluLookAt", "float", $x1,"float", $y1,"float", $z1,"float", $x2,"float", $y2,"float", $z2, "float" , $0, "float", $1, "float", $00 ) Endfunc Func gluPerspective($n1, $n2, $f1,$f2) DllCall( "Glu32.dll", "none", "gluPerspective", "float", $n1,"float", $n2,"float", $f1,"float", $f2) Endfunc Func glMatrixMode($mode) DllCall("opengl32.dll", "none", "glMatrixMode", "uint", $mode) EndFunc ;==>glMatrixMode Func glVertex3f($x, $y, $z) DllCall("opengl32.dll", "none", "glVertex3f", "float", $x, "float", $y, "float", $z) EndFunc ;==>glVertex3f Func glViewport($x, $y, $width, $height) DllCall("opengl32.dll", "none", "glViewport", "int", $x, "int", $y, "int", $width, "int", $height) EndFunc ;==>glViewport Func SwapBuffers($hDC) DllCall("gdi32.dll", "int", "SwapBuffers", "hwnd", $hDC) EndFunc ;==>SwapBuffers If you take out the gluLookAt and gluPerspective the script runs perfectly fine Link to comment Share on other sites More sharing options...
trancexx Posted March 8, 2011 Share Posted March 8, 2011 Change float to double. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Logty Posted March 9, 2011 Author Share Posted March 9, 2011 Thanks!! Link to comment Share on other sites More sharing options...
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