Author Topic: how to use a timer  (Read 522 times)

0 Members and 1 Guest are viewing this topic.

chrisc

  • Guest
how to use a timer
« on: April 16, 2018, 09:52:49 AM »
Hello

i'm  trying to make a splash screen which will time out in 5 secs

my preliminary code is below -- it does not exit after 5 secs?  any help appreciated

Code: [Select]
'   includepath "$\inc\"
'  Apr 16 2018
' http://www.oxygenbasic.org/forum/index.php?PHPSESSID=5jj7gcka25lpdnu9lie1jb4h60&topic=1636.msg17838;topicseen#msg17838
  $ FileName  "Splash.exe"
  include    "$\inc\RTL64.inc"

'  Set the width and height of the display window
  % width     300
  % height    300
   %ID_Timer  = 500
  $ fontA     "Arial",FW_SEMIBOLD

  $ title     "Rotating Quad2"
   % ExplicitMain
 
 '  Note that you need to place OpenglSceneFrame.inc , winUtil.inc
'   and glWinUtil.inc into the same folder when compiling
   include   "OpenglSceneFrame.inc"

   

'  Note that we must specify exactly these equates
'  all in uppercase ,  otherwise it can results in compilation errors
#define GL_TRIANGLES        0x0004
#define GL_TRIANGLE_FAN 0x0006
#define GL_QUAD_STRIP     0x0008
#define  SWP_NOSIZE         0x0001
#define  SWP_NOMOVE      0x0002
#define   SWP_SHOWWINDOW      0x0040
#define  SW_SHOW   5
#define  SM_CYCAPTION  4


sys wMsg,  wParam , lparam


'========================
' this center the display window
' on the screen
' but it was not use in this program
sub Center(sys hwnd)
    RECT rc
    sys x,y
    GetWindowRect(hwnd,&rc)
    x = (GetSystemMetrics(SM_CXSCREEN) - (rc.right-rc.left))\2
    y = (GetSystemMetrics(SM_CYSCREEN) -
           (rc.bottom-rc.top+GetSystemMetrics(SM_CYCAPTION)))\2
 
    SetWindowPos (hWnd, 0, x, y, 0, 0, SWP_NOSIZE)
end sub



 function WndMessages( hWnd, wMsg,  wParam , lparam ) as sys, link WndProcExtra
  ============================================================================
  select wMsg
       
'  case WM_ACTIVATE
    '  Center(hWnd)

  case WM_TIMER
       
                 KillTimer hWnd, %ID_Timer
                  print  " timeout"                     '  it doesn't  reach here?
   

  end select
 
  end function




  sub initialize(sys hWnd)
  '=======================
     ' 5 Sec timeout for splash screen
       SetTimer hWnd, %ID_Timer, 5000, 0
      WndMessages( hWnd, wMsg,  wParam , lparam )
  end sub
  '




  sub scene(sys hWnd)
  '==================
  '
  static single s1,s2,s3,s4,ang1

 

'  increase this angle for faster rotation between 1 and 10
   angi1=7
  '
  glLoadIdentity
  glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT

 '  Greenish Beige background color
   glClearColor .91,.94,.82,1


'  ' display the text label1
    glPushMatrix
    gltranslatef  -.63,.8,-2.5
    glScalef( 0.25, 0.25, .01)
    glColor3f  0.20, 0.0, 1.0
    gPrint    "Your Product"


 ' display the text label2
   gltranslatef  -5., -1.7,-1.0
'   glScalef( 0.15, 0.2, .01)
  glColor3f 1.0, 0.0, 0.0
   gPrint    "Label 2"




  '
  '
  s1=.2    'x y
  s2=-1    'z
  s3=0.5   'color
  s4=s3*.2 'color
  '
  glrotatef ang1, 0,0,1




  '
'   original square -- this work
' glbegin GL_QUADS
' glcolor4f   00,  s3,  s3, 1 : glvertex3f -s1, -s1,  s2
 ' glcolor4f   s3,  s3,  00, 1 : glvertex3f  s1, -s1,  s2
 ' glcolor4f   s4,   0,  s3, 1 : glvertex3f  s1,  s1,  s2
'  glcolor4f   s4,   0,  s3, 1 : glvertex3f -s1,  s1,  s2
'  glend


