Commit Graph

81 Commits

Author SHA1 Message Date
Emmanuele Bassi
fae3eaffcd glarea: Check that the context is not NULL
The public API should perform more checks when it comes to an NULL
context.

https://bugzilla.gnome.org/show_bug.cgi?id=746746
2015-03-25 15:19:30 +00:00
Matthias Clasen
0ddb5d729c More documentation fixes 2015-03-13 23:24:53 -04:00
Emmanuele Bassi
0a4879b9ac glarea: Better error handling
Currently, GtkGLArea will leak GError instances set during the context
creation, if an error is set.

If any error is set post-context creation, it should be displayed even
in the case a GL context exists; for instance, we can use the error
display facility for shader compilation errors.
2015-02-17 10:21:41 +00:00
Matthias Clasen
f8961facb2 Improve two strings
Make two property blurbs better.

https://bugzilla.gnome.org/show_bug.cgi?id=744574
2015-02-15 19:55:54 -05:00
Emmanuele Bassi
5a6264ef5d docs: Fix "shadres" → "shaders" typo
https://bugzilla.gnome.org/show_bug.cgi?id=744394
2015-02-15 11:23:30 +00:00
Emmanuele Bassi
d066e7541e Remove GdkGLProfile
The existence of OpenGL implementations that do not provide the full
core profile compatibility because of reasons beyond the technical, like
llvmpipe not implementing floating point buffers, makes the existence of
GdkGLProfile and documenting the fact that we use core profiles a bit
harder.

Since we do not have any existing profile except the default, we can
remove the GdkGLProfile and its related API from GDK and GTK+, and sweep
the whole thing under the carpet, while we wait for an extension that
lets us ask for the most compatible profile possible.

https://bugzilla.gnome.org/show_bug.cgi?id=744407
2015-02-12 17:51:31 +00:00
Emmanuele Bassi
c372f95a41 glarea: Add accessors for the required GL version
Specifying the version of OpenGL is enough of a common operation that it
should not require overriding the creation of the GdkGLContext.
2015-02-12 13:25:12 +00:00
Emmanuele Bassi
ec112a772b glarea: Update documentation
Drop the fixed pipeline example code.

https://bugzilla.gnome.org/show_bug.cgi?id=744394
2015-02-12 13:19:21 +00:00
Emmanuele Bassi
022724aa69 gl: Drop profile for gdk_window_create_gl_context()
Now that we have a two-stages GL context creation sequence, we can move
the profile to a pre-realize option, like the debug and forward
compatibility bits, or the GL version to use.
2015-02-12 12:34:28 +00:00
Emmanuele Bassi
5a3b28aaf1 glarea: Do not use extension API
We are using GL contexts with Core GL profiles, so we need to use the
proper API, not the one provided by extensions.

https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-02-09 19:10:30 +00:00
Emmanuele Bassi
22e6f37c9c GL: Split GL context creation in two phases
One of the major requests by OpenGL users has been the ability to
specify settings when creating a GL context, like the version to use
or whether the debug support should be enabled.

We have a couple of requirements in terms of API:

 • avoid, if at all possible, the "C arrays of integers with
   attribute, value pairs", which are hard to write and hard
   to bind in non-C languages.
 • allow failing in a recoverable way.
 • do not make the GL context creation API a mess of arguments.

Looking at prior art, it seems that a common pattern is to split the
construction phase in two:

 • a first phase that creates a GL context wrapper object and
   does preliminary checks on the environment.
 • a second phase that creates the backend-specific GL object.

We adopted a similar pattern:

 • gdk_window_create_gl_context() creates a GdkGLContext
 • gdk_gl_context_realize() creates the underlying resources

Calling gdk_gl_context_make_current() also realizes the context, so
simple GL users do not need to care. Advanced users will want to
call gdk_window_create_gl_context(), set up the optional requirements,
and then call gdk_gl_context_realize(). If either of these two steps
fails, it's possible to recover by changing the requirements, or simply
creating a new GdkGLContext instance.

https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-02-09 19:10:04 +00:00
Benjamin Otte
3575df8ee2 glarea: Remove useless function
The function should have been gone in
27cf0fa34c
2015-01-31 01:55:04 +01:00
Niels Nesse
27cf0fa34c Fix core context creation in GdkGLContext
- Specifically request GL version when creating context. Just specifying core
profile bit results in the requested version defaulting to 1.0 which causes
the core profile bit to be ignored and an arbitrary compatability context to be
returned.

- Fix GL painting by removing GL calls that have been depricated by the 3.2 core
profile.

