Page 1 of 1

4KB OpenGL Framework

Posted: Mon Apr 24, 2006 11:51 am
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

Posted: Mon Apr 24, 2006 2:51 pm
by THCM
Very nice! Thanx!

Posted: Tue Apr 25, 2006 2:35 am
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 ^^

Posted: Tue Apr 25, 2006 3:17 am
by va!n
just take a look here - 2,5 KB beta intro:
http://www.purebasic.fr/english/viewtop ... 892#140892

Posted: Tue Apr 25, 2006 8:45 am
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.

Posted: Tue May 02, 2006 12:55 am
by xperience2003
great work, thank you =)

Posted: Sun May 21, 2006 12:43 am
by xperience2003

Posted: Sun May 21, 2006 1:08 am
by traumatic
xperience2003 wrote:first test
N :!: CE

(though even 4kbs shouldn't crash on exit... ;))

Posted: Sun May 21, 2006 1:35 am
by va!n
as i told you on ICQ, nice work :wink:

Posted: Sun May 21, 2006 6:34 am
by benny
Really nice indeed :!: