How is this possible?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by LJ.

In another message thread, someone posted the link:
http://www.farb-rausch.de/fr08_final.zip

Of a 64K .exe with incredible graphics and sound. It look awhile to get it to run, as if it was unpacking itself into a Windows TEMP folder and then running. But even if it is truly double that at 128K it is still amazing.

My question is how is this possible? Is this done in all machine language assembly code and is that why it is so small?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by LJ.

Here is another web site, by same coders:
http://www.theproduct.de
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by dmoc.

http://www.scene.org
http://www.ojuice.net

Also see an example 512 byte demo I converted a while back...

viewtopic.php?t=2718
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by GPI.

I think, that the grafik is produced with mathematics routines (also complete calculated), so you need only small formals. Same for the sound. I think there is the soundfont (how a note should sound, piano, etc) calculated. And final a packer is install. and so on...

And forget it: You can't programm so a programm with this small size with PureBasic. To do soooo small programms you need to programm in assembler.

PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by LJ.

Can't get the OpenGL demo engine to run, error on line:
gluPerspectivef_(100.0, 1.0, 1.0, 100.0)

saying that gluPerspective is not an array, linked list, or function....
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by dmoc.

You need the GLU32F lib. Sorry, can't remember exactly where from but do a search either here or on the resources site. If you cannot find it let me know.

PS: Don't expect too much, it's not like the fr08 demo but I do believe that it is poss to code such things using PB (poss even without assembly)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by VPureBasic.
Originally posted by dmoc

You need the GLU32F lib. Sorry, can't remember exactly where from but do a search either here or on the resources site. If you cannot find it let me know.
Here's the link:
http://www.reelmediaproductions.com/pb/asmlibrary.html

Roger
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by LJ.

Thank guys. Very cool. The .exe compiled to only 7K impressive! No use of Direct X overhead, and the nice part is that no .bsp license and all that.

It is beyond me how it works, but if it can read from data statements, like numbers, and then draw to the screen that brings the possibility of creating a .bsp like map with it.

Check out this web site:
http://www.jsomers.com/bsp_demo/mazebsp.html

Apparently this author has made it possible to read a .bsp file and display it in OpenGl.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by LJ.

Oppss...okay, maybe not exactly. If you check out the OpenGL code that he had read a .bsp file, he used an authoring tool to write the GL code called GLUT. The program is at:
http://www.xmission.com/~nate/glut.html

It also comes with C++ source code how to read the .bsp file and display it in OpenGL. When I downloaded the code and checked it out, it uses different OpenGL language that VPurebasic's OpenGL code for PureBasic.

The author who wrote the .bsp reader to display in OpenGL used this authoring tool. I examined his C++ source code and he calls to the GLUT .dll with programming commands.

If we were able to convert his C++ code over to PureBasic, we would have to use the GLUT .dll as well and that would mean having to distribute the GLUT .dll with your program as well.

In my opinion, this is sort of counter to VPurebasic's beautiful code in that it doesn't require any .DLL's or even Direct X and that is part of the beauty of using OpenGL in the first place.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by LJ

In my opinion, this is sort of counter to VPurebasic's beautiful code in that it doesn't require any .DLL's or even Direct X and that is part of the beauty of using OpenGL in the first place.
You sure that is not just because Windows comes with OpenGL? Well, some versions do not have it, but people manage to collect it from places :)

c:\windows\system\glu32.dll - GLUT
c:\windows\system\opengl32.dll - OpenGL


--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.52, external editor)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by dmoc.

GLUT - GL Utility Toolkit (or something like that). It's mainly used for convenience but it does nothing that you cannot do yourself in pure GL (speaking of which have you checked out the pureGL PB demo yet?). Re C++ (and C for that matter) - strip out the C++ parts and you will see it will be the usual GL calls. PB GL code also uses the same calls, its just that it looks "integrated" when someone has created a PB lib interface (in this case the GLU32F lib). To learn more the red and blue GL books are a must but NeHe's site provides a great starting point... http://nehe.gamedev.net/

Have fun!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by LJ.

Here's a program I banged out rotating a triangle:

;
; OpenGL Triangle
; by Lance Jepsen
;
;
; Based on OpenGL Test by Fantaisie Software
;
;
;

IncludeFile "OpenGL.pbi"

Global theta.f
theta = 5
Procedure DrawCube(hdc)
glPushMatrix_() ; Save the original Matrix coordinates
glMatrixMode_(#GL_MODELVIEW)
glRotatef_( theta, 0,0,1.0);
glRotatef_ (theta, 1.0, 0, 0) ; rotate around X axis
glRotatef_ (theta, 0, 1.0, 0) ; rotate around Y axis
glRotatef_ (theta, 0, 0, 1.0) ; rotate around Z axis
glClearColor_( 0.0, 0.0, 0.0, 0.0 )
glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)

