MotionBlur Demo

Developed or developing a new product in PureBasic? Tell the world about it.
jammin
New User
New User
Posts: 9
Joined: Mon Jul 21, 2003 10:29 am
Contact:

MotionBlur Demo

Post by jammin »

Hi guys,

here is my first little OpenGL Demo.
Ported from Phil Freeman´s Delphi Demo.

Original Delphi .exe size is over 200 kb.
Purebasic .exe size is under 12 kb :D

http://mitglied.lycos.de/Graphicfreak/

regards jammin
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Hum... doesn't seem to work in win 2k ...

It just exist, doing nothing...
jammin
New User
New User
Posts: 9
Joined: Mon Jul 21, 2003 10:29 am
Contact:

Post by jammin »

I´m working with Win98,sorry.

Somebody here with the same problem ?
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Could the the GL drivers...

I have an NVIDIA GEFORCE2 MX400...
I have had some trouble in the past with purebasic opengl demos...
None seem to work :(
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Works for me. WinXP, GeForce4 Ti 4200
Good programmers don't comment their code. It was hard to write, should be hard to read.
Searhin
User
User
Posts: 41
Joined: Mon May 26, 2003 10:53 am
Location: Germany

Post by Searhin »

i love your example. (works on NT 4.0, too)

how about the source code? can you post it somewhere? or do you plan to sell it for the best bid?
jammin
New User
New User
Posts: 9
Joined: Mon Jul 21, 2003 10:29 am
Contact:

Post by jammin »

Code: Select all

; OpenGL Motion Blur Demo
; Ported from Delphi to Purebasic by jammin
; 
;
; Based on OpenGL Demo by Phil Freeman
;
;
;

IncludeFile "OpenGL.pbi"

Procedure Rendercube(Size.f)


glBegin_(#GL_QUADS);

  glNormal3f_( -1.0,  0.0,  0.0);
  glVertex3f_( Size, -Size, -Size);
  glVertex3f_( Size,  Size, -Size);
  glVertex3f_( Size,  Size,  Size);
  glVertex3f_( Size, -Size,  Size);

  glNormal3f_(1.0,  0.0,  0.0);
  glVertex3f_(-Size, -Size,  Size);
  glVertex3f_(-Size, -Size, -Size);
  glVertex3f_(-Size,  Size, -Size);
  glVertex3f_(-Size,  Size,  Size);

  glNormal3f_( 0.0,  0.0, 1.0);
  glVertex3f_(-Size,  Size, -Size);
  glVertex3f_( Size,  Size, -Size);
  glVertex3f_( Size, -Size, -Size);
  glVertex3f_(-Size, -Size, -Size);

  glNormal3f_( 0.0,  0.0,  -1.0);
  glVertex3f_(-Size, -Size,  Size);
  glVertex3f_(-Size,  Size,  Size);
  glVertex3f_( Size,  Size,  Size);
  glVertex3f_( Size, -Size,  Size);

  glNormal3f_( 0.0,  -1.0,  0.0);
  glVertex3f_( Size,  Size, -Size);
  glVertex3f_( Size,  Size,  Size);
  glVertex3f_(-Size,  Size,  Size);
  glVertex3f_(-Size,  Size, -Size);

  glNormal3f_( 0.0, 1.0,  0.0);
  glVertex3f_( Size, -Size,  Size);
  glVertex3f_(-Size, -Size,  Size);
  glVertex3f_(-Size, -Size, -Size);
  glVertex3f_( Size, -Size, -Size);

  glEnd_();      

EndProcedure 

 
 Procedure RenderScene(Fade.f);

  
  glColor3f_(0.0, 0.0, Fade);
  glTranslatef_(-0.5, 0.0, 0.0);
  RenderCube(0.1);

  glColor3f_(0.0, Fade, 0.0);
  glTranslatef_(1.0, 0.0, 0.0);
  RenderCube(0.1);

  glColor3f_(0.0, Fade, Fade);
  glTranslatef_(-0.5, 0.0, 0.5);
  RenderCube(0.1);

  glColor3f_(Fade, Fade, 0.0);
  glTranslatef_(0.0, 0.0, -1.0);
  RenderCube(0.1);

  glColor3f_(Fade, Fade / 2, 0.0);
  glTranslatef_(0.0, 0.5, 0.5);
  RenderCube(0.1);

  glColor3f_(Fade, 0.0, Fade);
  glTranslatef_(0.0, -1.0, 0.0);
  RenderCube(0.1);

  glColor3f_(Fade, 0.0, 0.0);
  glTranslatef_(0.0, 0.5, 0.0);
  RenderCube(0.2);
  
 EndProcedure;

 
 
 
 
 
Procedure DrawCube(hdc)

  glEnable_(#GL_LIGHT0);
  glEnable_(#GL_LIGHTING);
  glEnable_(#GL_COLOR_MATERIAL);
  glEnable_(#GL_DEPTH_TEST);
  glDepthFunc_(#GL_LEQUAL);

  glShadeModel_(#GL_SMOOTH)
  glClearColor_( 0.0, 0.0, 0.0, 0.0 )
  glClear_(#GL_COLOR_BUFFER_BIT);
  
  t1.f = GetTickCount_() / 1000;


  For i=0 To 15
  
    glClear_(#GL_DEPTH_BUFFER_BIT);

    t2.f = t1.f + i / 15 * 0.25;
    
    glLoadIdentity_();
    glRotatef_(t2.f * 70.0, 1.0, 0.0, 0.0);
    glRotatef_(t2.f * 80.0, 0.0, 1.0, 0.0);
    glRotatef_(t2.f * 90.0, 0.0, 0.0, 1.0);

    RenderScene(i / 15);
    
  Next i
  
  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 = 640 ; The window & GLViewport dimensions
WindowHeight = 480




hWnd = OpenWindow(0, 0, 0, WindowWidth, WindowHeight, #PB_Window_SystemMenu, "EchtZeit Motion Blur Demo")

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, WindowHeight), "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

Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Compiled the source code.... and works just fine !

Excellent work ! Very impressive :P
Post Reply