Andy Spencer [Mon, 6 Feb 2012 05:41:44 +0000 (05:41 +0000)]
Rewrite expose to preserve the depth buffer
Sorted objects are now drawn with depth testing enabled. Unsorted
objects are drawn without depth testing. This mostly affects
GRITS_LEVEL_WORD+n objects.
Objects at other levels such as BACKGROUND, OVERLAY, and HUD should
generally disable sorting so that they are always drawn to the screen.
For those levels, the depth-buffer is set to read-only. This preserves
the depth buffer so that it can be used later on to get the world-level
depth at a given screen location.
Andy Spencer [Mon, 30 Jan 2012 07:50:27 +0000 (07:50 +0000)]
Improve rendering of non lat-lon tiles
There have been a long standing bugs related to this..
Up until now the solution was to only use tiles that split along
lat-long lines and to also split the geometry (in roam) along the same
lines.
Hopefully this allows tiles to be rendered properly.
See examples/tex.c for details of how this rendering works.
Andy Spencer [Mon, 30 Jan 2012 07:06:08 +0000 (07:06 +0000)]
Use multi-texturing for alpha masking in tex.c
Multi-texturing uses two textures for each fragment. The example uses
GL_TEXTURE0 as the regular texture color and a second texture as the
alpha mask. Since there are two textures they can have separate
filtering an wrapping parameters.
The color texture uses GL_MODULATE which combines it with the existing
color. The alpha mask uses GL_REPLACE which causes it to replace the
linearly filtered alpha mask from the color texture with a hard-edged
alpha mask that is clamped to transparent at the border.
This is similar to how drawing is done in NASA World Wind
Andy Spencer [Mon, 30 Jan 2012 06:39:15 +0000 (06:39 +0000)]
Use glBlendFuncSeparate for alpha masking in tex.c
The draw happens in two steps:
1. Copy the alpha mask to the framebuffer without changing the color
channels: glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_ONE, GL_ZERO)
This uses GL_LINEAR filtering and GL_CLAMP_TO_BORDER to create a
alpha mask with hard edges as opposed to blurred edges.
2. Copy the texture color to the framebuffer using the alpha mask
stored in the frame buffer as the mask:
glBlendFuncSeparate(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA, GL_ZERO, GL_ZERO);
We can turn on GL_LINEAR filtering and GL_CLAMP here because the
alpha mask is taken from the framebuffer instead of the filtered
alpha component of the texture.
This creates a nice looking image without having to do any fancy setup.
The previous version also has issues if the texture is not split in the
middle of the polygon.
Unfortunately glBlendFuncSeparate depends on OpenGL 2.0 and requires
twice as many draws.
Andy Spencer [Mon, 16 Jan 2012 03:13:00 +0000 (03:13 +0000)]
Add Tile Map Service downloading
This uses map tiles directly from openstreetmap.org. The problem with
this is that those tiles are rendered using a Mercator projections which
is non-linear with respect to latitude. Two things must be done to
properly correct for this:
1. Split tiles at the correct location. With the Mercator projection,
the midpoint of a tile is the midpoint of the longitude but not the
midpoint of the latitude.
Correcting this very important because it prevent tiles from being
drawn in entirely the wrong place.
2. Morph each tile to lat-lon projection when it is drawn. This could
possibly be done with a OpenGL fragment shader.
This noticeable when zoomed out so it's not too bad to just ignore
the issue.. The web based map servers have similar issues with land
area at high-up zoom levels.
Eventually we'll want to fetch the XML and render the maps locally..
Andy Spencer [Sun, 8 Jan 2012 23:06:16 +0000 (23:06 +0000)]
Fix clipping plane issues
The clipping plane is flat, so the distance between the camera and the
clipping plane varies based on where screen location. I.e. it is closest
in the center and farther at the corners. Add a offset to elev to
account of this. It would be better to use a sin or to calculate
distances directly, but this is easy and appears to work.
Andy Spencer [Tue, 3 Jan 2012 07:32:34 +0000 (07:32 +0000)]
Add GritsLine
GritsLine is similar to GritsPoly, but does not draw a filled polygon.
As such it does not need to do any tessellation.
Currently it draws the points directly instead of using a display list.
This should make it easier to updated the line at runtime without
needing to create a new object.
Andy Spencer [Mon, 12 Dec 2011 05:37:20 +0000 (05:37 +0000)]
Move OpenGL includes to a common place
Apple seems to think the should put GL.h in OpenGL instead of GL..
putting it all gtkgl.h makes it a little easier, but requires gtkgl.h to
be included in the install and by grits.h.
Andy Spencer [Sat, 15 Oct 2011 06:20:43 +0000 (06:20 +0000)]
Add mouse, keyboard, and motion events to GritsObject
These work by chaining the event from GritsOpenGL up to each individual
object, which then emits the callback if it is currently selected
(moused over).
Andy Spencer [Sat, 15 Oct 2011 06:13:39 +0000 (06:13 +0000)]
Add mouse enter/leave signals to objects
This uses the OpenGL Selection render mode to determine which objects
the mouse is over. It requires fairly tight integration between
GritsOpenGL and GritsObject.
The signal code is handled internally by GritsObject. However, most of
the actual selection matching work is done by GritsOpenGL.
Object types that wish to improve performance can implement the pick()
function in addition to the draw() function. The pick function is used
when performing selection matching. It works similar to draw, but does
not need to do textures/lighting/opacity/etc.
Andy Spencer [Sat, 18 Jun 2011 22:10:17 +0000 (22:10 +0000)]
Change binaries to shared objects
There's a double load of the GObjects when using static libraries with
plugins. Shared libraries avoid this, I think there are other work
arounds that let static binaries work too, but this should be fine for
now.
Andy Spencer [Tue, 7 Jun 2011 08:43:32 +0000 (08:43 +0000)]
Switch from GtkGLExt to internal OpenGL handling
GtkGLExt has many problems:
- It's code is bloated and convoluted
- It doesn't work on Win32
- It doesn't work with gtk+-3.0
- The last release was in early 2006
Using our own lets us fix these issues and should be easier to maintain
than trying to figure out the GtkGLExt mess, or waiting for someone else
to fix it.
Andy Spencer [Mon, 24 Jan 2011 03:33:30 +0000 (03:33 +0000)]
Add GritsTester for debugging GritsObjects
The "tester" object is similar to a stripped down version of
GisOpenGL/GisViewer. It is intended for debugging GisObjects during
development. It displays one or more objects centered in the view and
and supports panning/moving around to inspect various parts of the
object.
Andy Spencer [Sat, 22 Jan 2011 20:13:05 +0000 (20:13 +0000)]
Allow disabling operations in grits_object_draw
Objects now include a GRITS_SKIP_* bitmask used for disabling various
operations in grits_object_draw. The default is to perform all tests and
operations, however some of these are expensive. Objects which do not
need some operations or take care of it themselves can disable the tests
in grits_object_draw to save processing time.
For instance, saving the OpenGL state can be quite costly for simple
objects.