← Back to team overview

kicad-developers team mailing list archive

Re: mode openGL issues after latest updates

 

On 05/04/2016 10:09 AM, Mário Luzeiro wrote:
> Hi Orson,
> 
> I understand, but my question was, since that check is inside the "BeginUpdate" I am supposing that you will do in any case every time that redraw update: i.e in this case you will call GL functions and in the worst case when the windows is not displayed and you have no context.
> 
> For comparison (what I mean is) on 3d-viewer on the function redraw:
> https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L294
> 
> void EDA_3D_CANVAS::Redraw()
> {
>     // SwapBuffer requires the window to be shown before calling
>     if( !IsShownOnScreen() )
>         return;
> 
> it will return immediately and will not continue to call any oGL functions.
> 
> Looking on overall on your source code you have different points of return related with IsShownOnScreen
> So is this condition guarantee on this case?

I would say so. There is a similar code snippet in OPENGL_TEST
(opengl_gal.cpp:1484) and because OPENGL_TEST is always run in the
beginning, it assures there is an OpenGL context bound. The last patch I
have added was to address the problem of switching between different
OpenGL contexts. This is the current initialization sequence:

1. Launch pcbnew
- No window
- No OpenGL context bound

2. Create EDA_DRAW_PANEL_GAL
- No window
- OpenGL context is created, but not bound yet

3. Run OPENGL_TEST
- Creates a window
- Waits until it appears on the screen (opengl_gal.cpp:1484)
- *Bounds the previously created OpenGL context* (now we can call OpenGL
functions, and they will work on the GAL canvas OpenGL context)
- Performs capabilities test

4. Display proper OpenGL canvas
- OpenGL context is already bound, but in case another window has
rebound it: call SetCurrent() to be sure the right context is bound

5. Loop: update vertices, redraw
- Context is bound, but it might have been rebound by another window (3D
footprint viewer, 3D board viewer, etc.), so call SetCurrent() to be
sure OpenGL calls are going to work with the right context.

Most of the time the OpenGL canvas is shown, therefore SetCurrent() will
be called. The only moment when the canvas is not shown is during the
pcbnew initialization, but this case is handled by OPENGL_TEST.

Regards,
Orson

> Mario
> ________________________________________
> From: Maciej Sumiński [maciej.suminski@xxxxxxx]
> Sent: 04 May 2016 08:57
> To: Mário Luzeiro; kicad-developers@xxxxxxxxxxxxxxxxxxx
> Subject: Re: mode openGL issues after latest updates
> 
> Hi Mario,
> 
> wxWidgets will trigger an assert in Linux if you try to set OpenGL
> context when the parent window is not yet visible. It may happen only
> when a window is created upon pcbnew launch, but anyway it is enough to
> require such condition there. It is also necessary to set the right
> context if there are multiple contexts available, that is why I have
> added the two lines you asked about.
> 
> Earlier, OpenGL context is bound by the OpenGL test window (that detects
> capabilities), hence all subsequent OGL calls are called using the right
> context.
> 
> Regards,
> Orson
> 
> On 05/03/2016 05:48 PM, Mário Luzeiro wrote:
>> Hi Orson,
>>
>> I tested your new change, still working but I was wondering:
>>
>> void OPENGL_GAL::BeginUpdate()
>> {
>>     if( IsShownOnScreen() )
>>         SetCurrent( *OPENGL_GAL::glContext );
>>
>> On this case shouldn't you not allow the begin of the update at all? (As you will not be able to render it)... but I dont know exactly how it is supposed to work.
>>
>> Regards,
>> Mario
>>
>> ________________________________________
>> From: Kicad-developers [kicad-developers-bounces+mrluzeiro=ua.pt@xxxxxxxxxxxxxxxxxxx] on behalf of Mário Luzeiro [mrluzeiro@xxxxx]
>> Sent: 03 May 2016 15:27
>> To: Maciej Sumiński; kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Subject: Re: [Kicad-developers] mode openGL issues after latest updates
>>
>> I tested (on Windows) and it works!
>> I didn't feel any issues.
>> Thanks,
>> Mario
>> ________________________________________
>> From: Maciej Sumiński [maciej.suminski@xxxxxxx]
>> Sent: 03 May 2016 15:20
>> To: Mário Luzeiro; kicad-developers@xxxxxxxxxxxxxxxxxxx
>> Subject: Re: mode openGL issues after latest updates
>>
>> On 05/03/2016 12:06 PM, Mário Luzeiro wrote:
>>> Hi Orson,
>>> I tested the new updates on my branch code, and now on Windows I got this issues after I close the 3d-viewer windows:
>>>
>>> Error: mapping vertices buffer: invalid operation
>>> Error: unmapping vertices buffer: invalid operation
>>> Error: unbinding vertices buffer:  invalid operation
>>>
>>> My guess is that it may be related with oGL context? :S
>>>
>>> https://code.launchpad.net/~mrluzeiro/kicad/kicad_new3d-viewer
>>>
>>> On Linux it works fine.
>>>
>>> Any ideas?
>>> Regards,
>>> Mario Luzeiro
>>
>> Hi Mario,
>>
>> Thank you for the report. You are right, it was due to invalid OpenGL
>> context. I was able to recreate the problem on Linux and it should be
>> fixed now (revision 6769).
>>
>> Regards,
>> Orson
>>
> 
> 


Attachment: signature.asc
Description: OpenPGP digital signature


References