- Additionally remove glInvalidateFramebuffer() call, it is not supported by 3.2
core.

https://bugzilla.gnome.org/show_bug.cgi?id=742953
2015-01-28 12:00:30 +00:00
Alexander Larsson
b52a06ac6f GtkGLArea: Handle window scale factor changes
We need to re-allocate the buffers for the new gl size.
2014-12-16 13:27:49 +01:00
Alexander Larsson
08853c7364 GtkGLArea: Only re-allocate buffers during paint
This drops the maybe_allocate_buffers that re-allocates buffers
at any point. Instead we just set have_buffers to FALSE and have
the buffers re-created when needed.

This also makes the buffer creation code imdeponent and makes it
clean up no longer needed buffers in order to handle being called
multiple times due to the above.

We also ensure we re-allocate the buffers when we're resizing
and the buffers are already created.
2014-12-16 13:25:23 +01:00
Matthias Clasen
f95fb6f893 GtkGLArea: avoid extraneous property notifications 2014-11-23 18:30:13 -05:00
Matthias Clasen
72a501fe15 GtkGLArea: Formatting fixes 2014-11-22 21:38:46 -05:00
Alexander Larsson
ef9ac24e95 GtkGLArea: Correctly position/size input window on realize 2014-11-03 13:35:00 +01:00
Alexander Larsson
3656c21030 GtkGLArea: Don't dispose gl context on unrealize
This was done to ensure the context is not current, but this is
pretty broken for shared contexts. We now just make it non-current.
2014-11-03 13:19:40 +01:00
Alexander Larsson
9930e6dcaa GtkGLArea: Add create-context signal
This lets you hook into the GL context creation which is useful
if you want to share one GL context between GtkGLArea widgets.
2014-11-03 10:43:31 +01:00
Alexander Larsson
f66060c422 GdkGLArea: fix has_alpha changes at runtime
We need to completely reallocate the buffers if we switch
has_alpha, because we may switch from render buffers to
texture.
2014-10-30 21:04:29 +01:00
Alexander Larsson
37d0159a84 GtkGLArea: Add resize signal
This is very useful, as almost all GL code wants to recalculate
the cameras each time the window size changes.
2014-10-30 21:04:29 +01:00
Alexander Larsson
969b9c6552 GtkGLArea: Add profile property
This lets you force a core 3.2 context if you want
2014-10-30 21:04:29 +01:00
Alexander Larsson
b519b642bd GtkGLArea: Add INPUT_ONLY window so that we can get events 2014-10-30 21:04:29 +01:00
Alexander Larsson
5ea3a1028d GtkGLArea: Major reworking
This restructures the way buffers are allocated and bound in a way
that is more flexible.

Buffer operation happens in three phases:
create_buffer() - Creates the gl objects
allocate_buffers() - Allocates space for the buffers at a given size
attach_buffers() - Attaches the buffers to the framebuffer and makes
                   the framebuffer the default drawing target
And destroy via
delete_buffers()

We call all these the first draw, and after that we allocate buffers
each time the widget changes size until the buffers are deleted.
We delete the buffers at unrealize.

However, anyone that wants to manually control buffer allocation strategies
can manually call allocate/delete_buffers().

There are also some other changes:
* Support for stencil buffers.
* A manual render mode where ::draw doesn't render unless you manually
  invalidated the previous rendering.
2014-10-30 21:04:29 +01:00
Alexander Larsson
ad30262fef GtkGLArea: Always destroy context on unrealize
We had some code that tried to reuse the context over realize, but
that doesn't work as we need to share with the possibly new
paint context of the re-realized window.
2014-10-30 12:43:03 +01:00
Benjamin Otte
44c8df62f2 glarea: Display the error message when an error occurred
Simply center a PangoLayout with the message text.
2014-10-16 03:33:15 +02:00
Matthias Clasen
e7c16a5e82 Drop a reference to GtkGLArea::create-context
The signal no longer exists.
2014-10-13 10:43:32 -04:00
Matthias Clasen
e5e9d87171 Nitpicky documentation fixes 2014-10-13 10:43:32 -04:00
Alexander Larsson
fdeb4f8c16 gl: Make gdk_gl_context_make_current() return void
Its not really reasonable to handle failures to make_current, it
basically only happens if you pass invalid arguments to it, and
thats not something we trap on similar things on the X drawing side.

If GL is not supported that should be handled by the context creation
failing, and anything going wrong after that is essentially a critical
(or an async X error).
2014-10-13 10:43:32 -04:00
Alexander Larsson
535723ce86 Add GtkGLArea widget 2014-10-13 10:43:31 -04:00