/** * Called via ctx->Driver.DrawPixels() */ static void st_DrawPixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels) { void *driver_vp, *driver_fp; struct st_context *st = st_context(ctx); const GLfloat *color; struct pipe_context *pipe = st->pipe; GLboolean write_stencil = GL_FALSE, write_depth = GL_FALSE; struct pipe_sampler_view *sv[2]; int num_sampler_view = 1; enum pipe_format stencil_format = PIPE_FORMAT_NONE; struct st_fp_variant *fpv; if (format == GL_DEPTH_STENCIL) write_stencil = write_depth = GL_TRUE; else if (format == GL_STENCIL_INDEX) write_stencil = GL_TRUE; else if (format == GL_DEPTH_COMPONENT) write_depth = GL_TRUE; if (write_stencil) { enum pipe_format tex_format; /* can we write to stencil if not fallback */ if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) goto stencil_fallback; tex_format = st_choose_format(st->pipe->screen, base_format(format), GL_NONE, GL_NONE, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW); if (tex_format == PIPE_FORMAT_Z24_UNORM_S8_USCALED) stencil_format = PIPE_FORMAT_X24S8_USCALED; else if (tex_format == PIPE_FORMAT_S8_USCALED_Z24_UNORM) stencil_format = PIPE_FORMAT_S8X24_USCALED; else stencil_format = PIPE_FORMAT_S8_USCALED; if (stencil_format == PIPE_FORMAT_NONE) goto stencil_fallback; } /* Mesa state should be up to date by now */ assert(ctx->NewState == 0x0); st_validate_state(st); /* * Get vertex/fragment shaders */ if (write_depth || write_stencil) { fpv = get_depth_stencil_fp_variant(st, write_depth, write_stencil); driver_fp = fpv->driver_shader; driver_vp = make_passthrough_vertex_shader(st, GL_TRUE); color = ctx->Current.RasterColor; } else { fpv = get_color_fp_variant(st); driver_fp = fpv->driver_shader; driver_vp = make_passthrough_vertex_shader(st, GL_FALSE); color = NULL; if (st->pixel_xfer.pixelmap_enabled) { sv[1] = st->pixel_xfer.pixelmap_sampler_view; num_sampler_view++; } } /* update fragment program constants */ st_upload_constants(st, fpv->parameters, PIPE_SHADER_FRAGMENT); /* draw with textured quad */ { struct pipe_resource *pt = make_texture(st, width, height, format, type, unpack, pixels); if (pt) { sv[0] = st_create_texture_sampler_view(st->pipe, pt); if (sv[0]) { if (write_stencil) { sv[1] = st_create_texture_sampler_view_format(st->pipe, pt, stencil_format); num_sampler_view++; } draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2], width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY, sv, num_sampler_view, driver_vp, driver_fp, color, GL_FALSE, write_depth, write_stencil); pipe_sampler_view_reference(&sv[0], NULL); if (num_sampler_view > 1) pipe_sampler_view_reference(&sv[1], NULL); } pipe_resource_reference(&pt, NULL); } } return; stencil_fallback: draw_stencil_pixels(ctx, x, y, width, height, format, type, unpack, pixels); }
earth_planet::earth_planet(int segments, std::string target, const double &ctol) : base(base_format(1,segments,1000).size(), 0, 1, 6 + segments + 1 +1, segments+2,ctol), encoding(1,segments,1000), vmax(3000),n_segments(segments) { std::vector<double> lb_v(get_dimension()); std::vector<double> ub_v(get_dimension()); //Start lb_v[encoding.leg_start_epoch_i(0)[0]] = 0; ub_v[encoding.leg_start_epoch_i(0)[0]] = 1000; //End lb_v[encoding.leg_end_epoch_i(0)[0]] = 500; ub_v[encoding.leg_end_epoch_i(0)[0]] = 1500; //Start Velocity std::vector<int> tmp = encoding.leg_start_velocity_i(0); for (std::vector<int>::size_type i = 0; i < tmp.size() ; ++i) { lb_v[tmp[i]] = -3; ub_v[tmp[i]] = 3; } //End Velocity tmp = encoding.leg_end_velocity_i(0); for (std::vector<int>::size_type i = 0; i < tmp.size() ; ++i) { lb_v[tmp[i]] = 0; ub_v[tmp[i]] = 0; } //I Throttles for (int j = 0; j<encoding.n_segments(0); ++j) { tmp = encoding.segment_thrust_i(0,j); for (std::vector<int>::size_type i = 0; i < tmp.size() ; ++i) { lb_v[tmp[i]] = -1; ub_v[tmp[i]] = 1; } } set_bounds(lb_v,ub_v); //traj_fb constructor std::vector<planet_ptr> sequence; sequence.push_back(planet_ptr(new planet_ss("earth"))); sequence.push_back(planet_ptr(new planet_ss(target))); trajectory = fb_traj(sequence,segments,1000,0.05,boost::numeric::bounds<double>::highest()); }