+static gboolean expose(GtkWidget *da, GdkEventExpose *event, gpointer user_data)
+{
+ Sweep *sweep = cur_sweep;
+
+ GdkGLContext *glcontext = gtk_widget_get_gl_context(da);
+ GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(da);
+
+ /* draw in here */
+ glPushMatrix();
+ glRotatef(0, 0, 0, 0);
+
+ /* Draw the rays */
+ glEnable(GL_TEXTURE_2D);
+ glBegin(GL_QUAD_STRIP);
+ int _ri; // not really used, creates strange fragments..
+ for (_ri = 0; _ri < sweep->h.nrays; _ri++) {
+ /* Do the first sweep twice to complete the last Quad */
+ int ri = _ri % sweep->h.nrays;
+ Ray *ray = sweep->ray[ri];
+
+ /* right and left looking out from radar */
+ double left = ((ray->h.azimuth - ((double)ray->h.beam_width/2.))*M_PI)/180.0;
+ double right = ((ray->h.azimuth + ((double)ray->h.beam_width/2.))*M_PI)/180.0;
+
+ double lx = sin(left);
+ double ly = cos(left);
+
+ /* TODO: change this to meters instead of 0..1 */
+ double max_dist = ray->h.nbins*ray->h.gate_size + ray->h.range_bin1;
+ double near_dist = (double)(ray->h.range_bin1) / max_dist;
+ double far_dist = (double)(ray->h.nbins*ray->h.gate_size + ray->h.range_bin1) / max_dist;
+
+ /* (find middle of bin) / scale for opengl */
+ glTexCoord2d(0.0, ((double)ri)/sweep->h.nrays); glVertex3f(lx*near_dist, ly*near_dist, 0.); // near left
+ glTexCoord2d(0.7, ((double)ri)/sweep->h.nrays); glVertex3f(lx*far_dist, ly*far_dist, 0.); // far left
+ }
+ g_printf("ri=%d, nr=%d, bw=%f\n", _ri, sweep->h.nrays, sweep->h.beam_width);