'   semi triangle  -- this work
'  glBegin  GL_TRIANGLE_FAN
   '     glcolor4f   00,  s3,  s3, 1  : glvertex3f  -s1, -s1,  s2   '1st triangle
   '      glcolor4f   s3,  s3,  00, 1 : glvertex3f  s1, -s1,  s2
   '      glcolor4f   s4,   0,  s3, 1  :  glvertex3f  -.3,-.1,  s2
   '      glcolor4f   s4,   0,  s3, 1  :  glvertex3f  s1,  s1 ,  -s2   '2nd
    '      glcolor4f   00,  s3,  s3, 1 : glvertex3f  s1,  -s1,  s2   '3rd
   '       glcolor4f   00,  s3,  s3, 1 : glvertex3f  s1,  s1,  -s2      '4th
  '   glEnd

 '  Triangle  -- this work
'   ensure that  z = -1.  thru' out
 '  glBegin GL_TRIANGLES 
'       glColor3f 1.0, 0.0, 0.0 :   glVertex3f   0.0,  .3,-1.
'       glColor3f 0.0, 1.0, 0.0 :   glVertex3f  0.2, -0.1,-1.
'       glColor3f 0.0, 0.0, 1.0 :   glVertex3f  -0.2,-0.1,-1.
' glEnd


'  Triangle  -- this work
'   this place triangle off center and if we increase the  -ve z
'   the object gets smaller and will spin at a distance of 0.8 from the center
 '   glTranslatef .80, 0.0, -2.0
  ' glBegin GL_TRIANGLES
'  glColor3f 1.0, 0.0, 0.0 : glVertex3f 0.0,  .30,-1.0
'  glColor3f 0.0, 1.0, 0.0 : glVertex3f 0.26,-0.15,-1.0
 ' glColor3f 0.0, 0.0, 1.0 : glVertex3f-0.26,-0.15,-1.0
'  glEnd

'  this work
' Half red square rotated off center
'   glTranslatef 2.40,0.0,-10.0
'   glBegin(GL_QUADS)
'  glColor3f   1.0, 0.0, 1.0
'  glVertex3f -1.0,-1.0, 0.0
'  glColor3f   1.0, 1.0, 1.0
'  glVertex3f  1.0,-1.0, 0.0
'  glVertex3f  1.0, 1.0, 0.0
'  glColor3f   1.0, 1.0, 1.0
'  glVertex3f -1.0, 1.0, 0.0
'  glEnd


'  rotating  off center Cube  -- this work
 ' glTranslatef -2.0, -2.0, -12.0
 ' glBegin GL_QUADS
 ' glColor3f   0.0, 1.0, 0.0
 ' glVertex3f  1.0, 1.0,-1.0
 ' glVertex3f -1.0, 1.0,-1.0
'  glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f  1.0, 1.0, 1.0
 ' glColor3f   1.0, 0.5, 0.0
 ' glVertex3f  1.0,-1.0, 1.0
 ' glVertex3f -1.0,-1.0, 1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f  1.0,-1.0,-1.0
 ' glColor3f   1.0, 0.0, 0.0
'  glVertex3f  1.0, 1.0, 1.0
 ' glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f -1.0,-1.0, 1.0
 ' glVertex3f  1.0,-1.0, 1.0
  'glColor3f   1.0, 1.0, 0.0
 ' glVertex3f  1.0,-1.0,-1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f -1.0, 1.0,-1.0
 ' glVertex3f  1.0, 1.0,-1.0
  'glColor3f   0.0, 0.0, 1.0
 ' glVertex3f -1.0, 1.0, 1.0
 ' glVertex3f -1.0, 1.0,-1.0
 ' glVertex3f -1.0,-1.0,-1.0
 ' glVertex3f -1.0,-1.0, 1.0
' glColor3f  1.0, 0.0, 1.0
 ' glVertex3f 1.0, 1.0,-1.0
 ' glVertex3f 1.0, 1.0, 1.0
 ' glVertex3f 1.0,-1.0, 1.0
'  glVertex3f 1.0,-1.0,-1.0
' glEnd
 

