From 63c56db5d404ea19cda0b40474ff1ae148327a94 Mon Sep 17 00:00:00 2001 From: Laurent Carlier Date: Sat, 2 Apr 2011 16:39:17 +0000 Subject: [PATCH] [EXAMPLES] * BUG: Update to new gb.sdl behaviour. git-svn-id: svn://localhost/gambas/trunk@3727 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- examples/examples/OpenGL/3DWebCam/.icon.png | Bin 4389 -> 4405 bytes .../OpenGL/3DWebCam/.src/Mmain.module | 112 +++++++++--------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/examples/examples/OpenGL/3DWebCam/.icon.png b/examples/examples/OpenGL/3DWebCam/.icon.png index ca0623ac61ed1680745b1a96f22c7f367b210393..f437814d9c2b84a5d4bc62d2036f37b23af23b68 100644 GIT binary patch delta 24 ecmZ3gv{h+>3NK5slV=DA5Y%v_bZk^)5d;8L2nH!u&14;k@ diff --git a/examples/examples/OpenGL/3DWebCam/.src/Mmain.module b/examples/examples/OpenGL/3DWebCam/.src/Mmain.module index 56756442c..2ab60664c 100644 --- a/examples/examples/OpenGL/3DWebCam/.src/Mmain.module +++ b/examples/examples/OpenGL/3DWebCam/.src/Mmain.module @@ -1,36 +1,36 @@ ' Gambas module file -PRIVATE hWebCam AS VideoDevice -PRIVATE CONST ScrWidth AS Integer = 640 -PRIVATE CONST ScrHeight AS Integer = 480 +Private hWebCam As VideoDevice +Private Const ScrWidth As Integer = 640 +Private Const ScrHeight As Integer = 480 ' Needed for frame count -PRIVATE Frames AS Integer -PRIVATE CTime AS Float +Private Frames As Integer +Private CTime As Float ' Rotations -PRIVATE xrot AS Float -PRIVATE yrot AS Float -PRIVATE zrot AS Float +Private xrot As Float +Private yrot As Float +Private zrot As Float ' texture -PRIVATE textures AS NEW Integer[] -PRIVATE Screen AS NEW Window(TRUE) AS "Screen" +Private textures As New Integer[] +Private Screen As New Window(True) As "Screen" -PRIVATE logo AS image -PRIVATE tmpLogo AS Image -PRIVATE hTimer AS NEW Timer AS "Timer1" -PRIVATE count AS Integer -PRIVATE UpdateLogo AS Boolean +Private logo As Image +Private tmpLogo As Image +Private hTimer As New Timer As "Timer1" +Private count As Integer +Private UpdateLogo As Boolean -PUBLIC SUB Main() +Public Sub Main() - TRY hWebCam = NEW VideoDevice("/dev/video0") - IF ERROR THEN - PRINT ("Unable to open video device") - RETURN + Try hWebCam = New VideoDevice("/dev/video0") + If Error Then + Print ("Unable to open video device") + Return - END IF + End If hWebCam.Hue = 10 hWebCam.Color = 10 hWebcam.Resize(320, 240) @@ -41,27 +41,27 @@ PUBLIC SUB Main() screen.Width = ScrWidth screen.Height = ScrHeight Screen.show() - Screen.Border = Screen.Resizable + Screen.Resizable = True InitGL() textures = Gl.GenTextures(1) LoadTextures() Screen_resize() CTime = Timer() hTimer.Delay = 200 - hTimer.Enabled = TRUE + hTimer.Enabled = True -END +End -PUBLIC SUB LoadTextures() +Public Sub LoadTextures() Gl.BindTexture(gl.GL_TEXTURE_2D, textures[0]) Gl.TexImage2D(logo) Gl.TexParameteri(gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR) Gl.TexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR) -END +End -PUBLIC SUB InitGL() +Public Sub InitGL() ' Enable smooth shading Gl.ShadeModel(gl.GL_SMOOTH) @@ -78,24 +78,24 @@ PUBLIC SUB InitGL() ' Really Nice Perspective Calculations Gl.Hint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_NICEST) -END +End -PUBLIC SUB Screen_close() +Public Sub Screen_close() ' Delete textures if needed - IF (textures.count > 0) THEN Gl.DeleteTextures(textures) + If (textures.count > 0) Then Gl.DeleteTextures(textures) -END +End -PUBLIC SUB Screen_resize() +Public Sub Screen_resize() ' Width/Height Ratio - DIM ratio AS Float - DIM Height AS Integer + Dim ratio As Float + Dim Height As Integer Height = Screen.Height ' Protect against a divide by zero - IF Height = 0 THEN Height = 1 + If Height = 0 Then Height = 1 ratio = Screen.Width / Height @@ -112,21 +112,21 @@ PUBLIC SUB Screen_resize() Gl.MatrixMode(gl.GL_MODELVIEW) GL.LoadIdentity() -END +End -PUBLIC SUB Screen_Draw() +Public Sub Screen_Draw() - DIM calc AS Float - INC count - IF UpdateLogo THEN + Dim calc As Float + Inc count + If UpdateLogo Then 'count = 0 'logo = tmpLogo logo.Resize(256, 256) LoadTextures() - UpdateLogo = FALSE - ENDIF + UpdateLogo = False + Endif - Gl.Clear(gl.GL_COLOR_BUFFER_BIT OR gl.GL_DEPTH_BUFFER_BIT) + Gl.Clear(gl.GL_COLOR_BUFFER_BIT Or gl.GL_DEPTH_BUFFER_BIT) Gl.LoadIdentity() Gl.Translatef(0.0, 0.0, -5.0) @@ -225,32 +225,32 @@ PUBLIC SUB Screen_Draw() Gl.End() - INC (Frames) - IF (Timer() > CTime + 5) THEN + Inc (Frames) + If (Timer() > CTime + 5) Then calc = Timer() - CTime - PRINT CStr(Frames) & " frames in " & Format$(calc, "#.0") & " seconds = " & Format$((Frames / calc), "######.000") & " FPS" + Print CStr(Frames) & " frames in " & Format$(calc, "#.0") & " seconds = " & Format$((Frames / calc), "######.000") & " FPS" Frames = 0 CTime = Timer() - ENDIF + Endif xrot += 0.3 ' X Axis Rotation yrot += 0.2 ' Y Axis Rotation zrot += 0.4 ' Z Axis Rotation - WAIT 0.05 + Wait 0.05 -END +End -PUBLIC SUB Screen_keyPress() +Public Sub Screen_keyPress() - IF key.Code = key.F1 THEN Screen.Fullscreen = NOT Screen.Fullscreen - IF key.Code = key.Esc THEN Screen.Close() + If key.Code = key.F1 Then Screen.Fullscreen = Not Screen.Fullscreen + If key.Code = key.Esc Then Screen.Close() -END +End -PUBLIC SUB Timer1_Timer() +Public Sub Timer1_Timer() logo = hWebCam.Image - UpdateLogo = TRUE + UpdateLogo = True -END +End