Jump to content

Freeglut.dll ( OpenGL ) - DllCall - create new window


Gordoni
 Share

Recommended Posts

$__GLUT_hDLL = "freeglut.dll"
DllOpen($__GLUT_hDLL)
DllCall($__GLUT_hDLL, "none", "glutInitWindowPosition", "int","100", "int", "100")
DllCall($__GLUT_hDLL, "none", "glutInitWindowSize", "int", "640", "int", "360")
$naik = BitOr(0x1908, 0x140A, 0x1801)
DllCall($__GLUT_hDLL, "none", "glutInitDisplayMode", "int",$naik)
DllCall($__GLUT_hDLL, "int", "glutCreateWindow", "char", "myname")

    
    While 1 
        Sleep(1000)
        
        WEnd

I would like to create window with freeglut and autoit. 

in C++ code which i translated : 

glutInit(&argc, argv);
glutInitWindowPosition(100, 100);
glutInitWindowSize(640, 360);
glutInitDisplayMode(GLUT_RGBA |  GLUT_DOUBLE | GLUT_DEPTH); 
glutCreateWindow("myname");

In attachment there is some examples which i found on our forum  ( freeglut.dll is a clone of glut32.dll with some changes, but no in these functions  ). Could someone check what is wrong or have idea how to make it working? 

Important links : http://www.opengl.org/documentation/specs/glut/spec3/spec3.html

http://freeglut.sourceforge.net/docs/api.php

ogl_glut_functions.au3

Edited by Gordoni
Link to comment
Share on other sites

This example creates a colored triangle in a black window.

 

Global Const $dllFreeGLUT = DllOpen( "freeglut.dll" )
Global Const $dllOpenGL32 = DllOpen( "opengl32.dll" )

#include "Utilities\Utilities.au3"

#include "OpenGL\OpenGLconstants.au3"
#include "OpenGL\OpenGLfunctions.au3"

#include "FreeGLUT\FreeGLUTstdConsts.au3"
#include "FreeGLUT\FreeGLUTextConsts.au3"
#include "FreeGLUT\FreeGLUTstdFuncs.au3"
#include "FreeGLUT\FreeGLUTextFuncs.au3"

Opt( "MustDeclareVars", 1 )

Global $CurrentWidth = 800, $CurrentHeight = 600
Global $FrameCount = 0

MainFunc()

DllClose( $dllFreeGLUT )
DllClose( $dllOpenGL32 )

Func MainFunc()

  Local $argc = 1
  Local $argv[$argc] = [ @ScriptName ]

  glutInit( $argc, $argv )

  glutInitContextVersion( 1, 1 )
  ;glutInitContextVersion( 3, 3 )
  ;glutInitContextFlags( $GLUT_FORWARD_COMPATIBLE )
  ;glutInitContextProfile( $GLUT_CORE_PROFILE )

  glutSetOption( $GLUT_ACTION_ON_WINDOW_CLOSE, $GLUT_ACTION_GLUTMAINLOOP_RETURNS )

  glutInitWindowSize( $CurrentWidth, $CurrentHeight )
  glutInitWindowPosition( 400, 100 )

  glutInitDisplayMode( $GLUT_DEPTH + $GLUT_DOUBLE + $GLUT_RGBA )

  Local $Title = "Triangle"
  Local $WindowHandle = glutCreateWindow( $Title );

  glutReshapeFunc( "ResizeFunction" )
  glutDisplayFunc( "RenderFunction" )
  glutIdleFunc( "IdleFunction" )
  glutTimerFunc( 0, "TimerFunction", 0 )

  glClearColor( 0.0, 0.0, 0.0, 0.0 )

  glutMainLoop()

EndFunc

; Callback function
Func ResizeFunction( $Width, $Height )
  $CurrentWidth = $Width
  $CurrentHeight = $Height
  glViewport( 0, 0, $CurrentWidth, $CurrentHeight )
EndFunc

; Callback function
Func RenderFunction()
  $FrameCount += 1
  glClear( $GL_COLOR_BUFFER_BIT + $GL_DEPTH_BUFFER_BIT )
  glBegin($GL_TRIANGLES)
    glColor3f (  0.0,   1.0,  0.0 )
    glVertex3f( -0.75, -0.50, 0.00 )
    glColor3f (  1.0,   0.0,  0.0 )
    glVertex3f(  0.00,  0.75, 0.00 )
    glColor3f (  0.0,   0.0,  1.0 )
    glVertex3f(  0.75, -0.50, 0.00 )
  glEnd()
  glutSwapBuffers()
  glutPostRedisplay()
EndFunc

; Callback function
Func IdleFunction()
  glutPostRedisplay()
EndFunc

; Callback function
Func TimerFunction( $Value )
  If $Value <> 0 Then
    Local $Title = "Triangle: " & _
                   $FrameCount * 4 & " Frames Per Second" & _
                   " @ " & $CurrentWidth & " x " & $CurrentHeight
    glutSetWindowTitle( $Title )
  Endif
  $FrameCount = 0
  glutTimerFunc( 250, "TimerFunction", 1 )
EndFunc

Example and UDFs are in the zip file but not the dll files.

Take a look at this thread in the Examples section.

Triangle.7z

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...