' DrawDiamond   -- this work  very well
    glTranslatef 1.4,0.0,-20.0
      glbegin GL_TRIANGLE_FAN  'top part
          glcolor3ub 255,   0,   0 : glvertex3f  0, 0.714, 0
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
          glcolor3ub   0,   0, 255 : glvertex3f  0.5, 0,-0.5
         glcolor3ub   0, 255,   0 : glvertex3f -0.5, 0,-0.5
          glcolor3ub   0,   0, 255 : glvertex3f -0.5, 0, 0.5
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
       glend
       glbegin GL_TRIANGLE_FAN    'bottom part
         glcolor3ub 255,   0,   0 : glvertex3f  0,-0.714, 0
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
          glcolor3ub   0,   0, 255 : glvertex3f -0.5, 0, 0.5
          glcolor3ub   0, 255,   0 : glvertex3f -0.5, 0,-0.5
          glcolor3ub   0,   0, 255 : glvertex3f  0.5, 0,-0.5
          glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
      glend



    'draws a 3D cube object  -- drawcube  works
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the cube smaller
  '     glTranslatef 1.4,0.0,-7.0
  '    glBegin  GL_QUADS
  '      glRotatef  ang1, 1.0, 1.0, 1.0         ' Rotate the quad on the X axis
  '     glcolor3ub 255,0,0
   '    glVertex3f  0.5,  0.5, -0.5    ' Top right of the quad (Top)
 '      glVertex3f -0.5,  0.5, -0.5    ' Top left of the quad (Top)
  '     glVertex3f -0.5,  0.5,  0.5    ' Bottom left of the quad (Top)
  '     glVertex3f  0.5,  0.5,  0.5    ' Bottom right of the quad (Top)

   '    glcolor3ub 255,255,0
   '    glVertex3f  0.5, -0.5,  0.5    ' Top right of the quad (Bottom)
   '    glVertex3f -0.5, -0.5,  0.5    ' Top left of the quad (Bottom)
   '    glVertex3f -0.5, -0.5, -0.5    ' Bottom left of the quad (Bottom)
   '    glVertex3f  0.5, -0.5, -0.5    ' Bottom right of the quad (Bottom)

    '   glcolor3ub 255,0,255
    '   glVertex3f  0.5,  0.5,  0.5    ' Top right of the quad (Front)
    '   glVertex3f -0.5,  0.5,  0.5    ' Top left of the quad (Front)
   '    glVertex3f -0.5, -0.5,  0.5    ' Bottom left of the quad (Front)
   '    glVertex3f  0.5, -0.5,  0.5    ' Bottom right of the quad (Front)

   '    glcolor3ub 0,0,255
   '    glVertex3f  0.5, -0.5, -0.5    ' Top right of the quad (Back)
    '   glVertex3f -0.5, -0.5, -0.5    ' Top left of the quad (Back)
    '   glVertex3f -0.5,  0.5, -0.5    ' Bottom left of the quad (Back)
    '   glVertex3f  0.5,  0.5, -0.5    ' Bottom right of the quad (Back)

   '    glcolor3ub 0,255,255
  '     glVertex3f -0.5,  0.5,  0.5    ' Top right of the quad (Left)
   '    glVertex3f -0.5,  0.5, -0.5    ' Top left of the quad (Left)
    '   glVertex3f -0.5, -0.5, -0.5    ' Bottom left of the quad (Left)
   '    glVertex3f -0.5, -0.5,  0.5    ' Bottom right of the quad (Left)

    '   glcolor3ub 255,128,0
     '  glVertex3f  0.5,  0.5, -0.5    ' Top right of the quad (Right)
    '   glVertex3f  0.5,  0.5,  0.5    ' Top left of the quad (Right)
    '   glVertex3f  0.5, -0.5,  0.5    ' Bottom left of the quad (Right)
    '   glVertex3f  0.5, -0.5, -0.5    ' Bottom right of the quad (Right)
  '  glEnd
   
  sleep (2)
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the cube smaller
   glLoadIdentity
      glTranslatef 2.5, -2.90, -15.0            ' Move right 1.5 units and into the screen
      glRotatef  ang1, 1.0, 1.0, 1.0         ' Rotate the quad on the X axis
      glBegin  GL_QUADS
         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)

         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)

         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)

         glColor3f   1.0,  1.0,  0.0         ' Set the color to yellow
         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)
         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)

         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)

         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


   sleep (2)
 '   draw the pyramid using triangles
