image display, two columns
This commit is contained in:
parent
afa0145241
commit
fb2bafb215
56
main.cpp
56
main.cpp
|
@ -10,7 +10,7 @@ int main(int, char**)
|
||||||
return 1;
|
return 1;
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
GLFWwindow* window = glfwCreateWindow(1280, 720, "microsa", nullptr, nullptr);
|
GLFWwindow* window = glfwCreateWindow(1900, 720, "microsa", nullptr, nullptr);
|
||||||
if (window == nullptr) {
|
if (window == nullptr) {
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -18,29 +18,71 @@ int main(int, char**)
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||||
ImGui_ImplOpenGL3_Init("#version 130");
|
ImGui_ImplOpenGL3_Init("#version 130");
|
||||||
|
|
||||||
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
int waterfall_width = 1600;
|
||||||
while (!glfwWindowShouldClose(window)) {
|
int waterfall_height = 700;
|
||||||
|
unsigned int waterfall_data[1600*700];
|
||||||
|
GLuint waterfall;
|
||||||
|
glGenTextures(1, &waterfall);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, waterfall);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
|
int t = 0;
|
||||||
|
bool exit = false;
|
||||||
|
while (!exit && !glfwWindowShouldClose(window)) {
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
t++;
|
||||||
|
for(int y=0;y<waterfall_height;y++)
|
||||||
|
for(int x=0;x<waterfall_width;x++)
|
||||||
|
waterfall_data[y*waterfall_width+x] = (x+y+t) | 0xff000000;
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, waterfall);
|
||||||
|
#if defined(GL_UNPACK_ROW_LENGTH) && !defined(__EMSCRIPTEN__)
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
#endif
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, waterfall_width, waterfall_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, waterfall_data);
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
ImGui_ImplGlfw_NewFrame();
|
ImGui_ImplGlfw_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f));
|
||||||
|
ImGui::SetNextWindowSize(io.DisplaySize);
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||||
|
ImGui::Begin("microsa", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoResize);
|
||||||
|
|
||||||
|
ImGui::BeginTable("microsa", 2, ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_Resizable);
|
||||||
|
ImGui::TableSetupColumn("", 0, 280.0);
|
||||||
|
ImGui::TableSetupColumn("", 0, 1600.0);
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
if(ImGui::Button("Exit"))
|
||||||
|
exit = true;
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Image((void*)(intptr_t)waterfall, ImVec2(waterfall_width, waterfall_height));
|
||||||
|
ImGui::EndTable();
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
ImGui::PopStyleVar(1);
|
||||||
|
|
||||||
// Rendering
|
// Rendering
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
int display_w, display_h;
|
int display_w, display_h;
|
||||||
glfwGetFramebufferSize(window, &display_w, &display_h);
|
glfwGetFramebufferSize(window, &display_w, &display_h);
|
||||||
glViewport(0, 0, display_w, display_h);
|
glViewport(0, 0, display_w, display_h);
|
||||||
glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue