Browse Source

Added imgui test integration

I will be cleaning it up
master
Macoy Madson 1 year ago
parent
commit
8aa088aa6c
3 changed files with 122 additions and 2 deletions
  1. +14
    -1
      Jamfile
  2. +24
    -1
      Jamrules
  3. +84
    -0
      tests/main.cpp

+ 14
- 1
Jamfile View File

@ -54,4 +54,17 @@ Library libBase20 : dataStructures/pool.cpp
MakeLocate libBase20 : lib ;
MakeLocate Base20Pseudotarget : bin ;
MakeLocate Base20Pseudotarget : bin ;
#
# Tests
#
Main TestBase20 : tests/main.cpp
../../3rdParty/repositories/imgui/imgui.cpp
../../3rdParty/repositories/imgui/imgui_demo.cpp
../../3rdParty/repositories/imgui/imgui_widgets.cpp
../../3rdParty/repositories/imgui/imgui_draw.cpp
../../3rdParty/repositories/imgui-sfml/imgui-SFML.cpp
;
LinkLibraries TestBase20 : libBase20 ;

+ 24
- 1
Jamrules View File

@ -21,6 +21,7 @@ CC = gcc ;
# Clang
C++ = clang++ ;
LINK = clang++ ;
# LINK = ld ;
##
## Compiler arguments
@ -43,7 +44,7 @@ LINK = clang++ ;
# lstdc++ = standard library [Unused]
# Arguments used on all projects, regardless of any variables
C++FLAGS = -std=c++11 -Wall -Wextra -Wno-unused-parameter ;
C++FLAGS = -std=c++11 -Wall -Wextra -Wno-unused-parameter -D IMGUI_INCLUDE_IMCONFIG_H ;
# Required arguments for tests
TESTSC++FLAGS = -g ;
@ -51,6 +52,28 @@ ALLLIBSC++FLAGS = $(TESTSC++FLAGS) ;
OPTIM = -O0 ;
HDRS =
../../3rdParty/repositories/SFML/include
../../3rdParty/repositories/imgui
../../3rdParty/repositories/imgui-sfml
;
LINKFLAGS = --verbose
-Wl,-rpath,.:../../3rdParty/repositories/SFML/lib
;
# This is for test executables, not the lib. You can use this as reference for your own executables
LINKLIBS =
# SFML
-L../../3rdParty/repositories/SFML/lib
-lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system
# OpenGL
-lGL
-lGLU
-lGLEW
;
# HDRS = thirdParty/flatbuffers/include src ;
# TODO: add project-specific filetype rules for things like flatbuffer .json compilation (see "UserObject rule":


+ 84
- 0
tests/main.cpp View File

@ -0,0 +1,84 @@
#include <iostream>
#include "graphics/graphics.hpp"
#include "input/input.hpp"
int WindowWidth = 1920;
int WindowHeight = 1080;
#define WIN_BACKGROUND_COLOR 20, 20, 20, 255
void windowResizeCB(float width, float height)
{
WindowWidth = width;
WindowHeight = height;
}
int main2();
int main()
{
return main2();
// window mainWindow(WindowWidth, WindowHeight, "Base 2.0 Test", &windowResizeCB);
// {
// mainWindow.setBackgroundColor(WIN_BACKGROUND_COLOR);
// // shouldClose manages some state
// mainWindow.shouldClose();
// mainWindow.update();
// mainWindow.shouldClear(true);
// mainWindow.getBase()->setVerticalSyncEnabled(true);
// mainWindow.getBase()->setFramerateLimit(60);
// }
// inputManager input(&mainWindow);
// while (!mainWindow.shouldClose() && !input.isPressed(inputCode::Escape))
// {
// }
}
#include "imgui.h"
#include "imgui-SFML.h"
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/System/Clock.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/Graphics/CircleShape.hpp>
int main2()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "ImGui + SFML = <3");
window.setFramerateLimit(60);
ImGui::SFML::Init(window);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
sf::Clock deltaClock;
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
ImGui::SFML::ProcessEvent(event);
if (event.type == sf::Event::Closed) {
window.close();
}
}
ImGui::SFML::Update(window, deltaClock.restart());
ImGui::ShowDemoWindow();
ImGui::Begin("Hello, world!");
ImGui::Button("Look at this pretty button");
ImGui::End();
window.clear();
window.draw(shape);
ImGui::SFML::Render(window);
window.display();
}
ImGui::SFML::Shutdown();
}

Loading…
Cancel
Save