'    note that by increasing  the -ve value of the z in glTranslatef
'    you can make the diamond smaller
 ' // Reset the view
      glLoadIdentity

      glTranslatef -1.5, -1.0, -10.0           ' Move left 1.5 units and into the screen
      glRotatef  ang1, 0.0, 1.0, 0.0          ' Rotate the triangle on the Y axis

      glBegin %GL_TRIANGLES
         ' Front
         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
         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
         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
         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





  '
  'UPDATE ROTATION ANGLES
  '----------------------
  '
  ang1+=angi1
  if ang1>360 then ang1-=360
  '
  end sub


  sub Release(sys hwnd)
  '====================
  end sub


' display the window and centralize it  using place = 2
MainWindow     width,height,%WS_POPUP ,2





Mike Lobanovsky

  • Admin Support Member
  • *****
  • Posts: 1872
Re: how to use a timer
« Reply #1 on: April 16, 2018, 03:15:31 PM »
Actually, it does exit but only in 32 bits. Which means the code is viable (though unsafe). I think Charles has to step in.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, 2 x nVidia GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

chrisc

  • Guest
Re: how to use a timer
« Reply #2 on: April 16, 2018, 04:49:08 PM »
Thanxx for the info, Mike
good to know that it works in 32bit

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3856
    • Oxygen Basic
Re: how to use a timer
« Reply #3 on: April 16, 2018, 09:24:00 PM »
Hi Chris,

This is a display and fade routine, using the 60Hz frame rate as a time base. All you need to do is insert it at the start of Scene()

Code: [Select]
  'DISPLAY AND FADE OUT
  if not picking then
    static Counter '60Hz Frame counter
    counter++
    if counter>180 'AFTER 3 SECONDS
      int WindowOpacity
      int t=(counter-180)*255/120 '2 sec fade
      if t>255 then t=255
      WindowOpacity=255-t
      if counter=300 '5 SECONDS
        CloseWindow 'REQUEST SHUT DOWN
      end if
      'Set WS_EX_LAYERED on this window
      SetWindowLong(hwnd, GWL_EXSTYLE,
      GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED)
      SetLayeredWindowAttributes(hwnd, 0, WindowOpacity, LWA_ALPHA);
    end if
  end if

Arnold

  • Hero Member
  • *****
  • Posts: 721
Re: how to use a timer
« Reply #4 on: April 17, 2018, 01:25:47 AM »
Hi Charles,

I applied your routine, compiled to 32-bit and 64-bit and the splash screen fades nicely out. May I ask two questions:
I used Set/GetWindowLongPtr. Does it matter?
How would the splash screen be applied in an application? I assume I have to create a Main Window and a Child Window which is the splash screen. Must I use different Scene() routines?

Roland

