Get Window Handle in OpenGL (and on Mac)

BlitzMax Forums/BlitzMax Programming/Get Window Handle in OpenGL (and on Mac)

Perhaps something like this knocked together snippet :

SuperStrict

Import "glue.m"

Extern
	Function macGetWindowOrigin(window:Int, x:Int Var, y:Int Var)
End Extern



Graphics 800, 600, 0


Local handle:Int = GraphicsWindowHandle()


SetColor 255, 255, 255

While Not KeyDown(key_escape)

	Local x:Int, y:Int
	macGetWindowOrigin(handle, x, y)


	Cls
	
	DrawText "hello", 10, 10
	
	DrawText x + ", " + y, 200, 200
	
	Flip


Wend

where GraphicsWindowHandle() returns the handle to the window - if there is one.
Running here on the Mac (OpenGL) :-)
(note that on OS X, origin is in bottom-left corner of the screen, so you would need to do some math on y)

Requires changes to BRL.Graphics, BRL.GLGraphics, BRL.GLMax2D ... and related modules.