glBegin_(#GL_TRIANGLES );
glColor3f_(1.0, 0.0, 0.0 )
glVertex2f_( 0.0, 1.0 )
glColor3f_( 0.0, 1.0, 0.0 )
glVertex2f_( 0.87, -0.5 );
glColor3f_( 0.0, 0.0, 1.0 )
glVertex2f_( -0.87, -0.5 );
glEnd_()

theta = theta + 1

glPopMatrix_()
glFinish_()

SwapBuffers_(hdc)
EndProcedure


Procedure HandleError (Result, Text$)
If Result = 0
MessageRequester("Error", Text$, 0)
End
EndIf
EndProcedure


pfd.PIXELFORMATDESCRIPTOR

FlatMode = 0 ; Enable Or disable the 'Flat' rendering

WindowWidth = 800 ; The window & GLViewport dimensions
WindowHeight = 600

hWnd = OpenWindow(0, 0, 0, WindowWidth, WindowHeight, #PB_Window_SystemMenu, "OpenGL Triangle")

hdc = GetDC_(hWnd)

pfd\nSize = SizeOf(PIXELFORMATDESCRIPTOR)
pfd\nVersion = 1
pfd\dwFlags = #PFD_SUPPORT_OPENGL | #PFD_DOUBLEBUFFER | #PFD_DRAW_TO_WINDOW
pfd\dwLayerMask = #PFD_MAIN_PLANE
pfd\iPixelType = #PFD_TYPE_RGBA
pfd\cColorBits = 24
pfd\cDepthBits = 16

pixformat = ChoosePixelFormat_(hdc, pfd)

HandleError( SetPixelFormat_(hdc, pixformat, pfd), "SetPixelFormat()")

hrc = wglCreateContext_(hdc)

HandleError( wglMakeCurrent_(hdc,hrc), "vglMakeCurrent()")

HandleError( glViewport_ (0, 0, WindowWidth-30, WindowHeight-30), "GLViewPort()") ; A rectangle which define the OpenGL output zone

While Quit = 0

Repeat
EventID = WindowEvent()

Select EventID
Case #PB_EventCloseWindow
Quit = 1
EndSelect

Until EventID = 0

DrawCube(hdc)
Wend
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by dmoc.

Looks like you caught the bug! Here's a link to a very useful library that I have already used in PB...

http://hem.passagen.se/opengl/glfw/
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by LJ.

; NeHe Lesson 5 OpenGL Tutorial
; Translated to PureBasic by Lance Jepsen
; http://nehe.gamedev.net/

IncludeFile "OpenGL.pbi"

Global rtri.f
Global rquad.f

Procedure InitGL()
glClearColor_(0.0, 0.0, 0.0, 0.0)
glDepthFunc_(#GL_LESS)
glEnable_(#GL_DEPTH_TEST)
glShadeModel_(#GL_SMOOTH)

glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_()

gluPerspectivef_(45.0, 640/480, 0.1, 100.0)
glMatrixMode_(#GL_MODELVIEW)
EndProcedure

Procedure DrawScene(hDC)
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glLoadIdentity_()
glTranslatef_(-1.5, 0.0, -6.0)
glRotatef_(rtri,0.0,1.0,0.0)

glBegin_(#GL_TRIANGLES)

;Front Face of Pyramid
glColor3f_(1.0,0.0,0.0); // Red
glVertex3f_( 0.0, 1.0, 0.0); // Top Of Triangle (Front)
glColor3f_(0.0,1.0,0.0); // Green
glVertex3f_(-1.0,-1.0, 1.0); // Left Of Triangle (Front)
glColor3f_(0.0,0.0,1.0); // Blue
glVertex3f_( 1.0,-1.0, 1.0); // Right Of Triangle (Front)

;Right Face of Pyramid
glColor3f_(1.0,0.0,0.0); // Red
glVertex3f_( 0.0, 1.0, 0.0); // Top Of Triangle (Right)
glColor3f_(0.0,0.0,1.0); // Blue
glVertex3f_(1.0,-1.0, 1.0); // Left Of Triangle (Right)
glColor3f_(0.0,1.0,0.0); // Green
glVertex3f_(1.0,-1.0, -1.0); // Right Of Triangle (Right)

;Back Face of Pyramid
glColor3f_(1.0,0.0,0.0); // Red
glVertex3f_( 0.0, 1.0, 0.0); // Top Of Triangle (Back)
glColor3f_(0.0,1.0,0.0); // Green
glVertex3f_(1.0,-1.0, -1.0); // Left Of Triangle (Back)
glColor3f_(0.0,0.0,1.0); // Blue
glVertex3f_(-1.0,-1.0, -1.0); // Right Of Triangle (Back)

;Left Face of Pyramid
glColor3f_(1.0,0.0,0.0); // Red
glVertex3f_( 0.0, 1.0, 0.0); // Top Of Triangle (Left)
glColor3f_(0.0,0.0,1.0); // Blue
glVertex3f_(-1.0,-1.0,-1.0); // Left Of Triangle (Left)
glColor3f_(0.0,1.0,0.0); // Green
glVertex3f_(-1.0,-1.0, 1.0); // Right Of Triangle (Left)
glEnd_(); // Done Drawing The Pyramid

glLoadIdentity_();
glTranslatef_(1.5,0.0,-7.0); // Move Right And Into The Screen

glRotatef_(rquad,1.0,1.0,1.0); // Rotate The Cube On X, Y & Z

glBegin_(#GL_QUADS); // Start Drawing The Cube

;Top Face of Cube
glColor3f_(0.0,1.0,0.0); // Set The Color To Green
glVertex3f_( 1.0, 1.0,-1.0); // Top Right Of The Quad (Top)
glVertex3f_(-1.0, 1.0,-1.0); // Top Left Of The Quad (Top)
glVertex3f_(-1.0, 1.0, 1.0); // Bottom Left Of The Quad (Top)
glVertex3f_( 1.0, 1.0, 1.0); // Bottom Right Of The Quad (Top)

;Bottom Face of Cube
glColor3f_(1.0,0.5,0.0); // Set The Color To Orange
glVertex3f_( 1.0,-1.0, 1.0); // Top Right Of The Quad (Bottom)
glVertex3f_(-1.0,-1.0, 1.0); // Top Left Of The Quad (Bottom)
glVertex3f_(-1.0,-1.0,-1.0); // Bottom Left Of The Quad (Bottom)
glVertex3f_( 1.0,-1.0,-1.0); // Bottom Right Of The Quad (Bottom)

;Front Face of Cube
glColor3f_(1.0,0.0,0.0); // Set The Color To Red
glVertex3f_( 1.0, 1.0, 1.0); // Top Right Of The Quad (Front)
glVertex3f_(-1.0, 1.0, 1.0); // Top Left Of The Quad (Front)
glVertex3f_(-1.0,-1.0, 1.0); // Bottom Left Of The Quad (Front)
glVertex3f_( 1.0,-1.0, 1.0); // Bottom Right Of The Quad (Front)

;Back Face of Cube
glColor3f_(1.0,1.0,0.0); // Set The Color To Yellow
glVertex3f_( 1.0,-1.0,-1.0); // Bottom Left Of The Quad (Back)
glVertex3f_(-1.0,-1.0,-1.0); // Bottom Right Of The Quad (Back)
glVertex3f_(-1.0, 1.0,-1.0); // Top Right Of The Quad (Back)
glVertex3f_( 1.0, 1.0,-1.0); // Top Left Of The Quad (Back)

;Left Face of Cube
glColor3f_(0.0,0.0,1.0); // Set The Color To Blue
glVertex3f_(-1.0, 1.0, 1.0); // Top Right Of The Quad (Left)
glVertex3f_(-1.0, 1.0,-1.0); // Top Left Of The Quad (Left)
glVertex3f_(-1.0,-1.0,-1.0); // Bottom Left Of The Quad (Left)
glVertex3f_(-1.0,-1.0, 1.0); // Bottom Right Of The Quad (Left)

;Right Face of Cube
glColor3f_(1.0,0.0,1.0); // Set The Color To Violet
glVertex3f_( 1.0, 1.0,-1.0); // Top Right Of The Quad (Right)
glVertex3f_( 1.0, 1.0, 1.0); // Top Left Of The Quad (Right)
glVertex3f_( 1.0,-1.0, 1.0); // Bottom Left Of The Quad (Right)
glVertex3f_( 1.0,-1.0,-1.0); // Bottom Right Of The Quad (Right)
glEnd_(); // Done Drawing The Quad

rtri = rtri + 0.6; // Increase The Rotation Variable For The Triangle
rquad = rquad - 0.45; // Decrease The Rotation Variable For The Quad

EndProcedure

pfd.PIXELFORMATDESCRIPTOR

hWnd = OpenWindow(0, 0, 0, 800, 580, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "OpenGL Test")

hdc = GetDC_(hWnd)

pfd\nSize = SizeOf(PIXELFORMATDESCRIPTOR)
pfd\nVersion = 1
pfd\dwFlags = #PFD_SUPPORT_OPENGL | #PFD_DOUBLEBUFFER | #PFD_DRAW_TO_WINDOW
pfd\iLayerType = #PFD_MAIN_PLANE
pfd\iPixelType = #PFD_TYPE_RGBA
pfd\cColorBits = 24
pfd\cDepthBits = 16

pixformat = ChoosePixelFormat_(hdc, pfd)
SetPixelFormat_(hdc, pixformat, pfd)
hrc = wglCreateContext_(hdc)
wglMakeCurrent_(hdc,hrc)

InitGL()

While Quit = 0

Repeat
EventID = WindowEvent()

Select EventID
Case #PB_EventCloseWindow
Quit = 1
EndSelect

Until EventID = 0

DrawScene(hDC)
SwapBuffers_(hDC)

Wend
Post Reply