Author Topic: openGL framework[BMAX]  (Read 6775 times)

0 Members and 1 Guest are viewing this topic.

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
openGL framework[BMAX]
« on: February 28, 2007 »
Inspired by the purebasic openGL framework Benny posted, I converted the code to bmax.

Code: [Select]
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.
« Last Edit: July 21, 2007 by Shockwave »

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: openGL framework
« Reply #1 on: February 28, 2007 »
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:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: openGL framework
« Reply #2 on: February 28, 2007 »
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.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: openGL framework
« Reply #3 on: March 01, 2007 »
Good work, so have some ood Karma from me too Zawran :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Re: openGL framework
« Reply #4 on: March 01, 2007 »
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:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: openGL framework
« Reply #5 on: March 01, 2007 »
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.

Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Re: openGL framework
« Reply #6 on: March 01, 2007 »
OK thx for an answer, would this work in blitz2D. if so what dll's would it need.


sry meant blitz3d
« Last Edit: March 01, 2007 by Paul »
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: openGL framework
« Reply #7 on: March 01, 2007 »
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.

Offline Paul

  • Pentium
  • *****
  • Posts: 1490
  • Karma: 47
    • View Profile
Re: openGL framework
« Reply #8 on: March 01, 2007 »
oh sry meant blitz3D
I will bite you - http://s5.bitefight.se/c.php?uid=31059
Challenge Trophies Won:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: openGL framework
« Reply #9 on: March 02, 2007 »
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.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: openGL framework
« Reply #10 on: March 03, 2007 »
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:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: openGL framework
« Reply #11 on: March 03, 2007 »
Yes thats the one Clyde, thanks for the link. And you're right about the size when it comes to b3d and b+.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: openGL framework
« Reply #12 on: March 03, 2007 »
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:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: openGL framework
« Reply #13 on: March 03, 2007 »
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.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: openGL framework
« Reply #14 on: March 03, 2007 »
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:

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: openGL framework
« Reply #15 on: March 03, 2007 »
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.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: openGL framework
« Reply #16 on: March 03, 2007 »
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: