Skip to content
Snippets Groups Projects
Commit 0ce1fa47 authored by Pascal Engeler's avatar Pascal Engeler
Browse files

Program starts!

parent 2a1c8048
No related branches found
No related tags found
No related merge requests found
...@@ -361,8 +361,8 @@ void ImGui_ImplSDL2_NewFrame(SDL_Window* window) ...@@ -361,8 +361,8 @@ void ImGui_ImplSDL2_NewFrame(SDL_Window* window)
/*We call the touch specific function here*/ /*We call the touch specific function here*/
/*For the imgui demo we need the top line, for waves we need the second line*/ /*For the imgui demo we need the top line, for waves we need the second line*/
//ImGui_ImplSDL2_UpdateMousePosAndButtons(); ImGui_ImplSDL2_UpdateMousePosAndButtons();
ImGui_ImplSDL2_Touch_UpdateMousePosAndButtons(); //ImGui_ImplSDL2_Touch_UpdateMousePosAndButtons();
ImGui_ImplSDL2_UpdateMouseCursor(); ImGui_ImplSDL2_UpdateMouseCursor();
// Update game controllers (if enabled and available) // Update game controllers (if enabled and available)
......
#include <init.hpp>
#include <glad/glad.h> #include <glad/glad.h>
//#include <SDL2/SDL.h>
#include <SDL.h> #include <SDL.h>
#include <string> #include <string>
#include <iostream> #include <iostream>
...@@ -26,7 +24,7 @@ bool Infrastructure::init(const std::string name, const int width, const int hei ...@@ -26,7 +24,7 @@ bool Infrastructure::init(const std::string name, const int width, const int hei
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
window_ = SDL_CreateWindow(name.c_str(), SDL_WINDOWPOS_CENTERED /*SDL_WINDOWPOS_CENTERED_DISPLAY(1)*/, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_FULLSCREEN); window_ = SDL_CreateWindow(name.c_str(), SDL_WINDOWPOS_CENTERED /*SDL_WINDOWPOS_CENTERED_DISPLAY(1)*/, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
//uncomment to make ginormous windows visible //uncomment to make ginormous windows visible
//SDL_SetWindowPosition(window, 0, 0); //SDL_SetWindowPosition(window, 0, 0);
......
#include <glad/glad.h>
#include <SDL.h>
#include <infrastructure.hpp>
#include <imgui.h>
#include <imgui_impl_opengl3.h>
#include <imgui_impl_sdl.h>
#include <iostream>
#define WIDTH 1280
#define HEIGHT 720
/*Debugging: Get VRAM info*/
#define GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX 0x9048
#define GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX 0x9049
int main(int argc, char** argv) {
std::cout << "Program is Starting\n";
Infrastructure infra;
infra.init("Arm Designer", WIDTH, HEIGHT);
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGui::StyleColorsDark();
ImGui_ImplSDL2_InitForOpenGL(infra.window(), infra.context());
const char* glsl_version = "#version 330";
ImGui_ImplOpenGL3_Init(glsl_version);
for (int i = 0; i < 1000; ++i) {
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplSDL2_NewFrame(infra.window());
ImGui::NewFrame();
ImGui::Begin("Developer", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0 / double(ImGui::GetIO().Framerate), double(ImGui::GetIO().Framerate));
GLint total_mem_kb = 0;
glGetIntegerv(GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX, &total_mem_kb);
ImGui::Text("Total VRAM: %.3f MB", static_cast<float>(total_mem_kb) / 1000.f);
GLint cur_avail_mem_kb = 0;
glGetIntegerv(GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX, &cur_avail_mem_kb);
ImGui::Text("Available VRAM: %.3f MB", static_cast<float>(cur_avail_mem_kb) / 1000.f);
ImGui::Text("Used VRAM: %.3f MB", static_cast<float>(total_mem_kb - cur_avail_mem_kb) / 1000.f);
if (ImGui::GetIO().MousePos[0] < -1000000) {
ImGui::Text("Mouse Coordinates: (N/A, N/A)");
}
else {
ImGui::Text("Mouse Coordinates: (%5.f, %5.f)", ImGui::GetIO().MousePos[0], ImGui::GetIO().MousePos[1]);
}
ImGui::End();
ImGui::Render();
glViewport(0, 0, WIDTH, HEIGHT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
SDL_GL_SwapWindow(infra.window());
#ifndef NDEBUG
GLint err = glGetError();
if (err != GL_NO_ERROR) {
std::cout << "Error Code: " << err << std::endl;
std::cout << "GL_NO_ERROR: " << GL_NO_ERROR << std::endl;
std::cout << "GL_INVALID_ENUM: " << GL_INVALID_ENUM << std::endl;
std::cout << "GL_INVALID_VALUE: " << GL_INVALID_VALUE << std::endl;
std::cout << "GL_INVALID_OPERATION: " << GL_INVALID_OPERATION << std::endl;
std::cout << "GL_INVALID_FRAMEBUFFER_OPERATION: " << GL_INVALID_FRAMEBUFFER_OPERATION << std::endl;
std::cout << "GL_OUT_OF_MEMORY: " << GL_OUT_OF_MEMORY << std::endl;
}
#endif
}
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment