Initial commit
This commit is contained in:
60
src/main.cpp
Normal file
60
src/main.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#define GLFW_INCLUDE_NONE
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#ifdef __SWITCH__
|
||||
#include <switch.h>
|
||||
|
||||
extern "C" void userAppInit() {
|
||||
socketInitializeDefault();
|
||||
nxlinkStdio();
|
||||
appletSetWirelessPriorityMode(AppletWirelessPriorityMode_OptimizedForWlan);
|
||||
plInitialize(PlServiceType_User);
|
||||
}
|
||||
|
||||
extern "C" void userAppExit() {
|
||||
plExit();
|
||||
socketExit();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Main code
|
||||
int main(int argc, char* argv[]) {
|
||||
if (!glfwInit()) return -1;
|
||||
|
||||
static int osdShow = 0;
|
||||
// Create window with graphics context
|
||||
GLFWwindow* window = glfwCreateWindow(1280, 720, "xPlayer", nullptr, nullptr);
|
||||
if (!window) {
|
||||
glfwTerminate();
|
||||
return -1;
|
||||
}
|
||||
glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) {
|
||||
if (action == GLFW_PRESS) {
|
||||
if (key == GLFW_KEY_ESCAPE)
|
||||
glfwSetWindowShouldClose(window, 1);
|
||||
else if (key == GLFW_KEY_ENTER)
|
||||
osdShow = !osdShow;
|
||||
}
|
||||
});
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(1);
|
||||
glfwSetTime(0);
|
||||
|
||||
int fbw = 0, fbh = 0;
|
||||
// Main loop
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
glfwGetFramebufferSize(window, &fbw, &fbh);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwWaitEvents();
|
||||
}
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user