您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ write_ppm函数代码示例

51自学网 2021-06-03 10:06:34
  C++
这篇教程C++ write_ppm函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中write_ppm函数的典型用法代码示例。如果您正苦于以下问题:C++ write_ppm函数的具体用法?C++ write_ppm怎么用?C++ write_ppm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了write_ppm函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int main(){    //--------------------    // Allocate the buffer.    // Clear the buffer, for now "manually"    // Create the rendering buffer object    // Create the Pixel Format renderer    // Do something simple, draw a diagonal line    // Write the buffer to agg_test.ppm    // Free memory    unsigned char* buffer = new unsigned char[frame_width * frame_height * 3];    memset(buffer, 255, frame_width * frame_height * 3);    agg::rendering_buffer rbuf(buffer,                                frame_width,                                frame_height,                                frame_width * 3);    agg::pixfmt_rgb24 pixf(rbuf);    unsigned i;    for(i = 0; i < pixf.height()/2; ++i)    {        pixf.copy_pixel(i, i, agg::rgba8(127, 200, 98));    }    draw_black_frame(pixf);    write_ppm(buffer, frame_width, frame_height, "agg_test.ppm");    delete [] buffer;    return 0;}
开发者ID:weimingtom,项目名称:graphin,代码行数:34,


示例2: main

int main(int argc, char** argv) {    if (argc != 2) {        std::cerr << "Error: wrong number of argument:" << std::endl            << "usage: ./shiny-tracer scene.sce" << std::endl;        return 1;    }    Scene scene;    parser(argv[1], scene);    // DEBUG    std::cout << scene.nbObjects() << " objects and " << scene.nbLights() << " lights" << std::endl;    int width = scene.getCam().getWidth();    int height = scene.getCam().getHeight();    std::vector<Color> screen;    scene.computeImage(screen);    std::string filename(argv[1]);    size_t pos = filename.find(".sce");    filename = filename.substr(0, pos);    filename.append(".ppm");    write_ppm(filename.c_str(), screen, width, height);    return 0;}
开发者ID:bara3r,项目名称:shiny-archer,代码行数:27,


示例3: main

int main (int argc, char * argv[]){    char * path = "/Users/neo_cupid/Desktop/18645/final_proj/data-2/1/input0.ppm";    char * path_csv = "/Users/neo_cupid/Desktop/18645/final_proj/data-2/1/input1.csv";    char * path_out = "/Users/neo_cupid/Desktop/18645/final_proj/data-2/1/outTest.ppm";    clock_t begin, end;    double time_spent;        begin = clock();        PPM_IMG img = read_ppm (path);    PPM_IMG output;    output.h = img.h;    output.w = img.w;    output.data = (unsigned char *)malloc(3 * img.w * img.h * sizeof(unsigned char));    float mask[25];    read_csv(path_csv, mask);    convolution(CHANNELS, img.w, img.h, mask, img, &output);    write_ppm(output, path_out);    free (output.data);    free(img.data);    end = clock();    time_spent = (double)(end - begin) / CLOCKS_PER_SEC;    printf("execution time: %lf./n",time_spent);    return 0;    }
开发者ID:jlin705,项目名称:18645,代码行数:26,


示例4: files_video

static intfiles_video(void *handle, struct ng_video_buf *buf){    struct files_handle *h = handle;    int rc = -1;    FILE *fp;    if (h->gotcha) {	fprintf(stderr,"Oops: can't count up file names any more/n");	return -1;    }        switch (h->video.fmtid) {    case VIDEO_RGB24:	rc = write_ppm(h->file, buf);	break;    case VIDEO_GRAY:	rc = write_pgm(h->file, buf);	break;    case VIDEO_JPEG:	if (NULL == (fp = fopen(h->file,"w"))) {	    fprintf(stderr,"grab: can't open %s: %s/n",h->file,strerror(errno));	    rc = -1;	} else {	    fwrite(buf->data,buf->size,1,fp);	    fclose(fp);	    rc = 0;	}    }    if (1 != patch_up(h->file))	h->gotcha = 1;    return rc;}
开发者ID:Kjir,项目名称:amsn,代码行数:33,


示例5: write_image

void write_image(char *file_name, int render_fmt, VInfo *ji, uint8_t *buf) {  FILE *x;  if ((x = open_outfile(file_name))) {    switch (render_fmt) {      case FMT_JPG:	if (write_jpeg(ji, buf, JPEG_QUALITY, x))	  dlog(LOG_ERR, "IMF: Could not write jpeg: %s/n", file_name);	break;      case FMT_PNG:	if (write_png(ji, buf, x))	  dlog(LOG_ERR, "IMF: Could not write png: %s/n", file_name);	break;      case FMT_PPM:	if (write_ppm(ji, buf, x))	  dlog(LOG_ERR, "IMF: Could not write ppm: %s/n", file_name);	break;      default:	dlog(LOG_ERR, "IMF: Unknown outformat %d/n", render_fmt);	break;    }    if (strcmp(file_name, "-")) fclose(x);    dlog(LOG_INFO, "IMF: Outputfile %s closed/n", file_name);  }  else    dlog(LOG_ERR, "IMF: Could not open outfile: %s/n", file_name);  return;}
开发者ID:UIKit0,项目名称:harvid,代码行数:27,


示例6: vips__ppm_save

intvips__ppm_save( VipsImage *in, const char *filename, gboolean ascii ){	Write *write;	if( vips_check_uintorf( "vips2ppm", in ) || 		vips_check_bands_1or3( "vips2ppm", in ) || 		vips_check_uncoded( "vips2ppm", in ) || 		vips_image_pio_input( in ) )		return( -1 );	/* We can only write >8 bit binary images in float.	 */	if( vips_format_sizeof( in->BandFmt ) > 1 && 		!ascii && 		in->BandFmt != VIPS_FORMAT_FLOAT ) {		vips_error( "vips2ppm", 			"%s", _( "binary >8 bit images must be float" ) );		return( -1 );	}	if( !(write = write_new( in, filename )) )		return( -1 );	if( write_ppm( write, ascii ) ) {		write_destroy( write );		return( -1 );	}	write_destroy( write );	return( 0 );}
开发者ID:FlavioFalcao,项目名称:libvips,代码行数:32,


示例7: free_context

void free_context(){   write_ppm("a.ppm", buffer, Width, Height);   printf("all done/n");   free( buffer );   OSMesaDestroyContext( ctx );}
开发者ID:certik,项目名称:osmesa,代码行数:10,


示例8: main

int main(){  image_t *img = read_ppm("example.ppm");  if (!img)    return EXIT_FAILURE;  for (size_t i = 0; i<img->width*img->height; ++i)  {    img->red_buffer[i] = 255-img->green_buffer[i];  }  write_ppm("example-out.ppm", img);  return EXIT_SUCCESS;}
开发者ID:hpc12,项目名称:hw3-ppm,代码行数:12,


示例9: ps_convert

static const char *ps_convert (char **argv, int fd){    const char *err;    cairo_surface_t *surface = NULL; /* silence compiler warning */    err = _spectre_render_page (argv[0], argv[1], &surface);    if (err != NULL)	return err;    err = write_ppm (surface, fd);    cairo_surface_destroy (surface);    return err;}
开发者ID:Ashod,项目名称:WinCairoRequirements,代码行数:15,


示例10: main

int main() {  unsigned char buf[WIDTH*HEIGHT*3];  char *filename_in;  char *filename_out;  filename_in = "testdata/pixbuff_7.ppm";  filename_out = "testdata/blurtest.ppm";  read_ppm(buf, filename_in);  printf("These two sequences of numbers should be different./n");  printf("%d %d %d/n", buf[12], buf[13], buf[14]);  gauss_blur(buf);  printf("%d %d %d/n", buf[12], buf[13], buf[14]);  write_ppm(buf, filename_out);  printf("Confirm that the image testdata/blurtest.ppm is a blurred copy of image testdata/pixbuff_7.ppm/n");  return 0;}
开发者ID:andrewdyates,项目名称:ARDrone,代码行数:15,


示例11: main

int main(int argc, char** argv){    int grid_size_x;    int grid_size_y;    int max_iter;    float xmin;    float xmax;    float ymin;    float ymax;    int **image;    int rank;//initialise a fn pointer    in_set_fn_t fp;     MPI_Comm comm;    comm = MPI_COMM_WORLD;    MPI_Init(&argc, & argv);    MPI_Comm_rank(comm, &rank);     read_options(argc, argv, &grid_size_x, &grid_size_y, &max_iter,                 &xmin, &xmax, &ymin, &ymax);    if(0 == rank)    {      initialise_image(&image, grid_size_x, grid_size_y);    }//set it to either julia or mandelbrot calculation    fp = &point_in_julia;      compute_set(fp, image, xmin, xmax, ymin, ymax, grid_size_x, grid_size_y, max_iter, comm);    if(0 == rank)    {      write_ppm("output.ppm", image, grid_size_x, grid_size_y, max_iter);      free(image);    }    MPI_Finalize();    return 0;}
开发者ID:bluefeet32,项目名称:PDP,代码行数:44,


示例12: DisplayNoDrawDoTest

static void DisplayNoDrawDoTest(void){    for (global_iteration = 0; global_iteration < global_num_proc;         global_iteration++) {        IceTImage image;        IceTUByte *color_buffer;        printf("Blank image is rank %d/n", global_iteration);        image = icetGLDrawFrame();        swap_buffers();        if (   (global_rank == 0)            && (global_num_proc > 1)          /* This last case covers when there is only 2 processes,           * the root, as always, is not drawing anything and the           * other process is drawing the clear screen. */            && ((global_num_proc > 2) || (global_iteration != 1)) ) {            int p;            int bad_count = 0;            printf("Checking pixels./n");            color_buffer = icetImageGetColorub(image);            for (p = 0;                 (p < SCREEN_WIDTH*SCREEN_HEIGHT*4) && (bad_count < 10); p++) {                if (color_buffer[p] != 255) {                    printf("BAD PIXEL %d.%d/n", p/4, p%4);                    printf("    Expected 255, got %d/n", color_buffer[p]);                    bad_count++;                }            }            if (bad_count >= 10) {                char filename[256];                global_result = TEST_FAILED;                sprintf(filename, "DisplayNoDraw_%s_%s_%d.ppm",                        icetGetStrategyName(), icetGetSingleImageStrategyName(),                        global_iteration);                write_ppm(filename, color_buffer,                          (int)SCREEN_WIDTH, (int)SCREEN_HEIGHT);                break;            }        }    }}
开发者ID:gzt200361,项目名称:ThirdParty-2.0.0,代码行数:44,


示例13: main

int main(){    //--------------------    // Allocate the buffer.    // Clear the buffer, for now "manually"    // Create the rendering buffer object    // Create the Pixel Format renderer    // Create one line (span) of type rgba8.    // Fill the buffer using blend_color_span    // Write the buffer to agg_test.ppm    // Free memory    unsigned char* buffer = new unsigned char[frame_width * frame_height * 3];    memset(buffer, 255, frame_width * frame_height * 3);    agg::rendering_buffer rbuf(buffer,                                frame_width,                                frame_height,                                frame_width * 3);    agg::pixfmt_rgb24 pixf(rbuf);    agg::rgba8 span[frame_width];    unsigned i;    for(i = 0; i < frame_width; ++i)    {        agg::rgba c(380.0 + 400.0 * i / frame_width, 0.8);        span[i] = agg::rgba8(c);    }    for(i = 0; i < frame_height; ++i)    {        pixf.blend_color_hspan(0, i, frame_width, span, 0, 255);    }    write_ppm(buffer, frame_width, frame_height, "agg_test.ppm");    delete [] buffer;    return 0;}
开发者ID:emuikernel,项目名称:BaijieCppUILib,代码行数:43,


示例14: write_thumb

void write_thumb(libraw_processed_image_t *img, const char *basename){    if(!img) return;    if(img->type == LIBRAW_IMAGE_BITMAP)        {            char fnt[1024];            snprintf(fnt,1024,"%s.thumb",basename);            write_ppm(img,fnt);        }    else if (img->type == LIBRAW_IMAGE_JPEG)        {            char fn[1024];            snprintf(fn,1024,"%s.thumb.jpg",basename);            FILE *f = fopen(fn,"wb");            if(!f) return;            fwrite(img->data,img->data_size,1,f);            fclose(f);        }}
开发者ID:KingBing,项目名称:LibRaw,代码行数:20,


示例15: run_cpu_color_test

void run_cpu_color_test(PPM_IMG img_in){    StopWatchInterface *timer=NULL;    printf("Starting CPU processing.../n");    sdkCreateTimer(&timer);    sdkStartTimer(&timer);    img_obuf_yuv_cpu = rgb2yuv(img_in); //Start RGB 2 YUV    sdkStopTimer(&timer);    printf("RGB to YUV conversion time: %f (ms)/n", sdkGetTimerValue(&timer));    sdkDeleteTimer(&timer);    sdkCreateTimer(&timer);    sdkStartTimer(&timer);    img_obuf_rgb_cpu = yuv2rgb(img_obuf_yuv_cpu); //Start YUV 2 RGB    sdkStopTimer(&timer);    printf("YUV to RGB conversion time: %f (ms)/n", sdkGetTimerValue(&timer));    sdkDeleteTimer(&timer);        write_yuv(img_obuf_yuv_cpu, "out_yuv.yuv");    write_ppm(img_obuf_rgb_cpu, "out_rgb.ppm");}
开发者ID:YansongZang,项目名称:cmpt-886,代码行数:22,


示例16: main

int main(int argc, char **argv){	unsigned int width = 640;	unsigned int height = 480;    unsigned char pixelsize = 0;    AGG_PIX_TYPE *msvc6_dummy = NULL;    switch (kiva::agg_pix_to_kiva(msvc6_dummy))    {        case (kiva::pix_format_gray8) : pixelsize = 1; break;        case (kiva::pix_format_rgb24) :        case (kiva::pix_format_bgr24) : pixelsize = 3; break;        case (kiva::pix_format_bgra32):        case (kiva::pix_format_rgba32):        case (kiva::pix_format_argb32):        case (kiva::pix_format_abgr32): pixelsize = 4; break;    }    unsigned char *buf = new unsigned char[width * height * pixelsize];    	GC_TYPE gc((unsigned char*)buf, width, height, -width * pixelsize);    gc.clear();    //brandon_draw_test(gc);    //gc_stress_test();    //test_handling_text(gc);    test_clip_stack(gc);    //test_arc_curve(gc);    //test_arc_to(gc);    //test_clip_stack(gc);    if (!write_ppm(buf, width, height, "dummy.ppm"))	{		printf("/nError writing file./n");	}    delete[] buf;    return 0;}
开发者ID:GaZ3ll3,项目名称:enable,代码行数:39,


示例17: main

int main(int argc, char** argv){    int grid_size_x;    int grid_size_y;    int max_iter;    float xmin;    float xmax;    float ymin;    float ymax;    int **image;    int rank;    MPI_Comm comm;    comm = MPI_COMM_WORLD;    MPI_Init(&argc, & argv);    MPI_Comm_rank(comm, &rank);     read_options(argc, argv, &grid_size_x, &grid_size_y, &max_iter,                 &xmin, &xmax, &ymin, &ymax);    if(0 == rank)    {      initialise_image(&image, grid_size_x, grid_size_y);    }    compute_mandelbrot_set(image, xmin, xmax, ymin, ymax,                           grid_size_x, grid_size_y, max_iter, comm);    if(0 == rank)    {      write_ppm("output.ppm", image, grid_size_x, grid_size_y, max_iter);      free(image);    }    MPI_Finalize();    return 0;}
开发者ID:bluefeet32,项目名称:PDP,代码行数:39,


示例18: main

int main(){  // Image dimensions.  const int w = 320;  const int h = 200;  const int c = 3;  const int stride = w*c;  // Raw data.  std::vector<unsigned char> data(w*h*c, 255);  ImagePainter painter(&data[0], w, h);    double black[] = { 0, 0, 0 };  double red[] = { 1, 0, 0 };  double green[] = { 0, 1, 0 };  double blue[] = { 0, 0, 1 };    // Draw two filled ellipses.  painter.fillEllipse(w/2, h/2, 50, 30, M_PI/6., red);  painter.drawEllipse(w/2, h/2, 50, 30, M_PI/6., black, 5.);  painter.fillEllipse(0, 0, 20, 50, M_PI/3., green);  // Draw two ellipses.  painter.drawCircle(30, 80, 25, blue, 3.);  // Draw rectangle.  painter.fillRectangle(10, 10, 300, 40, blue);  painter.drawRectangle(10, 10, 300, 40, black, 2.);  // Draw black line.  painter.drawLine(0, 0, 100, 50, black, 2.);  painter.drawLine(20, 50, 100, 60, black, 1.);  write_ppm(&data[0], w, h, "agg_test.ppm");  return 0;}
开发者ID:NNemec,项目名称:antigrain,代码行数:38,


示例19: run_gpu_color_test

void run_gpu_color_test(PPM_IMG img_in){    StopWatchInterface *timer=NULL;    launchEmptyKernel();    // lauch an empty kernel    printf("Starting GPU processing.../n");    sdkCreateTimer(&timer);    sdkStartTimer(&timer);    img_obuf_yuv_gpu = rgb2yuvGPU(img_in); //Start RGB 2 YUV    sdkStopTimer(&timer);    printf("RGB to YUV conversion time(GPU): %f (ms)/n", sdkGetTimerValue(&timer));    sdkDeleteTimer(&timer);    sdkCreateTimer(&timer);    sdkStartTimer(&timer);    img_obuf_rgb_gpu = yuv2rgbGPU(img_obuf_yuv_gpu); //Start YUV 2 RGB    sdkStopTimer(&timer);    printf("YUV to RGB conversion time(GPU): %f (ms)/n", sdkGetTimerValue(&timer));    sdkDeleteTimer(&timer);        write_ppm(img_obuf_rgb_gpu, "out_rgb.ppm");    write_yuv(img_obuf_yuv_gpu, "out_yuv.yuv");}
开发者ID:YansongZang,项目名称:cmpt-886,代码行数:23,


示例20: main

int main(int argc, char** argv){    int grid_size_x;    int grid_size_y;    int max_iter;    float xmin;    float xmax;    float ymin;    float ymax;    int **image;    read_options(argc, argv, &grid_size_x, &grid_size_y, &max_iter,                 &xmin, &xmax, &ymin, &ymax);    initialise_image(&image, grid_size_x, grid_size_y);    compute_mandelbrot_set(image, xmin, xmax, ymin, ymax,                           grid_size_x, grid_size_y, max_iter);    write_ppm("output.ppm", image, grid_size_x, grid_size_y, max_iter);    free(image);    return 0;}
开发者ID:bluefeet32,项目名称:PDP,代码行数:24,


示例21: sample_main

//.........这里部分代码省略.........    vkCmdBeginRenderPass(info.cmd, &rp_begin, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS);    vkCmdExecuteCommands(info.cmd, 4, secondary_cmds);    vkCmdEndRenderPass(info.cmd);    VkImageMemoryBarrier prePresentBarrier = {};    prePresentBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;    prePresentBarrier.pNext = NULL;    prePresentBarrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;    prePresentBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;    prePresentBarrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;    prePresentBarrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;    prePresentBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;    prePresentBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;    prePresentBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;    prePresentBarrier.subresourceRange.baseMipLevel = 0;    prePresentBarrier.subresourceRange.levelCount = 1;    prePresentBarrier.subresourceRange.baseArrayLayer = 0;    prePresentBarrier.subresourceRange.layerCount = 1;    prePresentBarrier.image = info.buffers[info.current_buffer].image;    vkCmdPipelineBarrier(info.cmd, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL,                         0, NULL, 1, &prePresentBarrier);    res = vkEndCommandBuffer(info.cmd);    assert(res == VK_SUCCESS);    const VkCommandBuffer cmd_bufs[] = {info.cmd};    VkFenceCreateInfo fenceInfo;    VkFence drawFence;    fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;    fenceInfo.pNext = NULL;    fenceInfo.flags = 0;    vkCreateFence(info.device, &fenceInfo, NULL, &drawFence);    VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;    VkSubmitInfo submit_info[1] = {};    submit_info[0].pNext = NULL;    submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;    submit_info[0].waitSemaphoreCount = 1;    submit_info[0].pWaitSemaphores = &imageAcquiredSemaphore;    submit_info[0].pWaitDstStageMask = &pipe_stage_flags;    submit_info[0].commandBufferCount = 1;    submit_info[0].pCommandBuffers = cmd_bufs;    submit_info[0].signalSemaphoreCount = 0;    submit_info[0].pSignalSemaphores = NULL;    /* Queue the command buffer for execution */    res = vkQueueSubmit(info.graphics_queue, 1, submit_info, drawFence);    assert(res == VK_SUCCESS);    /* Now present the image in the window */    VkPresentInfoKHR present;    present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;    present.pNext = NULL;    present.swapchainCount = 1;    present.pSwapchains = &info.swap_chain;    present.pImageIndices = &info.current_buffer;    present.pWaitSemaphores = NULL;    present.waitSemaphoreCount = 0;    present.pResults = NULL;    /* Make sure command buffer is finished before presenting */    do {        res = vkWaitForFences(info.device, 1, &drawFence, VK_TRUE, FENCE_TIMEOUT);    } while (res == VK_TIMEOUT);    assert(res == VK_SUCCESS);    res = vkQueuePresentKHR(info.present_queue, &present);    assert(res == VK_SUCCESS);    wait_seconds(1);    if (info.save_images) write_ppm(info, "secondary_command_buffer");    vkFreeCommandBuffers(info.device, info.cmd_pool, 4, secondary_cmds);    /* VULKAN_KEY_END */    vkDestroyFence(info.device, drawFence, NULL);    vkDestroySemaphore(info.device, imageAcquiredSemaphore, NULL);    destroy_pipeline(info);    destroy_pipeline_cache(info);    destroy_textures(info);    destroy_descriptor_pool(info);    destroy_vertex_buffer(info);    destroy_framebuffers(info);    destroy_shaders(info);    destroy_renderpass(info);    destroy_descriptor_and_pipeline_layouts(info);    destroy_uniform_buffer(info);    destroy_depth_buffer(info);    destroy_swap_chain(info);    destroy_command_buffer(info);    destroy_command_pool(info);    destroy_device(info);    destroy_window(info);    destroy_instance(info);    return 0;}
开发者ID:LunarG,项目名称:VulkanSamples,代码行数:101,


示例22: load_files

static int load_files(void){    void *voidc;    int rtype;    register int i, rowoff, row, col, vxoff, vyoff, offset;    int cnt, fd, size, tsiz, coff;    int vnum;    int y_rows, y_cols;    char *pr, *pg, *pb;    unsigned char *tr, *tg, *tb, *tset;    char *mpfilename, *name;    char *yfiles[MAXIMAGES];    struct Colors colors;    int ret;    size = nrows * ncols;    pr = G_malloc(size);    pg = G_malloc(size);    pb = G_malloc(size);    tsiz = Rast_window_cols();    tr = (unsigned char *)G_malloc(tsiz);    tg = (unsigned char *)G_malloc(tsiz);    tb = (unsigned char *)G_malloc(tsiz);    tset = (unsigned char *)G_malloc(tsiz);    for (cnt = 0; cnt < frames; cnt++) {	if (cnt > MAXIMAGES) {	    cnt--;	    break;	}	for (i = 0; i < size; i++)	    pr[i] = pg[i] = pb[i] = 0;	for (vnum = 0; vnum < numviews; vnum++) {	    if (icols == vcols) {		vxoff = BORDER_W;		vyoff = (irows == vrows) ? BORDER_W :		    BORDER_W + vnum * (BORDER_W + vrows);	    }	    else if (irows == vrows) {		vxoff = (icols == vcols) ? BORDER_W :		    BORDER_W + vnum * (BORDER_W + vcols);		vyoff = BORDER_W;	    }	    else {		/* 4 views */		/* assumes we want:		   view1        view2		   view3        view4   		 */		vxoff = vnum % 2 ? BORDER_W : vcols + 2 * BORDER_W;		vyoff = vnum > 1 ? vrows + 2 * BORDER_W : BORDER_W;	    }	    name = vfiles[vnum][cnt];	    G_message(_("Reading raster map <%s>..."), name);	    fd = Rast_open_old(name, "");	    if (Rast_read_colors(name, "", &colors) < 0)		G_fatal_error(_("Unable to read color table for <%s>"), name);	    rtype = Rast_get_map_type(fd);	    voidc = Rast_allocate_buf(rtype);	    for (row = 0; row < vrows; row++) {		Rast_get_row(fd, voidc, (int)(row / vscale), rtype);		rowoff = (vyoff + row) * ncols;		Rast_lookup_colors(voidc, tr, tg, tb,				       tset, tsiz, &colors, rtype);		for (col = 0; col < vcols; col++) {		    coff = (int)(col / vscale);		    offset = rowoff + col + vxoff;		    if (!tset[coff])			pr[offset] = pg[offset] = pb[offset] = (char)255;		    else {			pr[offset] = (char)tr[coff];			pg[offset] = (char)tg[coff];			pb[offset] = (char)tb[coff];		    }		}	    }	    Rast_close(fd);	}	yfiles[cnt] = G_tempfile();#ifdef USE_PPM	write_ppm(pr, pg, pb, nrows, ncols, &y_rows, &y_cols, yfiles[cnt]);#else	write_ycc(pr, pg, pb, nrows, ncols, &y_rows, &y_cols, yfiles[cnt]);#endif//.........这里部分代码省略.........
开发者ID:caomw,项目名称:grass,代码行数:101,


示例23: sample_main

//.........这里部分代码省略.........    rp_begin.framebuffer = info.framebuffers[info.current_buffer];    rp_begin.renderArea.offset.x = 0;    rp_begin.renderArea.offset.y = 0;    rp_begin.renderArea.extent.width = info.width;    rp_begin.renderArea.extent.height = info.height;    rp_begin.clearValueCount = 2;    rp_begin.pClearValues = clear_values;    vkCmdBeginRenderPass(info.cmd, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);    vkCmdBindPipeline(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline);    vkCmdBindDescriptorSets(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline_layout, 0, descriptor_set_count,                            descriptor_sets, 0, NULL);    const VkDeviceSize offsets[1] = {0};    vkCmdBindVertexBuffers(info.cmd, 0, 1, &info.vertex_buffer.buf, offsets);    init_viewports(info);    init_scissors(info);    vkCmdDraw(info.cmd, 12 * 3, 1, 0, 0);    vkCmdEndRenderPass(info.cmd);    res = vkEndCommandBuffer(info.cmd);    assert(res == VK_SUCCESS);    const VkCommandBuffer cmd_bufs[] = {info.cmd};    VkFenceCreateInfo fenceInfo;    VkFence drawFence;    fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;    fenceInfo.pNext = NULL;    fenceInfo.flags = 0;    vkCreateFence(info.device, &fenceInfo, NULL, &drawFence);    VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;    VkSubmitInfo submit_info[1] = {};    submit_info[0].pNext = NULL;    submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;    submit_info[0].waitSemaphoreCount = 1;    submit_info[0].pWaitSemaphores = &imageAcquiredSemaphore;    submit_info[0].pWaitDstStageMask = &pipe_stage_flags;    submit_info[0].commandBufferCount = 1;    submit_info[0].pCommandBuffers = cmd_bufs;    submit_info[0].signalSemaphoreCount = 0;    submit_info[0].pSignalSemaphores = NULL;    /* Queue the command buffer for execution */    res = vkQueueSubmit(info.graphics_queue, 1, submit_info, drawFence);    assert(res == VK_SUCCESS);    /* Now present the image in the window */    VkPresentInfoKHR present;    present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;    present.pNext = NULL;    present.swapchainCount = 1;    present.pSwapchains = &info.swap_chain;    present.pImageIndices = &info.current_buffer;    present.pWaitSemaphores = NULL;    present.waitSemaphoreCount = 0;    present.pResults = NULL;    /* Make sure command buffer is finished before presenting */    do {        res = vkWaitForFences(info.device, 1, &drawFence, VK_TRUE, FENCE_TIMEOUT);    } while (res == VK_TIMEOUT);    assert(res == VK_SUCCESS);    res = vkQueuePresentKHR(info.present_queue, &present);    assert(res == VK_SUCCESS);    wait_seconds(1);    if (info.save_images) write_ppm(info, "multiple_sets");    vkDestroySemaphore(info.device, imageAcquiredSemaphore, NULL);    vkDestroyFence(info.device, drawFence, NULL);    destroy_pipeline(info);    destroy_pipeline_cache(info);    destroy_textures(info);    // instead of destroy_descriptor_pool(info);    vkDestroyDescriptorPool(info.device, descriptor_pool[0], NULL);    destroy_vertex_buffer(info);    destroy_framebuffers(info);    destroy_shaders(info);    destroy_renderpass(info);    // instead of destroy_descriptor_and_pipeline_layouts(info);    for (int i = 0; i < descriptor_set_count; i++) vkDestroyDescriptorSetLayout(info.device, descriptor_layouts[i], NULL);    vkDestroyPipelineLayout(info.device, info.pipeline_layout, NULL);    destroy_uniform_buffer(info);    destroy_depth_buffer(info);    destroy_swap_chain(info);    destroy_command_buffer(info);    destroy_command_pool(info);    destroy_device(info);    destroy_window(info);    destroy_instance(info);    return 0;}
开发者ID:LunarG,项目名称:VulkanSamples,代码行数:101,


示例24: sample_main

//.........这里部分代码省略.........        moduleCreateInfo.pCode = fragmentBinary->code;        spvDiagnosticDestroy(fragmentDiag);        spvContextDestroy(spvContext);    } else {        // Convert GLSL to SPIR-V        init_glslang();        std::vector<unsigned int> fragSpv;        bool U_ASSERT_ONLY retVal = GLSLtoSPV(VK_SHADER_STAGE_FRAGMENT_BIT, fragShaderText, fragSpv);        assert(retVal);        finalize_glslang();        moduleCreateInfo.codeSize = fragSpv.size() * sizeof(unsigned int);        moduleCreateInfo.pCode = fragSpv.data();    }    res = vkCreateShaderModule(info.device, &moduleCreateInfo, NULL, &info.shaderStages[1].module);    assert(res == VK_SUCCESS);    /* VULKAN_KEY_END */    init_framebuffers(info, depthPresent);    init_vertex_buffer(info, g_vb_texture_Data, sizeof(g_vb_texture_Data), sizeof(g_vb_texture_Data[0]), true);    init_descriptor_pool(info, true);    init_descriptor_set(info, true);    init_pipeline_cache(info);    init_pipeline(info, depthPresent);    init_presentable_image(info);    VkClearValue clear_values[2];    init_clear_color_and_depth(info, clear_values);    VkRenderPassBeginInfo rp_begin;    init_render_pass_begin_info(info, rp_begin);    rp_begin.clearValueCount = 2;    rp_begin.pClearValues = clear_values;    vkCmdBeginRenderPass(info.cmd, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);    vkCmdBindPipeline(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline);    vkCmdBindDescriptorSets(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline_layout, 0, NUM_DESCRIPTOR_SETS,                            info.desc_set.data(), 0, NULL);    const VkDeviceSize offsets[1] = {0};    vkCmdBindVertexBuffers(info.cmd, 0, 1, &info.vertex_buffer.buf, offsets);    init_viewports(info);    init_scissors(info);    vkCmdDraw(info.cmd, 12 * 3, 1, 0, 0);    vkCmdEndRenderPass(info.cmd);    res = vkEndCommandBuffer(info.cmd);    assert(res == VK_SUCCESS);    VkFence drawFence = {};    init_fence(info, drawFence);    VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;    VkSubmitInfo submit_info = {};    init_submit_info(info, submit_info, pipe_stage_flags);    /* Queue the command buffer for execution */    res = vkQueueSubmit(info.graphics_queue, 1, &submit_info, drawFence);    assert(res == VK_SUCCESS);    /* Now present the image in the window */    VkPresentInfoKHR present = {};    init_present_info(info, present);    /* Make sure command buffer is finished before presenting */    do {        res = vkWaitForFences(info.device, 1, &drawFence, VK_TRUE, FENCE_TIMEOUT);    } while (res == VK_TIMEOUT);    assert(res == VK_SUCCESS);    res = vkQueuePresentKHR(info.present_queue, &present);    assert(res == VK_SUCCESS);    wait_seconds(1);    if (info.save_images) write_ppm(info, "spirv_specialization");    vkDestroyFence(info.device, drawFence, NULL);    vkDestroySemaphore(info.device, info.imageAcquiredSemaphore, NULL);    destroy_pipeline(info);    destroy_pipeline_cache(info);    destroy_textures(info);    destroy_descriptor_pool(info);    destroy_vertex_buffer(info);    destroy_framebuffers(info);    destroy_shaders(info);    destroy_renderpass(info);    destroy_descriptor_and_pipeline_layouts(info);    destroy_uniform_buffer(info);    destroy_depth_buffer(info);    destroy_swap_chain(info);    destroy_command_buffer(info);    destroy_command_pool(info);    destroy_device(info);    destroy_window(info);    destroy_instance(info);    return 0;}
开发者ID:billhollings,项目名称:VulkanSamples,代码行数:101,


示例25: sample_main

//.........这里部分代码省略.........    uni_offsets[0] = (uint32_t)buf_size; /* The second draw should use the                                            second matrix in the buffer */    vkCmdBindDescriptorSets(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,                            info.pipeline_layout, 0, NUM_DESCRIPTOR_SETS,                            info.desc_set.data(), 1, uni_offsets);    vkCmdDraw(info.cmd, 12 * 3, 1, 0, 0);    vkCmdEndRenderPass(info.cmd);    VkImageMemoryBarrier prePresentBarrier = {};    prePresentBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;    prePresentBarrier.pNext = NULL;    prePresentBarrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;    prePresentBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;    prePresentBarrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;    prePresentBarrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;    prePresentBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;    prePresentBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;    prePresentBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;    prePresentBarrier.subresourceRange.baseMipLevel = 0;    prePresentBarrier.subresourceRange.levelCount = 1;    prePresentBarrier.subresourceRange.baseArrayLayer = 0;    prePresentBarrier.subresourceRange.layerCount = 1;    prePresentBarrier.image = info.buffers[info.current_buffer].image;    vkCmdPipelineBarrier(info.cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,                         VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, 0,                         NULL, 1, &prePresentBarrier);    res = vkEndCommandBuffer(info.cmd);    const VkCommandBuffer cmd_bufs[] = {info.cmd};    VkFenceCreateInfo fenceInfo;    VkFence drawFence;    fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;    fenceInfo.pNext = NULL;    fenceInfo.flags = 0;    vkCreateFence(info.device, &fenceInfo, NULL, &drawFence);    VkPipelineStageFlags pipe_stage_flags =        VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;    VkSubmitInfo submit_info[1] = {};    submit_info[0].pNext = NULL;    submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;    submit_info[0].waitSemaphoreCount = 1;    submit_info[0].pWaitSemaphores = &presentCompleteSemaphore;    submit_info[0].pWaitDstStageMask = &pipe_stage_flags;    submit_info[0].commandBufferCount = 1;    submit_info[0].pCommandBuffers = cmd_bufs;    submit_info[0].signalSemaphoreCount = 0;    submit_info[0].pSignalSemaphores = NULL;    /* Queue the command buffer for execution */    res = vkQueueSubmit(info.queue, 1, submit_info, drawFence);    assert(res == VK_SUCCESS);    /* Now present the image in the window */    VkPresentInfoKHR present;    present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;    present.pNext = NULL;    present.swapchainCount = 1;    present.pSwapchains = &info.swap_chain;    present.pImageIndices = &info.current_buffer;    present.pWaitSemaphores = NULL;    present.waitSemaphoreCount = 0;    present.pResults = NULL;    /* Make sure command buffer is finished before presenting */    do {        res =            vkWaitForFences(info.device, 1, &drawFence, VK_TRUE, FENCE_TIMEOUT);    } while (res == VK_TIMEOUT);    assert(res == VK_SUCCESS);    res = vkQueuePresentKHR(info.queue, &present);    assert(res == VK_SUCCESS);    wait_seconds(1);    /* VULKAN_KEY_END */    if (info.save_images)        write_ppm(info, "dynamicuniform");    vkDestroySemaphore(info.device, presentCompleteSemaphore, NULL);    vkDestroyFence(info.device, drawFence, NULL);    destroy_pipeline(info);    destroy_pipeline_cache(info);    destroy_descriptor_pool(info);    destroy_vertex_buffer(info);    destroy_framebuffers(info);    destroy_shaders(info);    destroy_renderpass(info);    destroy_descriptor_and_pipeline_layouts(info);    destroy_uniform_buffer(info);    destroy_depth_buffer(info);    destroy_swap_chain(info);    destroy_command_buffer(info);    destroy_command_pool(info);    destroy_device(info);    destroy_window(info);    destroy_instance(info);    return 0;}
开发者ID:10imaging,项目名称:vulkan-basic-samples,代码行数:101,


示例26: sample_main

//.........这里部分代码省略.........    descriptor_writes[2] = {};    descriptor_writes[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;    descriptor_writes[2].pNext = NULL;    descriptor_writes[2].dstSet = descriptor_sets[0];    descriptor_writes[2].descriptorCount = 1;    descriptor_writes[2].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;    descriptor_writes[2].pImageInfo = &samplerInfo;    descriptor_writes[2].dstArrayElement = 0;    descriptor_writes[2].dstBinding = 2;    vkUpdateDescriptorSets(info.device, resource_count, descriptor_writes, 0, NULL);    /* VULKAN_KEY_END */    init_pipeline_cache(info);    init_pipeline(info, depthPresent);    init_presentable_image(info);    VkClearValue clear_values[2];    init_clear_color_and_depth(info, clear_values);    VkRenderPassBeginInfo rp_begin;    init_render_pass_begin_info(info, rp_begin);    rp_begin.clearValueCount = 2;    rp_begin.pClearValues = clear_values;    vkCmdBeginRenderPass(info.cmd, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);    vkCmdBindPipeline(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline);    vkCmdBindDescriptorSets(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline_layout, 0, NUM_DESCRIPTOR_SETS,                            descriptor_sets, 0, NULL);    const VkDeviceSize offsets[1] = {0};    vkCmdBindVertexBuffers(info.cmd, 0, 1, &info.vertex_buffer.buf, offsets);    init_viewports(info);    init_scissors(info);    vkCmdDraw(info.cmd, 12 * 3, 1, 0, 0);    vkCmdEndRenderPass(info.cmd);    res = vkEndCommandBuffer(info.cmd);    assert(res == VK_SUCCESS);    VkFence drawFence = {};    init_fence(info, drawFence);    VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;    VkSubmitInfo submit_info = {};    init_submit_info(info, submit_info, pipe_stage_flags);    /* Queue the command buffer for execution */    res = vkQueueSubmit(info.graphics_queue, 1, &submit_info, drawFence);    assert(res == VK_SUCCESS);    /* Now present the image in the window */    VkPresentInfoKHR present = {};    init_present_info(info, present);    /* Make sure command buffer is finished before presenting */    do {        res = vkWaitForFences(info.device, 1, &drawFence, VK_TRUE, FENCE_TIMEOUT);    } while (res == VK_TIMEOUT);    assert(res == VK_SUCCESS);    res = vkQueuePresentKHR(info.present_queue, &present);    assert(res == VK_SUCCESS);    wait_seconds(1);    if (info.save_images) write_ppm(info, "separate_image_sampler");    vkDestroyFence(info.device, drawFence, NULL);    vkDestroySemaphore(info.device, info.imageAcquiredSemaphore, NULL);    destroy_pipeline(info);    destroy_pipeline_cache(info);    vkDestroySampler(info.device, separateSampler, NULL);    vkDestroyImageView(info.device, info.textures[0].view, NULL);    vkDestroyImage(info.device, info.textures[0].image, NULL);    vkFreeMemory(info.device, info.textures[0].mem, NULL);    // instead of destroy_descriptor_pool(info);    vkDestroyDescriptorPool(info.device, descriptor_pool[0], NULL);    destroy_vertex_buffer(info);    destroy_framebuffers(info);    destroy_shaders(info);    destroy_renderpass(info);    // instead of destroy_descriptor_and_pipeline_layouts(info);    for (int i = 0; i < descriptor_set_count; i++) vkDestroyDescriptorSetLayout(info.device, descriptor_layouts[i], NULL);    vkDestroyPipelineLayout(info.device, info.pipeline_layout, NULL);    destroy_uniform_buffer(info);    destroy_depth_buffer(info);    destroy_swap_chain(info);    destroy_command_buffer(info);    destroy_command_pool(info);    destroy_device(info);    destroy_window(info);    destroy_instance(info);    return 0;}
开发者ID:karl-lunarg,项目名称:VulkanSamples,代码行数:101,


示例27: sample_main

//.........这里部分代码省略.........    descriptor_writes[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;    descriptor_writes[0].pNext = NULL;    descriptor_writes[0].dstSet = descriptor_sets[0];    descriptor_writes[0].descriptorCount = 1;    descriptor_writes[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;    descriptor_writes[0].pBufferInfo = &info.uniform_data.buffer_info;  // populated by init_uniform_buffer()    descriptor_writes[0].dstArrayElement = 0;    descriptor_writes[0].dstBinding = 0;    vkUpdateDescriptorSets(info.device, resource_count, descriptor_writes, 0, NULL);    // Create our push constant data, which matches shader expectations    unsigned pushConstants[2] = {};    pushConstants[0] = (unsigned)2;    pushConstants[1] = (unsigned)0x3F800000;    // Ensure we have enough room for push constant data    if (sizeof(pushConstants) > info.gpu_props.limits.maxPushConstantsSize) assert(0 && "Too many push constants");    vkCmdPushConstants(info.cmd, info.pipeline_layout, VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(pushConstants), pushConstants);    /* VULKAN_KEY_END */    init_pipeline_cache(info);    init_pipeline(info, depthPresent);    init_presentable_image(info);    VkClearValue clear_values[2];    init_clear_color_and_depth(info, clear_values);    VkRenderPassBeginInfo rp_begin;    init_render_pass_begin_info(info, rp_begin);    rp_begin.clearValueCount = 2;    rp_begin.pClearValues = clear_values;    vkCmdBeginRenderPass(info.cmd, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);    vkCmdBindPipeline(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline);    vkCmdBindDescriptorSets(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline_layout, 0, NUM_DESCRIPTOR_SETS,                            descriptor_sets, 0, NULL);    const VkDeviceSize offsets[1] = {0};    vkCmdBindVertexBuffers(info.cmd, 0, 1, &info.vertex_buffer.buf, offsets);    init_viewports(info);    init_scissors(info);    vkCmdDraw(info.cmd, 12 * 3, 1, 0, 0);    vkCmdEndRenderPass(info.cmd);    res = vkEndCommandBuffer(info.cmd);    assert(res == VK_SUCCESS);    VkFence drawFence = {};    init_fence(info, drawFence);    VkPipelineStageFlags pipe_stage_flags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;    VkSubmitInfo submit_info = {};    init_submit_info(info, submit_info, pipe_stage_flags);    /* Queue the command buffer for execution */    res = vkQueueSubmit(info.graphics_queue, 1, &submit_info, drawFence);    assert(res == VK_SUCCESS);    /* Now present the image in the window */    VkPresentInfoKHR present = {};    init_present_info(info, present);    /* Make sure command buffer is finished before presenting */    do {        res = vkWaitForFences(info.device, 1, &drawFence, VK_TRUE, FENCE_TIMEOUT);    } while (res == VK_TIMEOUT);    assert(res == VK_SUCCESS);    res = vkQueuePresentKHR(info.present_queue, &present);    assert(res == VK_SUCCESS);    wait_seconds(1);    if (info.save_images) write_ppm(info, "push_constants");    vkDestroyFence(info.device, drawFence, NULL);    vkDestroySemaphore(info.device, info.imageAcquiredSemaphore, NULL);    destroy_pipeline(info);    destroy_pipeline_cache(info);    // instead of destroy_descriptor_pool(info);    vkDestroyDescriptorPool(info.device, descriptor_pool[0], NULL);    destroy_vertex_buffer(info);    destroy_framebuffers(info);    destroy_shaders(info);    destroy_renderpass(info);    // instead of destroy_descriptor_and_pipeline_layouts(info);    for (int i = 0; i < descriptor_set_count; i++) vkDestroyDescriptorSetLayout(info.device, descriptor_layouts[i], NULL);    vkDestroyPipelineLayout(info.device, info.pipeline_layout, NULL);    destroy_uniform_buffer(info);    destroy_depth_buffer(info);    destroy_swap_chain(info);    destroy_command_buffer(info);    destroy_command_pool(info);    destroy_device(info);    destroy_window(info);    destroy_instance(info);    return 0;}
开发者ID:karl-lunarg,项目名称:VulkanSamples,代码行数:101,


示例28: ltgl_key

static void ltgl_key(unsigned char key, int x, int y){  if (key==27)  {    free_lstr_block(&lstr_block);    free_lsys_list(parsed_lsys);    free_transsys_list(parsed_transsys);    exit(0);  }  if (key==' ')  {    if (render_parameters.polygon_mode == GL_FILL)      render_parameters.polygon_mode = GL_LINE;    else      render_parameters.polygon_mode = GL_FILL;    glPolygonMode(GL_FRONT_AND_BACK, render_parameters.polygon_mode);  }  else if (key == 'n')    lstr_block.string_index++;  else if (key == 'N')    lstr_block.string_index += 50;  else if (key == '<')  {    render_parameters.animate_mode = 1;    ltgl_animate_func(-1);  }  else if (key == '>')  {    render_parameters.animate_mode = 1;    ltgl_animate_func(1);  }  else if (key == '.')    render_parameters.animate_mode = 0;  else if (key == 'l')    render_parameters.lighting_mode = !render_parameters.lighting_mode;  else if (key == 'p')    lstr_block.string_index--;  else if (key == 'X')    render_parameters.view_position.x += 0.2;  else if (key == 'x')    render_parameters.view_position.x -= 0.2;  else if (key == 'Y')    render_parameters.view_position.y += 0.2;  else if (key == 'y')    render_parameters.view_position.y -= 0.2;  else if (key == 'Z')    render_parameters.view_position.z += 0.2;  else if (key == 'z')    render_parameters.view_position.z -= 0.2;  else if (key == '|')  {    render_parameters.view_orientation.w = 1.0;    render_parameters.view_orientation.x = 0.0;    render_parameters.view_orientation.y = 0.0;    render_parameters.view_orientation.z = 0.0;    render_parameters.model_orientation.w = 1.0;    render_parameters.model_orientation.x = 0.0;    render_parameters.model_orientation.y = 0.0;    render_parameters.model_orientation.z = 0.0;  }  else if (key == 'i')    write_ppm();  else if (key == '?')    print_globals(stdout);  else if (key == 's')    print_lstrings(stdout);  else if (key == 'v')    verbose = !verbose;  else  {    if (isprint(key))      fprintf(stderr, "ltgl_key: unrecognized key '%c'/n", key);    else if (iscntrl(key))      fprintf(stderr, "ltgl_key: unrecognized key '^%c'/n", key + 64);    else      fprintf(stderr, "ltgl_key: unrecognized key #%d/n", key);  }  glutPostRedisplay ();}
开发者ID:anyelacamargo,项目名称:transsys,代码行数:79,


示例29: sample_main

//.........这里部分代码省略.........    vkUpdateDescriptorSets(info.device, 1, writes, 0, NULL);    init_pipeline_cache(info);    init_pipeline(info, depthPresent, vertexPresent);    // Color attachment clear to gray    VkClearValue clear_values;    clear_values.color.float32[0] = 0.2f;    clear_values.color.float32[1] = 0.2f;    clear_values.color.float32[2] = 0.2f;    clear_values.color.float32[3] = 0.2f;    VkSemaphoreCreateInfo imageAcquiredSemaphoreCreateInfo;    imageAcquiredSemaphoreCreateInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;    imageAcquiredSemaphoreCreateInfo.pNext = NULL;    imageAcquiredSemaphoreCreateInfo.flags = 0;    res = vkCreateSemaphore(info.device, &imageAcquiredSemaphoreCreateInfo, NULL, &info.imageAcquiredSemaphore);    assert(res == VK_SUCCESS);    // Get the index of the next available swapchain image:    res = vkAcquireNextImageKHR(info.device, info.swap_chain, UINT64_MAX, info.imageAcquiredSemaphore, VK_NULL_HANDLE,                                &info.current_buffer);    // TODO: Deal with the VK_SUBOPTIMAL_KHR and VK_ERROR_OUT_OF_DATE_KHR    // return codes    assert(res == VK_SUCCESS);    VkRenderPassBeginInfo rp_begin;    rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;    rp_begin.pNext = NULL;    rp_begin.renderPass = info.render_pass;    rp_begin.framebuffer = info.framebuffers[info.current_buffer];    rp_begin.renderArea.offset.x = 0;    rp_begin.renderArea.offset.y = 0;    rp_begin.renderArea.extent.width = info.width;    rp_begin.renderArea.extent.height = info.height;    rp_begin.clearValueCount = 1;    rp_begin.pClearValues = &clear_values;    vkCmdBeginRenderPass(info.cmd, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);    vkCmdBindPipeline(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline);    vkCmdBindDescriptorSets(info.cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, info.pipeline_layout, 0, NUM_DESCRIPTOR_SETS,                            info.desc_set.data(), 0, NULL);    init_viewports(info);    init_scissors(info);    vkCmdDraw(info.cmd, 3, 1, 0, 0);    vkCmdEndRenderPass(info.cmd);    res = vkEndCommandBuffer(info.cmd);    assert(res == VK_SUCCESS);    /* VULKAN_KEY_END */    const VkCommandBuffer cmd_bufs[] = {info.cmd};    VkFenceCreateInfo fenceInfo;    VkFence drawFence;    fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;    fenceInfo.pNext = NULL;    fenceInfo.flags = 0;    vkCreateFence(info.device, &fenceInfo, NULL, &drawFence);    execute_queue_cmdbuf(info, cmd_bufs, drawFence);    do {        res = vkWaitForFences(info.device, 1, &drawFence, VK_TRUE, FENCE_TIMEOUT);    } while (res == VK_TIMEOUT);    assert(res == VK_SUCCESS);    vkDestroyFence(info.device, drawFence, NULL);    execute_present_image(info);    wait_seconds(1);    if (info.save_images) write_ppm(info, "input_attachment");    vkDestroySemaphore(info.device, info.imageAcquiredSemaphore, NULL);    vkDestroyImageView(info.device, input_attachment_view, NULL);    vkDestroyImage(info.device, input_image, NULL);    vkFreeMemory(info.device, input_memory, NULL);    destroy_pipeline(info);    destroy_pipeline_cache(info);    destroy_descriptor_pool(info);    destroy_framebuffers(info);    destroy_shaders(info);    destroy_renderpass(info);    destroy_descriptor_and_pipeline_layouts(info);    destroy_swap_chain(info);    destroy_command_buffer(info);    destroy_command_pool(info);    destroy_device(info);    destroy_window(info);    destroy_instance(info);    return 0;}
开发者ID:karl-lunarg,项目名称:VulkanSamples,代码行数:101,


示例30: sample_main

//.........这里部分代码省略.........    cregion.srcOffset.x = 0;    cregion.srcOffset.y = 0;    cregion.srcOffset.z = 0;    cregion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;    cregion.dstSubresource.mipLevel = 0;    cregion.dstSubresource.baseArrayLayer = 0;    cregion.dstSubresource.layerCount = 1;    cregion.dstOffset.x = 256;    cregion.dstOffset.y = 256;    cregion.dstOffset.z = 0;    cregion.extent.width = 128;    cregion.extent.height = 128;    cregion.extent.depth = 1;    vkCmdCopyImage(info.cmd, bltSrcImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,                   bltDstImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1,                   &cregion);    VkImageMemoryBarrier prePresentBarrier = {};    prePresentBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;    prePresentBarrier.pNext = NULL;    prePresentBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;    prePresentBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;    prePresentBarrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;    prePresentBarrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;    prePresentBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;    prePresentBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;    prePresentBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;    prePresentBarrier.subresourceRange.baseMipLevel = 0;    prePresentBarrier.subresourceRange.levelCount = 1;    prePresentBarrier.subresourceRange.baseArrayLayer = 0;    prePresentBarrier.subresourceRange.layerCount = 1;    prePresentBarrier.image = info.buffers[info.current_buffer].image;    vkCmdPipelineBarrier(info.cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,                         VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, 0,                         NULL, 1, &prePresentBarrier);    res = vkEndCommandBuffer(info.cmd);    VkFenceCreateInfo fenceInfo;    VkFence drawFence;    fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;    fenceInfo.pNext = NULL;    fenceInfo.flags = 0;    vkCreateFence(info.device, &fenceInfo, NULL, &drawFence);    submit_info.pNext = NULL;    submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;    submit_info.waitSemaphoreCount = 0;    submit_info.pWaitSemaphores = NULL;    submit_info.pWaitDstStageMask = NULL;    submit_info.commandBufferCount = 1;    submit_info.pCommandBuffers = &info.cmd;    submit_info.signalSemaphoreCount = 0;    submit_info.pSignalSemaphores = NULL;    /* Queue the command buffer for execution */    res = vkQueueSubmit(info.queue, 1, &submit_info, drawFence);    assert(res == VK_SUCCESS);    res = vkQueueWaitIdle(info.queue);    assert(res == VK_SUCCESS);    /* Now present the image in the window */    VkPresentInfoKHR present;    present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;    present.pNext = NULL;    present.swapchainCount = 1;    present.pSwapchains = &info.swap_chain;    present.pImageIndices = &info.current_buffer;    present.pWaitSemaphores = NULL;    present.waitSemaphoreCount = 0;    present.pResults = NULL;    /* Make sure command buffer is finished before presenting */    do {        res =            vkWaitForFences(info.device, 1, &drawFence, VK_TRUE, FENCE_TIMEOUT);    } while (res == VK_TIMEOUT);    assert(res == VK_SUCCESS);    res = vkQueuePresentKHR(info.queue, &present);    assert(res == VK_SUCCESS);    wait_seconds(1);    /* VULKAN_KEY_END */    if (info.save_images)        write_ppm(info, "copyblitimage");    vkDestroySemaphore(info.device, presentCompleteSemaphore, NULL);    vkDestroyFence(info.device, drawFence, NULL);    vkDestroyImage(info.device, bltSrcImage, NULL);    vkFreeMemory(info.device, dmem, NULL);    destroy_swap_chain(info);    destroy_command_buffer(info);    destroy_command_pool(info);    destroy_device(info);    destroy_window(info);    destroy_instance(info);    return 0;}
开发者ID:Napoleon314,项目名称:VulkanSamples,代码行数:101,



注:本文中的write_ppm函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ write_record函数代码示例
C++ write_port函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。