aboutsummaryrefslogtreecommitdiffstats
path: root/lib/lufa/BuildTests/ModuleTest/Test_C.c
blob: 3c3f5a2ab7be9a1781725d66ba470fbeda4b77af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
             LUFA Library
     Copyright (C) Dean Camera, 2017.

  dean [at] fourwalledcubicle [dot] com
           www.lufa-lib.org
*/

/*
  Copyright 2017  Dean Camera (dean [at] fourwalledcubicle [dot] com)

  Permission to use, copy, modify, distribute, and sell this
  software and its documentation for any purpose is hereby granted
  without fee, provided that the above copyright notice appear in
  all copies and that both that the copyright notice and this
  permission notice and warranty disclaimer appear in supporting
  documentation, and that the name of the author not be used in
  advertising or publicity pertaining to distribution of the
  software without specific, written prior permission.

  The author disclaims all warranties with regard to this
  software, including all implied warranties of merchantability
  and fitness.  In no event shall the author be liable for any
  special, indirect or consequential damages or any damages
  whatsoever resulting from loss of use, data or profits, whether
  in an action of contract, negligence or other tortious action,
  arising out of or in connection with the use or performance of
  this software.
*/

#include "Modules.h"
ss="cp">#include <QOpenGLExtraFunctions> class DemoWindow : public QOpenGLWidget, private QOpenGLExtraFunctions { protected: void initializeGL() override { initializeOpenGLFunctions(); QtImGui::initialize(this); } void paintGL() override { QtImGui::newFrame(); // 1. Show a simple window // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug" { static float f = 0.0f; ImGui::Text("Hello, world!"); ImGui::SliderFloat("float", &f, 0.0f, 1.0f); ImGui::ColorEdit3("clear color", (float*)&clear_color); if (ImGui::Button("Test Window")) show_test_window ^= 1; if (ImGui::Button("Another Window")) show_another_window ^= 1; ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); } // 2. Show another simple window, this time using an explicit Begin/End pair if (show_another_window) { ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver); ImGui::Begin("Another Window", &show_another_window); ImGui::Text("Hello"); ImGui::End(); } // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow() if (show_test_window) { ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver); ImGui::ShowTestWindow(); } // Do render before ImGui UI is rendered glViewport(0, 0, width(), height()); glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w); glClear(GL_COLOR_BUFFER_BIT); ImGui::Render(); } private: bool show_test_window = true; bool show_another_window = false; ImVec4 clear_color = ImColor(114, 144, 154); }; int main(int argc, char *argv[]) { // Use OpenGL 3 Core Profile QSurfaceFormat glFormat; glFormat.setVersion(3, 3); glFormat.setProfile(QSurfaceFormat::CoreProfile); QSurfaceFormat::setDefaultFormat(glFormat); QApplication a(argc, argv); // Show window DemoWindow w; w.setWindowTitle("QtImGui widget example"); w.resize(1280, 720); w.show(); // Update at 60 fps QTimer timer; QObject::connect(&timer, SIGNAL(timeout()), &w, SLOT(update())); timer.start(16); return a.exec(); }