Code: OxygenBasic
  1.   $ FileName  "Splash.exe"
  2.  
  3. '  uses RTL32
  4. '  uses RTL64
  5.  
  6.    'Set the width and height of the display window
  7.   % width     300
  8.    % height    300
  9.  
  10.    $ fontA     "Arial",FW_SEMIBOLD
  11.  
  12.    $ title     "Rotating Quad"
  13.    % ExplicitMain
  14.  
  15.    uses OpenglSceneFrame
  16.    
  17.  
  18. '  Note that we must specify exactly these equates
  19. '  all in uppercase ,  otherwise it can results in compilation errors
  20. #define GL_TRIANGLES    0x0004
  21. #define GL_TRIANGLE_FAN 0x0006
  22. #define GL_QUAD_STRIP   0x0008
  23. #define SWP_NOSIZE      0x0001
  24. #define SWP_NOMOVE      0x0002
  25. #define SWP_SHOWWINDOW  0x0040
  26. #define SW_SHOW              5
  27. #define SM_CYCAPTION         4
  28.  
  29.  
  30.  
  31.   sub initialize(sys hWnd)
  32.   '=======================
  33.  end sub
  34.   '
  35.  
  36.   sub scene(sys hWnd)
  37.   '==================
  38.  '
  39.  static single s1,s2,s3,s4,ang1
  40.  
  41.   'DISPLAY AND FADE OUT
  42.  if not picking then
  43.     static Counter '60Hz Frame counter
  44.    counter++
  45.     if counter>180 'AFTER 3 SECONDS
  46.      int WindowOpacity
  47.       int t=(counter-180)*255/120 '2 sec fade
  48.      if t>255 then t=255
  49.       WindowOpacity=255-t
  50.       if counter=300 '5 SECONDS
  51.        CloseWindow 'REQUEST SHUT DOWN
  52.      end if
  53.       'Set WS_EX_LAYERED on this window
  54.      SetWindowLongPtr(hwnd, GWL_EXSTYLE,
  55.       GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED)
  56.       SetLayeredWindowAttributes(hwnd, 0, WindowOpacity, LWA_ALPHA);
  57.     end if
  58.   end if
  59.  
  60.   'increase this angle for faster rotation between 1 and 10
  61.  angi1=7
  62.   '
  63.  glLoadIdentity
  64.   glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
  65.  
  66.   'Greenish Beige background color
  67.  glClearColor .91,.94,.82,1
  68.  
  69.  
  70.   'display the text label1
  71.   glPushMatrix
  72.    gltranslatef  -.63,.8,-2.5
  73.    glScalef( 0.25, 0.25, .01)
  74.    glColor3f  0.20, 0.0, 1.0
  75.    gPrint    "Your Product"
  76.  
  77.  
  78.   'display the text label2
  79.   gltranslatef  -5., -1.7,-1.0
  80.   'glScalef( 0.15, 0.2, .01)
  81.   glColor3f 1.0, 0.0, 0.0
  82.    gPrint    "Label 2"
  83.  
  84.  
  85.  
  86.    s1=.2    'x y
  87.   s2=-1    'z
  88.   s3=0.5   'color
  89.   s4=s3*.2 'color
  90.   '
  91.   glrotatef ang1, 0,0,1
  92.  
  93.  
  94.    'DrawDiamond   -- this work  very well
  95.   glTranslatef 1.4,0.0,-20.0
  96.       glbegin GL_TRIANGLE_FAN  'top part
  97.          glcolor3ub 255,   0,   0 : glvertex3f  0, 0.714, 0
  98.           glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
  99.           glcolor3ub   0,   0, 255 : glvertex3f  0.5, 0,-0.5
  100.          glcolor3ub   0, 255,   0 : glvertex3f -0.5, 0,-0.5
  101.           glcolor3ub   0,   0, 255 : glvertex3f -0.5, 0, 0.5
  102.           glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
  103.       glend
  104.       glbegin GL_TRIANGLE_FAN    'bottom part
  105.         glcolor3ub 255,   0,   0 : glvertex3f  0,-0.714, 0
  106.           glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
  107.           glcolor3ub   0,   0, 255 : glvertex3f -0.5, 0, 0.5
  108.           glcolor3ub   0, 255,   0 : glvertex3f -0.5, 0,-0.5
  109.           glcolor3ub   0,   0, 255 : glvertex3f  0.5, 0,-0.5
  110.           glcolor3ub   0, 255,   0 : glvertex3f  0.5, 0, 0.5
  111.       glend
  112.  
  113.  
  114.    
  115.    sleep (2)
  116.   'note that by increasing  the -ve value of the z in glTranslatef
  117.  'you can make the cube smaller
  118.   glLoadIdentity
  119.       glTranslatef 2.5, -2.90, -15.0            ' Move right 1.5 units and into the screen
  120.      glRotatef  ang1, 1.0, 1.0, 1.0         ' Rotate the quad on the X axis
  121.      glBegin  GL_QUADS
  122.          glColor3f   0.0,  1.0,  0.0         ' Set the color to green
  123.         glVertex3f  1.0,  1.0, -1.0         ' Top right of the quad (Top)
  124.         glVertex3f -1.0,  1.0, -1.0         ' Top left of the quad (Top)
  125.         glVertex3f -1.0,  1.0,  1.0         ' Bottom left of the quad (Top)
  126.         glVertex3f  1.0,  1.0,  1.0         ' Bottom right of the quad (Top)
  127.  
  128.          glColor3f   1.0,  0.5,  0.0         ' Set the color to orange
  129.         glVertex3f  1.0, -1.0,  1.0         ' Top right of the quad (Bottom)
  130.         glVertex3f -1.0, -1.0,  1.0         ' Top left of the quad (Bottom)
  131.         glVertex3f -1.0, -1.0, -1.0         ' Bottom left of the quad (Bottom)
  132.         glVertex3f  1.0, -1.0, -1.0         ' Bottom right of the quad (Bottom)
  133.  
  134.          glColor3f   1.0,  0.0,  0.0         ' Set the color to red
  135.         glVertex3f  1.0,  1.0,  1.0         ' Top right of the quad (Front)
  136.         glVertex3f -1.0,  1.0,  1.0         ' Top left of the quad (Front)
  137.         glVertex3f -1.0, -1.0,  1.0         ' Bottom left of the quad (Front)
  138.         glVertex3f  1.0, -1.0,  1.0         ' Bottom right of the quad (Front)
  139.  
  140.          glColor3f   1.0,  1.0,  0.0         ' Set the color to yellow
  141.         glVertex3f  1.0, -1.0, -1.0         ' Top right of the quad (Back)
  142.         glVertex3f -1.0, -1.0, -1.0         ' Top left of the quad (Back)
  143.         glVertex3f -1.0,  1.0, -1.0         ' Bottom left of the quad (Back)
  144.         glVertex3f  1.0,  1.0, -1.0         ' Bottom right of the quad (Back)
  145.  
  146.          glColor3f   0.0,  0.0,  1.0         ' Set the color to blue
  147.         glVertex3f -1.0,  1.0,  1.0         ' Top right of the quad (Left)
  148.         glVertex3f -1.0,  1.0, -1.0         ' Top left of the quad (Left)
  149.         glVertex3f -1.0, -1.0, -1.0         ' Bottom left of the quad (Left)
  150.         glVertex3f -1.0, -1.0,  1.0         ' Bottom right of the quad (Left)
  151.  
  152.          glColor3f   1.0,  0.0,  1.0         ' Set the color to violet
  153.         glVertex3f  1.0,  1.0, -1.0         ' Top right of the quad (Right)
  154.         glVertex3f  1.0,  1.0,  1.0         ' Top left of the quad (Right)
  155.         glVertex3f  1.0, -1.0,  1.0         ' Bottom left of the quad (Right)
  156.         glVertex3f  1.0, -1.0, -1.0         ' Bottom right of the quad (Right)
  157.      glEnd
  158.  
  159.    sleep (2)
  160.   'draw the pyramid using triangles
  161.  'note that by increasing  the -ve value of the z in glTranslatef
  162.  'you can make the diamond smaller
  163.  'Reset the view
  164.   glLoadIdentity
  165.  
  166.       glTranslatef -1.5, -1.0, -10.0           ' Move left 1.5 units and into the screen
  167.      glRotatef  ang1, 0.0, 1.0, 0.0          ' Rotate the triangle on the Y axis
  168.  
  169.       glBegin %GL_TRIANGLES
  170.          ' Front
  171.         glColor3f   1.0,  0.0,  0.0         ' Red
  172.         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Front)
  173.         glColor3f   0.0,  1.0,  0.0         ' Green
  174.         glVertex3f -1.0, -1.0,  1.0         ' Left of triangle (Front)
  175.         glColor3f   0.0,  0.0,  1.0         ' Blue
  176.         glVertex3f  1.0, -1.0,  1.0         ' Right of triangle (Front)
  177.  
  178.          ' Right
  179.         glColor3f   1.0,  0.0,  0.0         ' Red
  180.         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Right)
  181.         glColor3f   0.0,  0.0,  1.0         ' Blue
  182.         glVertex3f  1.0, -1.0,  1.0         ' Left of triangle (Right)
  183.         glColor3f   0.0,  1.0,  0.0         ' Green
  184.         glVertex3f  1.0, -1.0, -1.0         ' Right of triangle (Right)
  185.  
  186.          ' Back
  187.         glColor3f   1.0,  0.0,  0.0         ' Red
  188.         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Back)
  189.         glColor3f   0.0,  1.0,  0.0         ' Green
  190.         glVertex3f  1.0, -1.0, -1.0         ' Left of triangle (Back)
  191.         glColor3f   0.0,  0.0,  1.0         ' Blue
  192.         glVertex3f -1.0, -1.0, -1.0         ' Right of triangle (Back)
  193.  
  194.          ' Left
  195.         glColor3f   1.0,  0.0,  0.0         ' Red
  196.         glVertex3f  0.0,  1.0,  0.0         ' Top of triangle (Left)
  197.         glColor3f   0.0,  0.0,  1.0         ' Blue
  198.         glVertex3f -1.0, -1.0, -1.0         ' Left of triangle (Left)
  199.         glColor3f   0.0,  1.0,  0.0         ' Green
  200.         glVertex3f -1.0, -1.0,  1.0         ' Right of triangle (Left)
  201.      glEnd
  202.  
  203.  
  204.   '
  205.  'UPDATE ROTATION ANGLES
  206.  '----------------------
  207.  '
  208.  ang1+=angi1
  209.   if ang1>360 then ang1-=360
  210.   '
  211.  end sub
  212.  
  213.  
  214.   sub Release(sys hwnd)
  215.   '====================
  216.  end sub
  217.  
  218.  
  219. ' display the window and centralize it  using place = 2
  220. MainWindow   width,height, WS_POPUP ,2
  221.  

