76 lines
1.5 KiB
C
76 lines
1.5 KiB
C
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#define IMGL3W_IMPL
|
|
#include "opengl3_loader.h"
|
|
#define GLFW_INCLUDE_NONE
|
|
#include <GLFW/glfw3.h>
|
|
#if defined(__SWITCH__)
|
|
#include <switch.h>
|
|
|
|
extern "C" void userAppInit()
|
|
{
|
|
socketInitializeDefault();
|
|
nxlinkStdio();
|
|
appletSetWirelessPriorityMode(AppletWirelessPriorityMode_OptimizedForWlan);
|
|
plInitialize(PlServiceType_User);
|
|
}
|
|
|
|
extern "C" void userAppExit()
|
|
{
|
|
plExit();
|
|
socketExit();
|
|
}
|
|
#endif
|
|
|
|
static void die(const char *msg)
|
|
{
|
|
fprintf(stderr, "%s\n", msg);
|
|
exit(1);
|
|
}
|
|
|
|
static void glfwKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
|
{
|
|
if (action == GLFW_PRESS)
|
|
printf("glfwKeyCallback %d scancode %d\n", key, scancode);
|
|
}
|
|
|
|
// Main code
|
|
int main(int argc, char *argv[])
|
|
{
|
|
if (!glfwInit())
|
|
die("init glfw failed");
|
|
|
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
|
|
|
// Create window with graphics context
|
|
GLFWwindow *window = glfwCreateWindow(800, 450, "GLTEXT", NULL, NULL);
|
|
if (!window)
|
|
{
|
|
glfwTerminate();
|
|
return -1;
|
|
}
|
|
glfwMakeContextCurrent(window);
|
|
imgl3wInit2(glfwGetProcAddress);
|
|
glfwSwapInterval(1);
|
|
glfwSetTime(0);
|
|
glfwSetKeyCallback(window, glfwKeyCallback);
|
|
|
|
int fbw = 0, fbh = 0;
|
|
// Main loop
|
|
while (!glfwWindowShouldClose(window))
|
|
{
|
|
glfwGetFramebufferSize(window, &fbw, &fbh);
|
|
glViewport(0, 0, fbw, fbh);
|
|
|
|
glfwSwapBuffers(window);
|
|
glfwWaitEvents();
|
|
}
|
|
|
|
glfwDestroyWindow(window);
|
|
glfwTerminate();
|
|
|
|
return 0;
|
|
} |