当前位置: 首页 > news >正文

网站建设基本步骤包括哪些代写文章平台

网站建设基本步骤包括哪些,代写文章平台,网站建设实验小结,营销推广方案案例WebGPU(七):C头部封装 在前面的学习中,我们使用的都是原生态的WebGPU API,那是基于C语言的API,但是为了更高效的开发,我们可以使用一个基于C的库。 根据参考的教程,这个github库提供更加纤细的描述。它提…

WebGPU(七):C++头部封装

在前面的学习中,我们使用的都是原生态的WebGPU API,那是基于C语言的API,但是为了更高效的开发,我们可以使用一个基于C++的库。

根据参考的教程,这个github库提供更加纤细的描述。它提供了一个webgpu.hpp的C++封装头文件,但是在Dawn的代码实现中,本身包含一个C++头封装文件,本例程主要使用Dawn自带的C++封装头文件。

#define WEBGPU_CPP_IMPLEMENTATION
#include <webgpu/webgpu.hpp>#include <glfw3webgpu.h>
#include <GLFW/glfw3.h>#include <iostream>
#include <cassert>#define UNUSED(x) (void)x;using namespace wgpu;int main (int, char**) {Instance instance = createInstance(InstanceDescriptor{});if (!instance) {std::cerr << "Could not initialize WebGPU!" << std::endl;return 1;}if (!glfwInit()) {std::cerr << "Could not initialize GLFW!" << std::endl;return 1;}glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);GLFWwindow* window = glfwCreateWindow(640, 480, "Learn WebGPU", NULL, NULL);if (!window) {std::cerr << "Could not open window!" << std::endl;return 1;}std::cout << "Requesting adapter..." << std::endl;Surface surface = glfwGetWGPUSurface(instance, window);RequestAdapterOptions adapterOpts{};adapterOpts.compatibleSurface = surface;Adapter adapter = instance.requestAdapter(adapterOpts);std::cout << "Got adapter: " << adapter << std::endl;std::cout << "Requesting device..." << std::endl;DeviceDescriptor deviceDesc{};deviceDesc.label = "My Device";deviceDesc.requiredFeaturesCount = 0;deviceDesc.requiredLimits = nullptr;deviceDesc.defaultQueue.label = "The default queue";Device device = adapter.requestDevice(deviceDesc);std::cout << "Got device: " << device << std::endl;Queue queue = device.getQueue();auto onDeviceError = [](WGPUErrorType type, char const* message, void* /* pUserData */) {std::cout << "Uncaptured device error: type " << type;if (message) std::cout << " (" << message << ")";std::cout << std::endl;};wgpuDeviceSetUncapturedErrorCallback(device, onDeviceError, nullptr /* pUserData */);std::cout << "Creating swapchain device..." << std::endl;
#ifdef WEBGPU_BACKEND_WGPUTextureFormat swapChainFormat = surface.getPreferredFormat(adapter);
#elseTextureFormat swapChainFormat = TextureFormat::BGRA8Unorm;
#endifSwapChainDescriptor swapChainDesc = {};swapChainDesc.width = 640;swapChainDesc.height = 480;swapChainDesc.usage = TextureUsage::RenderAttachment;swapChainDesc.format = swapChainFormat;swapChainDesc.presentMode = PresentMode::Fifo;SwapChain swapChain = device.createSwapChain(surface, swapChainDesc);std::cout << "Swapchain: " << swapChain << std::endl;while (!glfwWindowShouldClose(window)) {glfwPollEvents();TextureView nextTexture = swapChain.getCurrentTextureView();if (!nextTexture) {std::cerr << "Cannot acquire next swap chain texture" << std::endl;return 1;}CommandEncoderDescriptor commandEncoderDesc{};commandEncoderDesc.label = "Command Encoder";CommandEncoder encoder = device.createCommandEncoder(commandEncoderDesc);RenderPassDescriptor renderPassDesc{};WGPURenderPassColorAttachment renderPassColorAttachment = {};renderPassColorAttachment.view = nextTexture;renderPassColorAttachment.resolveTarget = nullptr;renderPassColorAttachment.loadOp = LoadOp::Clear;renderPassColorAttachment.storeOp = StoreOp::Store;renderPassColorAttachment.clearValue = Color{ 0.9, 0.1, 0.2, 1.0 };renderPassDesc.colorAttachmentCount = 1;renderPassDesc.colorAttachments = &renderPassColorAttachment;renderPassDesc.depthStencilAttachment = nullptr;renderPassDesc.timestampWriteCount = 0;renderPassDesc.timestampWrites = nullptr;RenderPassEncoder renderPass = encoder.beginRenderPass(renderPassDesc);renderPass.end();nextTexture.release();CommandBufferDescriptor cmdBufferDescriptor{};cmdBufferDescriptor.label = "Command buffer";CommandBuffer command = encoder.finish(cmdBufferDescriptor);queue.submit(command);swapChain.present();}glfwDestroyWindow(window);glfwTerminate();return 0;
}

因为在测试的时候发现,有很多函数都没有相对应的封装,所以这一步的代码修改的内容相对而言很少。

http://www.yayakq.cn/news/332005/

相关文章:

  • 常熟市建设工程发承包网站怎么黑掉网站
  • 柳市网站设计推广医院做网站怎么就违规了
  • 朝阳网络 网站建设石家庄发生大事了
  • 河南如何建网站要什么条件二手手表回收网站
  • 建设一个门户网站需要多少钱紫色网站
  • 做数字艺术设计的网站网页图片居中怎么设置
  • 国外酷炫网站我想做一个网站怎么办
  • 网站建设实训体会友情链接怎么交换
  • 网站正在升级建设中网站程序授权码
  • 网站出现的问题吗网站外部链接如何建设
  • 沈阳核工业建设工程总公司网站网站设计面试问题
  • 网站返回500错误页面网页前端开发技术
  • 装修网站推广方案在线p图
  • 如何提升网站的权重安徽餐饮加盟网站建设
  • 如何建设简易网站地方门户网站的前途
  • 网站关键词在哪里添加网站开发软件开发流程
  • 网络推广营销工具福州seo按天付费
  • 做网站维护合同长春网站建设工作
  • 网站开发是属于哪个税收分类重庆市建设工程质量信息网
  • 营销型网站首页模板游戏网站制作模板
  • 网站logo做黑页外贸网站seo推广教程
  • 网站制作交易流程检查目录遍历漏洞wordpress站点
  • 北京英文网站建设的原则code wordpress
  • 建网站软件有哪些浙江建设工程造价信息网站
  • 企业网站建设相关书籍精通wordpress
  • 公司网站自己怎么建立找深圳网站建设
  • 人才招聘网网站策划方案修改wordpress 2m
  • 建公司网站免费行情软件下载大全
  • 做筹款的网站需要什么资质建筑模板规格型号
  • 震天建设集团网站企业推广文案范文