With NoCreate it's even simpler (actually, you *might* get some leaks when using placement-new like that), just move-construct a new instance:
GL::Buffer buffer{NoCreate}; // this is a placeholder
buffer = GL::Buffer{}; // this is a live instance now
The same is possible with Platform::GLContext, but for implementation reasons there it's not move-constructible and you have to call create() on the instance instead. Some more info about these tags is here:
http://blog.magnum.graphics/announcements/2018.02/#full-control-over-initialization-and-ownership
Yes, MeshTools::compile() is more for "oh i have to load a generic model which might contain just anything" cases, you get all of the genericity yet none of the control.
Over the years this project turned from a "spare time side-project" to a thing that I can actually make my living with. Working on it full-time now.
Cheers
> Datum: 15.06.2018 01:49
> Předmět: Re: [magnum] Primitives example with magnum+Qt
>
>Attached the new working version in case you want to use it in anyway.
>
>Ok. Let me go step by step with the changes and my comments:
>- Using NoCreate instead of Optional works perfect (very nice trick, I love
>C++). It took me a while to understand how to do And now I understand what
>you meant with "placeholder". I'm instantiating a new object, calling the
>constructor but passing the pointer to the class member (it´s brilliant) so
>the createImplementation function is called. (i.e. new (&_vertexBuffer) GL::
>Buffer{};)
>- The shader was not leaking, there was a delete on the Viewer destructor
>;-). Now it´s gone as it´s not needed anymore.
>- Regarding compile vs interleave/combine, I think compile is really useful
>for getting quick results but, in my case, I want full control on buffers
>so I prefer to play more the second approach.
>- translation (the one with the sign flipped, damn, what a silly one) moved
>from projection to transformation. Makes more sense to me :)
>- projection matrix updated and passed to the shader on resizeGL: it works
>perfect now. resizeGL looks like this now
>
>void Viewer::resizeGL(int w, int h) {
>
> _framebuffer = GL::Framebuffer::wrap(defaultFramebufferObject(), {{}, {w, h}});
>
> _shader->setProjectionMatrix( Matrix4::perspectiveProjection(35.0_degf, static_cast<float>(w)/h, 0.01f, 100.0f) );
>
>}
>
>
>I think that's all by now. Next step is to use the SceneGraph to control
>the camera and then straight to the picking. I´ll let you know.
>
>Thanks a lot for your help and congratulations for this really impressive
>library.
>Please, don't tell me you have done all this in your spare time.
>
>Best regards,
>Alex
>
>
>
>
>
>
>
>
>
>On Thursday, 14 June 2018 20:14:35 UTC+1, mosra wrote:
>>
>> > Od: Vladimír Vondruš <
mo...@centrum.cz <javascript:>>
>> > Komu: Alex Moreno <
amore...@gmail.com <javascript:>>, Magnum C++/OpenGL
>> Graphics Engine <
magnum...@googlegroups.com <javascript:>>
>> > Datum: 14.06.2018 20:00
>> > Předmět: Re: [magnum] Primitives example with magnum+Qt
>> >
>> >Hi,
>> >
>> >took me a while, because while trying to get this to work, I apparently
>> uncovered a strange crash bug in the Mesa driver involving
>> GL::Framebuffer::clearDepth(). Oh well.
>> >
>> >Your problem boils down to the following: compared to the Primitives
>> example in Magnum, you move your object the other direction, which puts it
>> effectively behind the camera. If I change the translation back to
>> Vector3::zAxis(-10.0f), it draws the object correctly.
>> >
>> >(In case you are also on Mesa, the clearDepth()/clearColor() functions
>> don't seem to work correctly on the default framebuffer, causing the object
>> to not be shown and crashing in some rare occasions as well. I will look
>> into this, in the meantime you can work around that by using the (older)
>> GL::*Framebuffer::clear() functionality.)
>> >
>> >Cheers!
>> >mosra
>> >
>> >______________________________________________________________
>> >> Od: Alex Moreno <
amore...@gmail.com <javascript:>>
>> <javascript:>>
>> an email to
magnum-engin...@googlegroups.com <javascript:>.
>> <javascript:>.
>> email to
magnum-engin...@googlegroups.com <javascript:>.
>> <javascript:>.