opengl without brl.glgraphicsBlitzMax Forums/BlitzMax OpenGL Programming/opengl without brl.glgraphics
| Is it possible to use blitzmax for opengl without having to import the brl mods? The thing is that I am trying to make as small an exe file as possible, and so far I have only been able to get the smallest of examples (opening a window with an opengl context and clearing it) down to above 100kb.|
I need something like this, but that does not compile to 100kb+
Framework BRL.GLGraphics Import PUB.GLEW Import BRL.PolledInput SetGraphicsDriver(GLGraphicsDriver()) Graphics(640,480) While Not KeyDown(KEY_ESCAPE) Wend End
I have seen other basic languages manage to do the same in about 40kb, which is considerably less than blitzmax, and in the size frame I would like it to be.
I am thinking that BRL.GLGraphics and everything else it imports probably has a lot of stuff that isn't needed for just making a window with the opengl context that can be used as a target for opengl code.
If someone has any input it would be highly appreciated and examples of how to get something like that done would be stellar.
| You can also shave off a decent chunk of the executable size by compressing the resulting file with UPX.|
With UPX the program will automatically decompress in memory and run itself, so there's no difference to the end user other than a smaller size.
| With UPX I can get it down to just under half the size, but since I would have more code than just opening the window, I would like it to be even smaller before all the other code is added. |
| Important note: I don't have any experience of actually doing this stuff -- it's just a few pointers in the spirit of "providing input"!|
I couldn't get the first example below to work on a quick attempt (looks like something's changed in 'Max since then), but you might want to try setting up your own window/event loop via Win32 in this fashion...
Kev's minimal 'raw' window code:
(I might have a proper go at making this work again myself at some point.)
DredPirateRoberts' C import file, which does a similar thing in a different way (I haven't tried it), from which you could just rip the window creation/event stuff:
With a basic window going like this, you should then be able to use Win32's GetDC to obtain the device context for the client (inner) area and pass it to the 'wgl' functions:
You'd have to import the pub/opengl mod to use the functions of course. Like I say, I haven't tried any of this, and don't 'do' raw OpenGL myself so I probably can't offer much more help than this. Obviously, this stuff would be Win32 only (the standard imports would handle the other platforms normally).
| You can make a stripped GLGraphics, like this..|
Don't forget to copy C sources from brl.GLGraphics
Strict framework brl.blitz Import Pub.OpenGL import brl.polledinput ?Win32 Import "glgraphics.win32.c" ?MacOS Import "glgraphics.macos.m" ?Linux Import "-lX11" Import "-lXxf86vm" Import "-lGL" Import "glgraphics.linux.c" ? Private Extern Function bbGLGraphicsShareContexts() Function bbGLGraphicsGraphicsModes( buf:Byte Ptr,size ) Function bbGLGraphicsAttachGraphics( widget,flags ) Function bbGLGraphicsCreateGraphics( width,height,depth,hertz,flags ) Function bbGLGraphicsGetSettings( context,width Var,height Var,depth Var,hertz Var,flags Var ) Function bbGLGraphicsClose( context ) Function bbGLGraphicsSetGraphics( context ) Function bbGLGraphicsFlip( sync ) End Extern global context = bbGLGraphicsCreateGraphics(400, 300, 0, 0, -1) bbGLGraphicsSetGraphics(context) enablePolledInput() while not keyhit(KEY_ESCAPE) bbGLGraphicsFlip(context) WEnd
However, this won't reduce filesize a lot. I get a 75K compiled exe using the code above.
| Thanks Tommo and James, you have given me some ideas to work with. |