bugGNU Octave - Bugs: bug #49083, demo camlight fails using qt...

 
 

bug #49083: demo camlight fails using qt graphics_toolkit

Submitted by:  Avinoam Kalma <avinoam>
Submitted on:  Tue 13 Sep 2016 08:55:32 PM UTC  
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Avinoam Open/Closed:  Closed
Release:  4.2.0-rc1 Operating System:  Microsoft Windows

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Thu 15 Sep 2016 03:45:45 PM UTC, comment #10: 

I fixed a typo "occured" -> "occurred" and pushed your patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/3564b6b6b8d1).  Closing report.

Rik <rik5>
Project Administrator
Thu 15 Sep 2016 08:47:11 AM UTC, comment #9: 

The attached patch fixes the original issue from comment #0 for me by checking the gl error after GL_MULTISAMPLE and reacting accordingly in gl-render.cc.

From [1]: GL_MULTISAMPLE is available in OpenGL 1.3 and later. GL_INVALID_ENUM is generated by glEnable "if cap is not one of the values listed previously". That might include the case when calling a feature on a version that doesn't support it.
I guess from its documentation [2] that glIsEnabled would generate the same error.

In Octave on Windows, "__opengl_info__" returns the following for me:

version    = 1.1.0
vendor     = Microsoft Corporation
renderer   = GDI Generic
extensions =
  GL_WIN_swap_hint
  GL_EXT_bgra
  GL_EXT_paletted_texture

Is that the GL_VERSION or the version of the graphics driver?

[1]: https://www.opengl.org/sdk/docs/man2/xhtml/glEnable.xml
[2]: https://www.opengl.org/sdk/docs/man2/xhtml/glIsEnabled.xml

(file #38514)

Markus Mützel <mmuetzel>
Project Member
Thu 15 Sep 2016 01:02:10 AM UTC, comment #8: 

I think the code to check whether MULTISAMPLE is enabled is wrong.  For example, it should be possible to use

glIsEnabled (GL_MULTISAMPLE)

to check whether the feature is turned on.

There may also be a disconnect between gl-render.cc and the GLCanvas object created by Qt.  I checked with the GLCanvas object and it thinks MULTISAMPLE is enabled and that the number of samples is 4.

I was using this resource: https://www.opengl.org/sdk/docs/man2/xhtml/glGet.xml.

Also, https://www.opengl.org/wiki/Multisampling
Also, https://www.opengl.org/discussion_boards/showthread.php/148216-redbook-multisample-example-not-work-%28GL_SAMPLE_BUFFERS-0%29

Rik <rik5>
Project Administrator
Wed 14 Sep 2016 08:45:31 PM UTC, comment #7: 

The same error seems to be raised several times in opengl_renderer::init_gl_context () on Windows. The following lines set the gl error to 1280 (GL_INVALID_ENUM):

        glEnable (GL_MULTISAMPLE);
        glGetIntegerv (GL_SAMPLE_BUFFERS, &iMultiSample);
        glGetIntegerv (GL_SAMPLES, &iNumSamples);
            glDisable (GL_MULTISAMPLE);

No errors with Ubuntu.

I have prepared a changeset that checks for these errors and should treat them correctly. I will attach it here once cross-building has finished and I could test. So probably not before tomorrow.

Markus Mützel <mmuetzel>
Project Member
Wed 14 Sep 2016 05:48:18 PM UTC, comment #6: 

Thanks for checking on this.  I think you're right that we should have been checking more often for errors when we were setting up the window for plotting.

Rik <rik5>
Project Administrator
Wed 14 Sep 2016 05:43:35 PM UTC, comment #5: 

glGetError actually returns an error when entering get_maxlights.
So there must be something wrong before. The error number is 1280 which should be GL_INVALID_ENUM.
I am no way sure where this actually comes from.

I will try to narrow it down. But cross-building just takes very long...

Markus Mützel <mmuetzel>
Project Member
Wed 14 Sep 2016 04:20:52 PM UTC, comment #4: 

After reading the code again, I guess that for some reason a GL error occured before "get_maxlight" is called.
Atm, I am cross-building with the following change in gl-render.cc:

@@ -603,6 +603,8 @@

   static int max_lights = 0;

+  std::cout << "GL error: " << glGetError () << std::endl;
+
   // Check actual maximum number of lights possible
   if (max_lights == 0)
     {

That should reset a possible GL error and print the error number. Maybe that could give a hint as to what is going on here.

However, it might take some time before I have any results because cross-building is just so tedious...

@Rik: I guess something is wrong with how we are initializing OpenGL for Windows or we cause an error very early after initialization. We do not call glGetError as often as we probably should. I have also seen problems with "texturemap" on Windows on my system (see bug #46997). As far as I can see, that is the only place that glGetError was called before. That error in texturemaps disappeared for me. I guess that is because the GL error is now reset earlier in "get_maxlights" (causing problems here).

Markus Mützel <mmuetzel>
Project Member
Wed 14 Sep 2016 04:02:14 PM UTC, comment #3: 

Testing with the 4.2.0-rc1 installer in a Windows XP VM shows the same warning message for the qt AND fltk toolkits.

I'm adding Markus to the list since he essentially added the light and camlight features to Octave.  This may be hardware specific.  Maybe both of our machines have an OpenGL version that doesn't support lighting.

Rik <rik5>
Project Administrator
Wed 14 Sep 2016 01:29:05 PM UTC, comment #2: 

I can see the same error for the 4.2.0-rc1 on Windows. This error was probably introduced with changeset 2aac9ec7df29 from bug #48669 (and patch #8943) which moved the fist call of "get_maxlight" until after the window was created to resolve issues with fltk.

It looks like qt tries to add the light before the window was opened which results in the behavior you describe.

When you get lights to work once (e.g. by calling "demo light 1"). It will work correctly until the end of the session.

I am not familiar enough with fltk to judge how this "dilemma" can be resolved. CC'ing Dan Sebald who I believe a much better expert.

Markus Mützel <mmuetzel>
Project Member
Tue 13 Sep 2016 08:57:20 PM UTC, comment #1: 

correction:

>> demo camlight
camlight example 1:
## Adding lights to a scene
sphere (64);
camlight

## Add a second light
camlight left

title ({"camlight()", "lights are left and right"});

Press <enter> to continue: warning: light: Maximum number of lights (0) in these axes is exceeded.

It works fine with fltk.

Avinoam Kalma <avinoam>
Project Member
Tue 13 Sep 2016 08:55:32 PM UTC, original submission:  
Avinoam Kalma <avinoam>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by mmuetzel
  • -email is unavailable- added by avinoam (Submitted the item)
  • -email is unavailable- added by avinoam
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-09-15 rik5 StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2016-09-15 mmuetzel Attached File- => Added bug45542_GL_MULTISAMPLE.patch, #38514
    2016-09-14 rik5 StatusNone => Confirmed
        Carbon-Copy- => Added mmuetzel
    2016-09-14 mmuetzel Carbon-Copy- => Added sebald
    2016-09-13 avinoam Carbon-Copy- => Added a.kalma@gmail.com

    Back to the top


    Powered by Savane 3.5