OpenGL window pauses for no reason

Linux specific questions.
wolfman775
Posts: 104
Joined: Apr 30, 2009 15:20
Location: Dumbarton, Scotland

OpenGL window pauses for no reason

Postby wolfman775 » May 20, 2011 12:06

I have this simple Dancing squares demo:

Code: Select all

' My first try at an openGL program
'
#include "GL/gl.bi"
#include "GL/glu.bi"
#include "fbgfx.bi"

' Create a variable for the rotation
Dim qrot As Double

' Create a window
ScreenRes 640,480,32,, fb.GFX_OPENGL

' Setup OpenGL
glViewport 0, 0, 640, 480
glMatrixMode GL_PROJECTION
glLoadIdentity()
gluPerspective 45.0, 640.0/480.0, 0.1, 100.0
glMatrixMode GL_MODELVIEW
glLoadIdentity()

' The main program is here
Do
   ' Clear the screen
   glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT
      glLoadIdentity()
      
      ' Now position ourselves
      glTranslatef -2, sin(qrot/5), -10
      
      ' Rotate for the Quad
      glRotatef qrot, 0.1, 0.5, 0.1
      
      ' Draw a Quad
      glBegin(GL_QUADS)
         glColor3f(0.0, 0.5, 1.0)
         
         glVertex3f(0,0,0)
         glVertex3f(1,0,0)
         glVertex3f(1,1,0)
         glVertex3f(0,1,0)
      glEnd()
      
      ' Reposition ourselves
      glTranslatef 1, 0, 6
      
      ' Unrotate (Well sort off) so that the other square stays
        ' facing the same direction
      glRotatef -qrot, 0.1, 0.5, 0.1
      
      ' Draw another quad
      glBegin(GL_QUADS)
         glColor4f(0.5, 0.0, 1.0, 0.5)
         
         glVertex3f(0.0,0.0,0.0)
         glVertex3f(0.5,0.0,0.0)
         
         glColor4f(1.0, 0.0, 0.5, 1.0)
         
         glVertex3f(0.5,0.5,0.0)
         glVertex3f(0.0,0.5,0.0)
      glEnd()
      
      ' Increase the rotation
      qrot += 1
      
      ' Update the screen
      flip()
Loop Until Multikey(1)


But when I run it will randomly freeze every few seconds unless i move the mouse (Or the window).

fb 0.22.0 (Just installed because 0.21.1 had an openGL problem)
Ubuntu 11.04
TJF
Posts: 3502
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Postby TJF » May 20, 2011 13:26

Hey!

Your code looks OK. It runs well on my box (no freeze at all: Ubuntu 11.04, fbc 0.22, VIA-graphic chip and OpenChrome driver).

It may be an issue of the OpenGl-part of your graphic driver.
wolfman775
Posts: 104
Joined: Apr 30, 2009 15:20
Location: Dumbarton, Scotland

Postby wolfman775 » May 20, 2011 13:40

I Don't think its the driver because I just downloaded lesson 37 from the NeHe tutorials (The "Linux/GLUT" code) and compiled that and it doesn't do the same thing. I also tried compiling the FreeBASIC version of lesson 5 (/usr/local/share/freebasic/exapmles/GL/NeHe/lesson05.bas) and it has the same problem.
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Postby Galeon » May 20, 2011 14:01

It freezes on mine:

Intel® Pentium(R) D CPU 2.80GHz × 2
2.0 GB RAM
Intel Corporation 82946GZ/GL Integrated Graphics Controller
(Intel® 946GZ GEM 20100330 DEVELOPMENT x86/MMX/SSE2)
Ubuntu 11.04 (natty)
GNOME 3.0.1
32-bit
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Postby pestery » May 20, 2011 14:29

I had mixed results. On WinXP it ran fine, but on Ubuntu it ran at super speed! Although no freezing in either case. I fixed the super speed by adding ScreenSync() before the Flip() command. By the way, I'm using fbc 0.21.1 on WinXP and I think 0.20.0 on Ubuntu (I forgot to check while I was logged in).
wolfman775
Posts: 104
Joined: Apr 30, 2009 15:20
Location: Dumbarton, Scotland

Postby wolfman775 » May 20, 2011 14:32

I think it might be to do with compiz, in CompizConfig Settings Manager go to worarounds and select "fix screen updates in XGL with fglrx. This doesn't stop the freezing but makes it much less frequent.

EDIT:
Actually no, it just started doing it again anyway.
Landeel
Posts: 703
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Postby Landeel » May 21, 2011 0:03

