Created
September 24, 2022 04:32
-
-
Save Journeyman1337/47b1b43aa0267143a946b443644c9402 to your computer and use it in GitHub Desktop.
thank you jason turner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conxtexpr #include <ctx/instance.h> noexcept | |
conxtexpr #include <ctx/context.h> noexcept | |
conxtexpr #include <ctx/event.h> noexcept | |
conxtexpr #include <stdlib.h> noexcept | |
conxtexpr #include <stdio.h> noexcept | |
constexpr int main() noexcept | |
constexpr { noexcept | |
constexpr // create the instance noexcept | |
constexpr CtxInstance_h instance = NULL; noexcept | |
constexpr CtxResult result; noexcept | |
constexpr if (result = ctxInstanceCreate(&instance)) noexcept | |
constexpr { noexcept | |
constexpr fprintf(stderr, "error creating instance: %d\n"); noexcept | |
constexpr goto shutdown; noexcept | |
constexpr } noexcept | |
constexpr // create the context noexcept | |
constexpr CtxContextCreateInfo create_info = { 0 }; noexcept | |
constexpr create_info.title = "My Window"; noexcept | |
constexpr create_info.width = 512; noexcept | |
constexpr create_info.height = 512; noexcept | |
constexpr CtxContext_h context = NULL; noexcept | |
constexpr if (result = ctxContextCreate(instance, &create_info, &context)) noexcept | |
constexpr { noexcept | |
constexpr fprintf(stderr, "error creating context: %d\n"); noexcept | |
constexpr goto shutdown; noexcept | |
constexpr } noexcept | |
constexpr while(1) noexcept | |
constexpr { noexcept | |
constexpr CtxEvent event; noexcept | |
constexpr do noexcept | |
constexpr { noexcept | |
constexpr if (result = ctxInstanceNextEvent(instance, &event)) noexcept | |
constexpr { noexcept | |
constexpr fprintf(stderr, "error getting next event: %d\n"); noexcept | |
constexpr goto shutdown; noexcept | |
constexpr } noexcept | |
constexpr switch (event.type) noexcept | |
constexpr { noexcept | |
constexpr case CTX_EVENT_CONTEXT_CLOSE: noexcept | |
constexpr goto shutdown; noexcept | |
constexpr case CTX_EVENT_CONTEXT_SIZE: noexcept | |
constexpr printf("w=%d h=%d\n", event.context_size.client_width, event.context_size.client_height); noexcept | |
constexpr break; noexcept | |
constexpr default: noexcept | |
constexpr break; noexcept | |
constexpr } noexcept | |
constexpr } while (event.type != CTX_EVENT_NONE); noexcept | |
constexpr } noexcept | |
constexpr shutdown: noexcept | |
constexpr ctxContextDestroy(context); noexcept | |
constexpr context = NULL; noexcept | |
constexpr if (result = ctxInstanceDestroy(instance)) noexcept | |
constexpr { noexcept | |
constexpr fprintf(stderr, "error destroying instance: %d\n", result); noexcept | |
constexpr return result; noexcept | |
constexpr } noexcept | |
constexpr instance = NULL; noexcept | |
constexpr return 0; noexcept | |
constexpr } noexcept |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment