Page 1 of 1

MotionBlur Demo

Posted: Mon Jul 21, 2003 10:32 am
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

Posted: Mon Jul 21, 2003 9:58 pm
by Num3
Hum... doesn't seem to work in win 2k ...

It just exist, doing nothing...

Posted: Mon Jul 21, 2003 10:00 pm
by jammin
I´m working with Win98,sorry.

Somebody here with the same problem ?

Posted: Mon Jul 21, 2003 10:09 pm
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 :(

Posted: Mon Jul 21, 2003 11:35 pm
by traumatic
Works for me. WinXP, GeForce4 Ti 4200

Posted: Tue Jul 22, 2003 11:03 am
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?

Posted: Tue Jul 22, 2003 9:36 pm
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


Posted: Tue Jul 22, 2003 10:51 pm
by Num3
Compiled the source code.... and works just fine !

Excellent work ! Very impressive :P