chrisc

  • Guest
Re: how to use a timer
« Reply #5 on: April 17, 2018, 03:58:47 AM »
Thanxx Charles you are a maestro!

@Roland,  to apply this splash screen, i think you should use a main calling program with a main window
and call this Splash program as a dll.   so when the splash.dll exits it will not have any effect on the main program.

i maybe wrong, but i think this is doable?

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3856
    • Oxygen Basic
Re: how to use a timer
« Reply #6 on: April 17, 2018, 04:54:44 AM »
Thanks Chris,

That answers Roland's second question.

I think it's doable. Strictly speaking though, You will also need to explicitly UnregisterClass, in a DLL. This can be done after the close of the message loop in WinMain.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms644899(v=vs.85).aspx

I will add this to WinUtil.inc
Code: [Select]
  ...
  UnregisterClass @wc
  end function ; end of WinMain

Hi Roland,

I don't think it matters in this instance but we can adopt GetWindowLongPtr and SetWindowLongPtr as the standard.

chrisc

  • Guest
Re: how to use a timer
« Reply #7 on: April 17, 2018, 05:26:34 AM »
Thanxx Charles

but when i placed the UnregisterClass @wc  into WinUtil.inc  , it did not work

the main dialog also closes after the splash screen faded away?

see the atteched files

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3856
    • Oxygen Basic
