GLFW v2.4.2
for MASM32

  1. Introduction
  2. Installing GLFW for MASM32
  3. Compiling the example programs
  4. Using GLFW from MASM32
  5. The author
  6. Acknowledgements


1. Introduction

This distribution contains MASM32 bindings for the GLFW v2.4.x Windows DLL, and MASM32 example programs. For further information on how to use GLFW you should read the GLFW documentation.

For those of you who are unfamiliar with MASM32, it is a free 32-bit x86 assembler for Windows, with excellent support for win32 API calls etc. You can download MASM32 from its homepage, www.masm32.com.

I assume that the reader of this document is at least somewhat familiar with x86 assembly language, and knows how to use MASM32.


2. Installing GLFW for MASM32

To install GLFW for MASM32, you should copy support\masm\include\glfw.inc to your MASM32 include directory, and support\masm\lib\glfwdll.lib to your MASM32 lib directory.

The file support\win32dll\glfw.dll can either be copied to your Windows system folder (e.g. C:\WINNT\system32\ for Windows NT or C:\WINDOWS\SYSTEM for Windows 9x/ME), or to your project directory (where you keep your compiled EXE).

IMPORTANT Since there is a problem with how the MASM32 include files are generated (64-bit arguments are interpreted as two 32-bit arguments), it is necessary to replace the opengl32.inc and glu32.inc files in your MASM32 include directory with the ones in this distribution (support\masm\include\opengl32.inc and support\masm\include\glu32.inc). Otherwise you will not be able to compile the example programs, and programming OpenGL with MASM32 will not be easy.


3. Compiling the example programs

Assuming that you have installed GLFW as described in section 2, you should be able to compile the example programs by simply running support\masm\examples\makeit.bat (double clicking the icon works just fine).


4. Using GLFW from MASM32

4.1 General

MASM32 has very nice DLL calling support, so using GLFW should be straight forward.

In your program, you should INCLUDE \masm32\include\glfw.inc and INCLUDELIB \masm32\lib\glfwdll.lib (paths according to the MASM32 recommendations).

As you can see in the example programs, they do not specify the full MASM32 path when including the .inc and .lib files. This is because I keep my MASM32 installation and my project files on different drives, and I have solved it with a (more or less) clever batch file (support\masm\examples\makeit.bat). Feel free to use this batch file as a template for building your own projects. Otherwise you should make sure that you specify the correct include and library paths.


4.2 Calling GLFW functions

To call GLFW functions you use the INVOKE macro, which correctly places the function arguments on the stack, and calls the GLFW function. The syntax is: INVOKE function[, arg1[, arg2[, ...]]]. For instance, calling glfwOpenWindow could look like this:

  INVOKE glfwOpenWindow, 640, 480, 0, 0, 0, 0, 0, 0, GLFW_WINDOW


4.3 Using GLFW callback functions

In order to use GLFW callback functions, you have to make sure that your functions are using the STDCALL calling convention.


5. The author

My name is Marcus Geelnard, marcus.geelnard@home.se. Please contact me if you have any problems with GLFW, or any questions at all concerning compiling or using GLFW.

The GLFW web site can be found here: http://glfw.sourceforge.net/. It contains the latest version of GLFW, news and other information that is useful for OpenGL development.


6. Acknowledgements

Many thanks to Toni Jovanoski, whose dedicated work made MASM32 support possible! He also supplied the modified opengl32.inc and glu32.inc files.