Avoid name conflicts between Util and Windows function
GetWindow and SwapBuffers are function of Windows.h and using the same name causes a compile error. This commit also changes Util's GetProcTableAndDevice to CreateNXTDevice because we might need to call NXT procs when creating the C++ device.
This commit is contained in:
parent
26275d0a16
commit
583e9a8f3c
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <unistd.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
nxt::Device device;
|
nxt::Device device;
|
||||||
|
@ -42,9 +41,7 @@ struct ShaderData {
|
||||||
static std::vector<ShaderData> shaderData;
|
static std::vector<ShaderData> shaderData;
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
nxtProcTable procs;
|
device = CreateCppNXTDevice();
|
||||||
GetProcTableAndDevice(&procs, &device);
|
|
||||||
nxtSetProcs(&procs);
|
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
|
|
||||||
|
@ -150,7 +147,7 @@ void frame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
queue.Submit(50, commands.data());
|
queue.Submit(50, commands.data());
|
||||||
SwapBuffers();
|
DoSwapBuffers();
|
||||||
fprintf(stderr, "frame %i\n", f);
|
fprintf(stderr, "frame %i\n", f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +159,7 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
while (!ShouldQuit()) {
|
while (!ShouldQuit()) {
|
||||||
frame();
|
frame();
|
||||||
usleep(16000);
|
USleep(16000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO release stuff
|
// TODO release stuff
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
|
@ -296,9 +295,7 @@ void initCommandBuffers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
nxtProcTable procs;
|
device = CreateCppNXTDevice();
|
||||||
GetProcTableAndDevice(&procs, &device);
|
|
||||||
nxtSetProcs(&procs);
|
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
|
|
||||||
|
@ -310,7 +307,7 @@ void init() {
|
||||||
|
|
||||||
void frame() {
|
void frame() {
|
||||||
queue.Submit(1, &commandBuffers[pingpong]);
|
queue.Submit(1, &commandBuffers[pingpong]);
|
||||||
SwapBuffers();
|
DoSwapBuffers();
|
||||||
|
|
||||||
pingpong = (pingpong + 1) % 2;
|
pingpong = (pingpong + 1) % 2;
|
||||||
}
|
}
|
||||||
|
@ -323,7 +320,7 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
while (!ShouldQuit()) {
|
while (!ShouldQuit()) {
|
||||||
frame();
|
frame();
|
||||||
usleep(16000);
|
USleep(16000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO release stuff
|
// TODO release stuff
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
nxt::Device device;
|
nxt::Device device;
|
||||||
nxt::Queue queue;
|
nxt::Queue queue;
|
||||||
|
@ -28,9 +27,7 @@ nxt::Pipeline computePipeline;
|
||||||
nxt::BindGroup computeBindGroup;
|
nxt::BindGroup computeBindGroup;
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
nxtProcTable procs;
|
device = CreateCppNXTDevice();
|
||||||
GetProcTableAndDevice(&procs, &device);
|
|
||||||
nxtSetProcs(&procs);
|
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
|
|
||||||
|
@ -142,7 +139,7 @@ void frame() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
SwapBuffers();
|
DoSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
@ -153,7 +150,7 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
while (!ShouldQuit()) {
|
while (!ShouldQuit()) {
|
||||||
frame();
|
frame();
|
||||||
usleep(16000);
|
USleep(16000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO release stuff
|
// TODO release stuff
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
nxt::Device device;
|
nxt::Device device;
|
||||||
|
@ -55,9 +54,7 @@ void initBuffers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
nxtProcTable procs;
|
device = CreateCppNXTDevice();
|
||||||
GetProcTableAndDevice(&procs, &device);
|
|
||||||
nxtSetProcs(&procs);
|
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
|
|
||||||
|
@ -105,7 +102,7 @@ void frame() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
SwapBuffers();
|
DoSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
@ -116,7 +113,7 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
while (!ShouldQuit()) {
|
while (!ShouldQuit()) {
|
||||||
frame();
|
frame();
|
||||||
usleep(16000);
|
USleep(16000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO release stuff
|
// TODO release stuff
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
nxt::Device device;
|
nxt::Device device;
|
||||||
|
@ -59,9 +58,7 @@ void initBuffers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
nxtProcTable procs;
|
device = CreateCppNXTDevice();
|
||||||
GetProcTableAndDevice(&procs, &device);
|
|
||||||
nxtSetProcs(&procs);
|
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
|
|
||||||
|
@ -112,7 +109,7 @@ void frame() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
SwapBuffers();
|
DoSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
@ -123,7 +120,7 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
while (!ShouldQuit()) {
|
while (!ShouldQuit()) {
|
||||||
frame();
|
frame();
|
||||||
usleep(16000);
|
USleep(16000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO release stuff
|
// TODO release stuff
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
nxtDevice device;
|
nxtDevice device;
|
||||||
nxtQueue queue;
|
nxtQueue queue;
|
||||||
nxtPipeline pipeline;
|
nxtPipeline pipeline;
|
||||||
|
@ -23,9 +21,7 @@ nxtRenderPass renderpass;
|
||||||
nxtFramebuffer framebuffer;
|
nxtFramebuffer framebuffer;
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
nxtProcTable procs;
|
device = CreateNXTDevice();
|
||||||
GetProcTableAndDevice(&procs, &device);
|
|
||||||
nxtSetProcs(&procs);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
nxtQueueBuilder builder = nxtDeviceCreateQueueBuilder(device);
|
nxtQueueBuilder builder = nxtDeviceCreateQueueBuilder(device);
|
||||||
|
@ -93,7 +89,7 @@ void frame() {
|
||||||
nxtQueueSubmit(queue, 1, &commands);
|
nxtQueueSubmit(queue, 1, &commands);
|
||||||
nxtCommandBufferRelease(commands);
|
nxtCommandBufferRelease(commands);
|
||||||
|
|
||||||
SwapBuffers();
|
DoSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
@ -104,7 +100,7 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
while (!ShouldQuit()) {
|
while (!ShouldQuit()) {
|
||||||
frame();
|
frame();
|
||||||
usleep(16000);
|
USleep(16000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO release stuff
|
// TODO release stuff
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
nxt::Device device;
|
nxt::Device device;
|
||||||
|
@ -95,9 +94,7 @@ void initTextures() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
nxtProcTable procs;
|
device = CreateCppNXTDevice();
|
||||||
GetProcTableAndDevice(&procs, &device);
|
|
||||||
nxtSetProcs(&procs);
|
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
|
|
||||||
|
@ -173,7 +170,7 @@ void frame() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
SwapBuffers();
|
DoSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
@ -184,7 +181,7 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
while (!ShouldQuit()) {
|
while (!ShouldQuit()) {
|
||||||
frame();
|
frame();
|
||||||
usleep(16000);
|
USleep(16000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO release stuff
|
// TODO release stuff
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
nxt::Device device;
|
nxt::Device device;
|
||||||
nxt::Queue queue;
|
nxt::Queue queue;
|
||||||
nxt::Pipeline pipeline;
|
nxt::Pipeline pipeline;
|
||||||
|
@ -27,9 +25,7 @@ nxt::BindGroup bindGroup;
|
||||||
struct {uint32_t a; float b;} s;
|
struct {uint32_t a; float b;} s;
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
nxtProcTable procs;
|
device = CreateCppNXTDevice();
|
||||||
GetProcTableAndDevice(&procs, &device);
|
|
||||||
nxtSetProcs(&procs);
|
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
|
|
||||||
|
@ -104,7 +100,7 @@ void frame() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
SwapBuffers();
|
DoSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
@ -115,7 +111,7 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
while (!ShouldQuit()) {
|
while (!ShouldQuit()) {
|
||||||
frame();
|
frame();
|
||||||
usleep(16000);
|
USleep(16000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO release stuff
|
// TODO release stuff
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
nxt::Device device;
|
nxt::Device device;
|
||||||
|
@ -43,9 +42,7 @@ void initBuffers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
nxtProcTable procs;
|
device = CreateCppNXTDevice();
|
||||||
GetProcTableAndDevice(&procs, &device);
|
|
||||||
nxtSetProcs(&procs);
|
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
|
|
||||||
|
@ -92,7 +89,7 @@ void frame() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
SwapBuffers();
|
DoSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
@ -103,7 +100,7 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
while (!ShouldQuit()) {
|
while (!ShouldQuit()) {
|
||||||
frame();
|
frame();
|
||||||
usleep(16000);
|
USleep(16000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO release stuff
|
// TODO release stuff
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
nxt::Device device;
|
nxt::Device device;
|
||||||
|
@ -183,9 +182,7 @@ void initPipelinePost() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
nxtProcTable procs;
|
device = CreateCppNXTDevice();
|
||||||
GetProcTableAndDevice(&procs, &device);
|
|
||||||
nxtSetProcs(&procs);
|
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
|
|
||||||
|
@ -217,7 +214,7 @@ void frame() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
SwapBuffers();
|
DoSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
@ -228,7 +225,7 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
while (!ShouldQuit()) {
|
while (!ShouldQuit()) {
|
||||||
frame();
|
frame();
|
||||||
usleep(16000);
|
USleep(16000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO release stuff
|
// TODO release stuff
|
||||||
|
|
|
@ -25,6 +25,12 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <Windows.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
BackendBinding* CreateMetalBinding();
|
BackendBinding* CreateMetalBinding();
|
||||||
|
|
||||||
namespace backend {
|
namespace backend {
|
||||||
|
@ -104,7 +110,7 @@ static nxt::wire::CommandHandler* wireClient = nullptr;
|
||||||
static nxt::wire::TerribleCommandBuffer* c2sBuf = nullptr;
|
static nxt::wire::TerribleCommandBuffer* c2sBuf = nullptr;
|
||||||
static nxt::wire::TerribleCommandBuffer* s2cBuf = nullptr;
|
static nxt::wire::TerribleCommandBuffer* s2cBuf = nullptr;
|
||||||
|
|
||||||
void GetProcTableAndDevice(nxtProcTable* procs, nxt::Device* device) {
|
nxt::Device CreateCppNXTDevice() {
|
||||||
switch (backendType) {
|
switch (backendType) {
|
||||||
case BackendType::OpenGL:
|
case BackendType::OpenGL:
|
||||||
binding = new OpenGLBinding;
|
binding = new OpenGLBinding;
|
||||||
|
@ -122,13 +128,13 @@ void GetProcTableAndDevice(nxtProcTable* procs, nxt::Device* device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glfwInit()) {
|
if (!glfwInit()) {
|
||||||
return;
|
return nxt::Device();
|
||||||
}
|
}
|
||||||
|
|
||||||
binding->SetupGLFWWindowHints();
|
binding->SetupGLFWWindowHints();
|
||||||
window = glfwCreateWindow(640, 480, "NXT window", nullptr, nullptr);
|
window = glfwCreateWindow(640, 480, "NXT window", nullptr, nullptr);
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return;
|
return nxt::Device();
|
||||||
}
|
}
|
||||||
|
|
||||||
binding->SetWindow(window);
|
binding->SetWindow(window);
|
||||||
|
@ -137,10 +143,12 @@ void GetProcTableAndDevice(nxtProcTable* procs, nxt::Device* device) {
|
||||||
nxtProcTable backendProcs;
|
nxtProcTable backendProcs;
|
||||||
binding->GetProcAndDevice(&backendProcs, &backendDevice);
|
binding->GetProcAndDevice(&backendProcs, &backendDevice);
|
||||||
|
|
||||||
|
nxtDevice cDevice = nullptr;
|
||||||
|
nxtProcTable procs;
|
||||||
switch (cmdBufType) {
|
switch (cmdBufType) {
|
||||||
case CmdBufType::None:
|
case CmdBufType::None:
|
||||||
*procs = backendProcs;
|
procs = backendProcs;
|
||||||
*device = nxt::Device::Acquire(backendDevice);
|
cDevice = backendDevice;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CmdBufType::Terrible:
|
case CmdBufType::Terrible:
|
||||||
|
@ -156,13 +164,15 @@ void GetProcTableAndDevice(nxtProcTable* procs, nxt::Device* device) {
|
||||||
wireClient = nxt::wire::NewClientDevice(&clientProcs, &clientDevice, c2sBuf);
|
wireClient = nxt::wire::NewClientDevice(&clientProcs, &clientDevice, c2sBuf);
|
||||||
s2cBuf->SetHandler(wireClient);
|
s2cBuf->SetHandler(wireClient);
|
||||||
|
|
||||||
*procs = clientProcs;
|
procs = clientProcs;
|
||||||
*device = nxt::Device::Acquire(clientDevice);
|
cDevice = clientDevice;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
procs->deviceSetErrorCallback(device->Get(), PrintDeviceError, 0);
|
nxtSetProcs(&procs);
|
||||||
|
procs.deviceSetErrorCallback(cDevice, PrintDeviceError, 0);
|
||||||
|
return nxt::Device::Acquire(cDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxt::ShaderModule CreateShaderModule(const nxt::Device& device, nxt::ShaderStage stage, const char* source) {
|
nxt::ShaderModule CreateShaderModule(const nxt::Device& device, nxt::ShaderStage stage, const char* source) {
|
||||||
|
@ -278,17 +288,15 @@ extern "C" {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetProcTableAndDevice(nxtProcTable* procs, nxtDevice* device) {
|
nxtDevice CreateNXTDevice() {
|
||||||
nxt::Device cppDevice;
|
return CreateCppNXTDevice().Release();
|
||||||
GetProcTableAndDevice(procs, &cppDevice);
|
|
||||||
*device = cppDevice.Release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtShaderModule CreateShaderModule(nxtDevice device, nxtShaderStage stage, const char* source) {
|
nxtShaderModule CreateShaderModule(nxtDevice device, nxtShaderStage stage, const char* source) {
|
||||||
return CreateShaderModule(device, static_cast<nxt::ShaderStage>(stage), source).Release();
|
return CreateShaderModule(device, static_cast<nxt::ShaderStage>(stage), source).Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwapBuffers() {
|
void DoSwapBuffers() {
|
||||||
if (cmdBufType == CmdBufType::Terrible) {
|
if (cmdBufType == CmdBufType::Terrible) {
|
||||||
c2sBuf->Flush();
|
c2sBuf->Flush();
|
||||||
s2cBuf->Flush();
|
s2cBuf->Flush();
|
||||||
|
@ -297,11 +305,21 @@ extern "C" {
|
||||||
binding->SwapBuffers();
|
binding->SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
void USleep(uint64_t usecs) {
|
||||||
|
Sleep(usecs / 1000);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void USleep(uint64_t usecs) {
|
||||||
|
usleep(usecs);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool ShouldQuit() {
|
bool ShouldQuit() {
|
||||||
return glfwWindowShouldClose(window);
|
return glfwWindowShouldClose(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWwindow* GetWindow() {
|
GLFWwindow* GetGLFWWindow() {
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,12 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
bool InitUtils(int argc, const char** argv);
|
bool InitUtils(int argc, const char** argv);
|
||||||
void SwapBuffers();
|
void DoSwapBuffers();
|
||||||
bool ShouldQuit();
|
bool ShouldQuit();
|
||||||
|
void USleep(uint64_t usecs);
|
||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
struct GLFWwindow* GetWindow();
|
struct GLFWwindow* GetGLFWWindow();
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,10 +31,10 @@ extern "C" {
|
||||||
// Yuck
|
// Yuck
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#include <nxt/nxtcpp.h>
|
#include <nxt/nxtcpp.h>
|
||||||
void GetProcTableAndDevice(nxtProcTable* procs, nxt::Device* device);
|
nxt::Device CreateCppNXTDevice();
|
||||||
nxt::ShaderModule CreateShaderModule(const nxt::Device& device, nxt::ShaderStage stage, const char* source);
|
nxt::ShaderModule CreateShaderModule(const nxt::Device& device, nxt::ShaderStage stage, const char* source);
|
||||||
void CreateDefaultRenderPass(const nxt::Device& device, nxt::RenderPass* renderPass, nxt::Framebuffer* framebuffer);
|
void CreateDefaultRenderPass(const nxt::Device& device, nxt::RenderPass* renderPass, nxt::Framebuffer* framebuffer);
|
||||||
#else
|
#else
|
||||||
void GetProcTableAndDevice(nxtProcTable* procs, nxtDevice* device);
|
nxtDevice CreateNXTDevice();
|
||||||
nxtShaderModule CreateShaderModule(nxtDevice device, nxtShaderStage stage, const char* source);
|
nxtShaderModule CreateShaderModule(nxtDevice device, nxtShaderStage stage, const char* source);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <unistd.h>
|
|
||||||
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||||
#include <glm/mat4x4.hpp>
|
#include <glm/mat4x4.hpp>
|
||||||
#include <glm/gtc/matrix_inverse.hpp>
|
#include <glm/gtc/matrix_inverse.hpp>
|
||||||
|
@ -450,9 +449,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
nxtProcTable procs;
|
device = CreateCppNXTDevice();
|
||||||
GetProcTableAndDevice(&procs, &device);
|
|
||||||
nxtSetProcs(&procs);
|
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
|
|
||||||
|
@ -575,7 +572,7 @@ namespace {
|
||||||
const auto& node = scene.nodes.at(n);
|
const auto& node = scene.nodes.at(n);
|
||||||
drawNode(node);
|
drawNode(node);
|
||||||
}
|
}
|
||||||
SwapBuffers();
|
DoSwapBuffers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,14 +637,14 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
GLFWwindow* window = GetWindow();
|
GLFWwindow* window = GetGLFWWindow();
|
||||||
glfwSetMouseButtonCallback(window, mouseButtonCallback);
|
glfwSetMouseButtonCallback(window, mouseButtonCallback);
|
||||||
glfwSetCursorPosCallback(window, cursorPosCallback);
|
glfwSetCursorPosCallback(window, cursorPosCallback);
|
||||||
glfwSetScrollCallback(window, scrollCallback);
|
glfwSetScrollCallback(window, scrollCallback);
|
||||||
|
|
||||||
while (!ShouldQuit()) {
|
while (!ShouldQuit()) {
|
||||||
frame();
|
frame();
|
||||||
usleep(16000);
|
USleep(16000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO release stuff
|
// TODO release stuff
|
||||||
|
|
Loading…
Reference in New Issue