Re: how to use a timer
« Reply #8 on: April 17, 2018, 09:18:07 AM »
Hmmm! This is not going to work, since it seems not to allow registration twice, even when the first is unregistered (dll window).

Will have to think of another way.

chrisc

  • Guest
Re: how to use a timer
« Reply #9 on: April 17, 2018, 10:26:04 AM »
Thanxx Charles

please take your time, my pc with Windows 10 just stop me from compiling in O2
and every exe i made it gives a message  " this app can't run on your PC "

i did everything like diabling smartscreen but not sucessful.

chrisc

  • Guest
Re: how to use a timer
« Reply #10 on: April 17, 2018, 10:47:27 AM »
Hello Charles

i tried modifying this DialogWind.o2bas  to have the below code
but when i compile and run my pc display the message   " this app can't run on your PC "

Code: [Select]
     case IDM_Splash
                   Local hsplash as sys
                   hsplash= FindWindow("Splash", "")   'Find splash handle
                     if hsplash  then
                             PostMessage(hsplash, WM_CLOSE,0,0)   
                    else
                            Splash()
                   end if




and when i placed back  the original code (as shown below) it can compile and run without that message
wonder if you have the same problem if you added the above code.  the  windowsdefender
is a nuisance

Code: [Select]
   case IDM_Splash
           Splash()








chrisc

  • Guest
Re: how to use a timer
« Reply #11 on: April 17, 2018, 07:39:46 PM »
Hello Charles

do you think that the use of the single global window handle hwnd would have make it
difficult for users to build multiple windows? 

since currently, if you close a  particular window, then all the windows would also be closed.

maybe you should make provision for multiple window handles in your winutil.inc and glwinutil.inc files