• Welcome to Dark Bit Factory & Gravity.
 

openGL framework[BMAX]

Started by zawran, February 28, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

zawran

Inspired by the purebasic openGL framework Benny posted, I converted the code to bmax.


Framework brl.GLGraphics

Function doIntro()
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT)
glRotatef(0.5,1.0,1.0,1.0)
glBegin(GL_TRIANGLES)
glColor3f(1.0,0.0,0.0)
glVertex3f(0.0,-1.0,0.0)
glColor3f(0.0,1.0,0.0)
glVertex3f(1.0,1.0,0.0)
glColor3f(0.0,0.0,1.0)
glVertex3f(-1.0,1.0,0.0)
glEnd()
End Function

GLGraphics( 640, 480, 0, 60, GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER )

While Not KeyHit(KEY_ESCAPE)
doIntro()
Flip
Wend
End


It will compile uncompressed to about 95.5kb, and 36.5kb using upx. I believe that its possible to get this a lot smaller. Most of the reason for the size right now is that the official bmax openGL module, which I what this uses, is filled with a lot of functions for context, pixmap and other. Most of which isn't really needed for doing basic raw openGL, so I will try and extract what is needed to just open up a window with an openGL context and using the basic openGL commands. I would like to get it down to about half the size or less. That way it could be used to make 64k stuff with. I doubt that it would be possible to cram it down under the 4k limit, but we'll see when I get further with this.

[edit] I have attached an exe for those without bmax.

benny!

Nice. Thanks for giving so fast info about the framework in bmax ( K++ ). I do not know
anything about bmax - is it possible to direct access the WinApi. Then you could
maybe drop some kb and avoid the GLGraphics overload  ???
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

zawran

Yes you can use the winApi directly, I will just have to go through their graphics code and see what calls are needed, then I will be able to drop their graphics module and stick with just openGL and some winApi calls. That should cut a good deal of kb out of the final exe.

Shockwave

Good work, so have some ood Karma from me too Zawran :)
Shockwave ^ Codigos
Challenge Trophies Won:

Paul

The triangle in the demo has four edges
is that supposed to happen?
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

zawran

I am thinking that it has to do with the way its rotated. I will eventually be replacing the triangle thingy with something else when I try and cut it down in size. I did make a version where I rotated it in another way and that looked alright, but I also noticed the strange look of the triangle every now and then.

Paul

#6
OK thx for an answer, would this work in blitz2D. if so what dll's would it need.


sry meant blitz3d
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

zawran

I remember that someone did an openGL dll for blitzPlus, but I do not remember any for blitz2d. I do not think that blitz2d can work with dll files, but I could be wrong.

Paul

oh sry meant blitz3D
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

zawran

If I remember correctly then you can use DLL files with B3D, you will have to create a decls file and place it in the userlibs folder of the b3d install. I don't have any links to that openGL dll though, last I heard of it was back when blitzcoder was still around, and thats a long time ago.

Clyde

Here you go dude. Peter Scheutz OGL Direct

If it's getting a really small exe with using this along the lines of the framework, then I dont think your going to achieve it with B3D / B+ as of the way that it compiles with all the commands even if you dont use them.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

zawran

Yes thats the one Clyde, thanks for the link. And you're right about the size when it comes to b3d and b+.

Shockwave

That's the only problem with 3D, 2D and +

Max is better.. How small do you think you can get a bmax exe Zawran?
Shockwave ^ Codigos
Challenge Trophies Won:

zawran

So far I have cut 11kb off it, so its down to 84.5kb for that triangle example. But I am looking to get it lower yet. I will have to dig into the old backup and see if I can't find the code I play around with ages ago, which had some winapi stuff going on. I was going to seach the blitzbasic site for some info, but it have been down for a couple of days, no clue why, so I will have to find my backup discs and go seaching. I doubt that I will get it much lower than just barely fitting within 64k and it actually doing some effects. But you'll never know though. At the moment I am using the openGL module which comes with bmax, its probably possible to cut that down even further by removing stuff that I will never be using from openGL anyways.

Shockwave

Can  I just ask, are you packing your executables?

If not, you could use mew or kkrunchy or upx to bring the final file size down much further, as well as developing a framework where you know what can be safely left out.
Shockwave ^ Codigos
Challenge Trophies Won:

zawran

I haven't packed the exe yet, but I have used upx on all my releases so far. I might take a look at that kkrunchy and see if it does better than upx.

Shockwave

It is much more effective than upx. Most of the demo scene use it to pack thier 64kbs. I think you'll be pleasantly surprised.
Shockwave ^ Codigos
Challenge Trophies Won: