4KB OpenGL Framework

Share your advanced PureBasic knowledge/code with the community.
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

4KB OpenGL Framework

Post by benny »

Code updated for 5.20+

Hi,

here is a little purebasic conversion for people who are interested in doing
4KB intros using purebasic / opengl.

the original author of this idea is auld.

Code: Select all

; *** 4K Framework for PureBasic [Win]
; ***
; *** original framework by auld
; *** pb-conversion by benny!weltenkonstrukteur.de
; ***

IncludeFile #PB_Compiler_Home+"Examples\Sources - Advanced\OpenGL Cube\OpenGL.pbi"


Procedure do4KIntro()
  
  glClear_(#GL_DEPTH_BUFFER_BIT | #GL_COLOR_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_();
  
EndProcedure


pfd.PIXELFORMATDESCRIPTOR
pfd\cColorBits  = 32
pfd\cDepthBits  = 32
pfd\dwFlags     = #PFD_SUPPORT_OPENGL | #PFD_DOUBLEBUFFER
hDC = GetDC_ ( CreateWindow_("edit", 0, #WS_POPUP | #WS_VISIBLE | #WS_MAXIMIZE, 0, 0 ,0 ,0, 0 ,0 ,0, 0 ) )
SetPixelFormat_ ( hDC, ChoosePixelFormat_( hDC, pfd), pfd )
wglMakeCurrent_ ( hDC, wglCreateContext_(hDC) )
ShowCursor_(#False);

Repeat
  glClear_ ( #GL_DEPTH_BUFFER_BIT | #GL_COLOR_BUFFER_BIT )
  do4KIntro()
  SwapBuffers_ ( hDC );
Until ( GetAsyncKeyState_ (#VK_ESCAPE) )
The code aboves results in an executable of 2.560 bytes. Using shrinkers
like Dropper for example the file get shrinked to 992 bytes (WindowsXP
only !!!). So still some bytes left for your ideas ;-)

You can download the un- / compressed executables at the following url:

http://www.weltenkonstrukteur.de/dl/4K_PBFW.zip

For more information about 4K-intros and optimizing tricks you can visit :

http://in4k.untergrund.net/index.php?title=Main_Page
Last edited by benny on Mon Apr 24, 2006 4:34 pm, edited 1 time in total.
regards,
benny!
-
pe0ple ar3 str4nge!!!
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

Very nice! Thanx!
The Human Code Machine / Masters' Design Group
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

hehe... its nearly the same framework i am using since some time for own prods and own system :)

But please.... pllleeeaaasseeeee everybody here (!!!) pleeasseeee dont use the shrinker to remove original API names and replacing this by its offset... this may make your exe very small but this have one very big (hacking) problem!!! (so dont use the /o option) Your exe will only work on systems like yours! If someone may have another OS version or the same as you with just another SP version, the exe may no longer work! Real coders dont need tools like shrinkers and good coders should code and not hacking ^^
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

just take a look here - 2,5 KB beta intro:
http://www.purebasic.fr/english/viewtop ... 892#140892
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

va!n wrote:... Real coders dont need tools like shrinkers and good coders should
code and not hacking ^^
I am using the /b-option, the so called : CAP DROPPING. You find
more information about it here :

http://in4k.untergrund.net/various%20we ... cle_3.html

http://in4k.untergrund.net/html_article ... opping.htm


This technique was used by several well known 4kb productions, so I kind of
disagree with your statement above.

But well, just my 2cts.
regards,
benny!
-
pe0ple ar3 str4nge!!!
xperience2003
Enthusiast
Enthusiast
Posts: 113
Joined: Tue Oct 05, 2004 9:05 pm
Location: germany
Contact:

Post by xperience2003 »

great work, thank you =)
xperience2003
Enthusiast
Enthusiast
Posts: 113
Joined: Tue Oct 05, 2004 9:05 pm
Location: germany
Contact:

Post by xperience2003 »

traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

xperience2003 wrote:first test
N :!: CE

(though even 4kbs shouldn't crash on exit... ;))
Good programmers don't comment their code. It was hard to write, should be hard to read.
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

as i told you on ICQ, nice work :wink:
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

Really nice indeed :!:
regards,
benny!
-
pe0ple ar3 str4nge!!!
Post Reply