Works super fast for me in Kubuntu 8.04.
After adding vsync, works fine. (http://www.freebasic.net/forum/viewtopic.php?t=13715&highlight=vsync)
Galeon
Posts: 563
Joined: Apr 08, 2009 5:30
Location: Philippines
Contact:

Postby Galeon » May 21, 2011 1:02

I tried what Landeel have said then these showed up in the console:
OpenGL max texture size is : 4096
OpenGL extensions : GL_ARB_copy_buffer GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_draw_elements_base_vertex GL_ARB_explicit_attrib_location GL_ARB_fragment_coord_conventions GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_framebuffer_object GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_map_buffer_range GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_provoking_vertex GL_ARB_seamless_cube_map GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_shadow GL_ARB_sync GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_mirrored_repeat GL_ARB_texture_non_power_of_two GL_ARB_texture_rectangle GL_ARB_texture_rg GL_ARB_texture_swizzle GL_ARB_transpose_matrix GL_ARB_vertex_array_bgra GL_ARB_vertex_array_object GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_window_pos GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_logic_op GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_copy_texture GL_EXT_draw_buffers2 GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_framebuffer_object GL_EXT_gpu_program_parameters GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_pixels GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_polygon_offset GL_EXT_provoking_vertex GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_shader_objects GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_subtexture GL_EXT_texture3D GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_add GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias GL_EXT_texture_object GL_EXT_texture GL_EXT_texture_rectangle GL_EXT_texture_sRGB GL_EXT_texture_swizzle GL_EXT_vertex_array_bgra GL_EXT_vertex_array GL_OES_EGL_image GL_OES_read_format GL_3DFX_texture_compression_FXT1 GL_APPLE_client_storage GL_APPLE_object_purgeable GL_APPLE_packed_pixels GL_APPLE_vertex_array_object GL_ATI_blend_equation_separate GL_ATI_envmap_bumpmap GL_ATI_separate_stencil GL_ATI_texture_env_combine3 GL_IBM_multimode_draw_arrays GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_INGR_blend_func_separate GL_MESA_pack_invert GL_MESA_texture_signed_rgba GL_MESA_window_pos GL_MESA_ycbcr_texture GL_NV_blend_square GL_NV_depth_clamp GL_NV_light_max_exponent GL_NV_packed_depth_stencil GL_NV_texgen_reflection GL_NV_texture_env_combine4 GL_NV_texture_rectangle GL_NV_vertex_program1_1 GL_NV_vertex_program GL_SGIS_generate_mipmap GL_SGIS_texture_border_clamp GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod GL_SUN_multi_draw_arrays
OpenGL : using glXSwapIntervalSGI
OpenGL : could not find the extensions


The new code (not sure if this is correct):

Code: Select all

' My first try at an openGL program
'
#include "GL/gl.bi"
#include "GL/glu.bi"
#include "fbgfx.bi"

' Create a variable for the rotation
Dim qrot As Double

' Create a window
ScreenRes 640,480,32,, fb.GFX_OPENGL

' Setup OpenGL
glViewport 0, 0, 640, 480
glMatrixMode GL_PROJECTION
glLoadIdentity()
gluPerspective 45.0, 640.0/480.0, 0.1, 100.0
glMatrixMode GL_MODELVIEW
glLoadIdentity()

Dim Shared CONSOLEHANDLE As Integer
CONSOLEHANDLE=Freefile
Open cons For Output As #CONSOLEHANDLE

Sub glSetVSync(Byval value As Integer)
Dim SwapInterval As Function Cdecl(Byval interval As Integer) As Integer
Dim As Integer maxtexturesize
glGetIntegerv(GL_MAX_TEXTURE_SIZE, @maxtexturesize)
Print #CONSOLEHANDLE,"OpenGL max texture size is : ";str(maxtexturesize)
Dim As String glextensions=*glGetString(GL_EXTENSIONS)
Print #CONSOLEHANDLE,"OpenGL extensions : ";glextensions

If (Instr(glextensions, "WGL_EXT_swap_control") <> 0) Then
        Print #CONSOLEHANDLE, "OpenGL : found extension WGL_EXT_swap_control"
        SwapInterval = ScreenGLProc("wglSwapIntervalEXT")
        Print #CONSOLEHANDLE, "OpenGL : using wglSwapIntervalEXT"
Else
    SwapInterval = ScreenGLProc("glXSwapIntervalSGI")
    Print #CONSOLEHANDLE, "OpenGL : using glXSwapIntervalSGI"
End If
If (SwapInterval <> 0) Then
        If value Then
                Print #CONSOLEHANDLE, "OpenGL : setting vsync ON"
        Else
                Print #CONSOLEHANDLE, "OpenGL : setting vsync OFF"
        End If
        SwapInterval(value)
Else
    Print #CONSOLEHANDLE, "OpenGL : could not find the extensions"
End If
End Sub

' The main program is here
Do
        ' Clear the screen
        glClear GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT
           glLoadIdentity()
         
           ' Now position ourselves
           glTranslatef -2, sin(qrot/5), -10
         
           ' Rotate for the Quad
           glRotatef qrot, 0.1, 0.5, 0.1
         
           ' Draw a Quad
           glBegin(GL_QUADS)
                   glColor3f(0.0, 0.5, 1.0)
                 
                   glVertex3f(0,0,0)
                   glVertex3f(1,0,0)
                   glVertex3f(1,1,0)
                   glVertex3f(0,1,0)
           glEnd()
         
           ' Reposition ourselves
           glTranslatef 1, 0, 6
         
           ' Unrotate (Well sort off) so that the other square stays
        ' facing the same direction
           glRotatef -qrot, 0.1, 0.5, 0.1
         
           ' Draw another quad
           glBegin(GL_QUADS)
                   glColor4f(0.5, 0.0, 1.0, 0.5)
                 
                   glVertex3f(0.0,0.0,0.0)
                   glVertex3f(0.5,0.0,0.0)
                 
                   glColor4f(1.0, 0.0, 0.5, 1.0)
                 
                   glVertex3f(0.5,0.5,0.0)
                   glVertex3f(0.0,0.5,0.0)
           glEnd()
         
           ' Increase the rotation
           qrot += 1
         
           ' Update the screen
           glSetVSync(1)
           flip()
Loop Until Multikey(1)

Close #CONSOLEHANDLE


It still freezes here.
Landeel
Posts: 703
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Postby Landeel » May 21, 2011 17:33

You're supposed to call glSetVSync just once in the beginning of the code.

It won't work anyway.
OpenGL : could not find the extensions


May I ask what video card / drivers are you using?

Return to “Linux”

Who is online

Users browsing this forum: No registered users and 3 guests