forked from Rinnegatamante/imgui-vita
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
143 lines (120 loc) · 4.42 KB
/
main.cpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// ImGui - standalone example application for SDL2 + OpenGL
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
// **Prefer using the code in the sdl_opengl3_example/ folder**
// See imgui_impl_sdl.cpp for details.
#include <imgui_vita.h>
#include <stdio.h>
#include <vitaGL.h>
enum BT_WIN {
BT_WIN_SEARCH,
BT_WIN_BROWSE,
BT_WIN_UPDATE
};
int main(int, char**)
{
sceClibPrintf("starting up\n");
vglInit(0x100000);
// Setup ImGui binding
sceClibPrintf("creating context\n");
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
ImGui_ImplVitaGL_Init();
// Setup style
sceClibPrintf("setting style\n");
ImGui::StyleColorsDark();
sceClibPrintf("getting style\n");
ImGuiStyle &style = ImGui::GetStyle();
// Window styling
style.WindowBorderSize = 0.0f;
style.WindowRounding = 0.0f;
style.WindowPadding = ImVec2(10.0f, 10.0f);
// General styling
style.FrameBorderSize = 0.0f;
style.FrameRounding = 5.0f;
style.FramePadding = ImVec2(5.0f, 5.0f);
// Load font
io.Fonts->AddFontFromFileTTF("ux0:app/IMGUI0001/font.ttf", 30.0f);
enum BT_WIN current_window = BT_WIN_BROWSE;
ImGuiWindowFlags fullscreenFlags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoBringToFrontOnFocus;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
const char* categories[] = {
"All",
"Ports",
"Games",
"Emulators",
"Utilities"
};
static int current_category = 0;
const char* apps[] = {
"Adrenaline",
"VHBB",
"vitaQuakeIII",
"vitaHexen",
"VitaShell",
"ScummVM"
};
static int selected_app = 0;
// Main loop
bool done = false;
while (!done)
{
vglStartRendering();
ImGui_ImplVitaGL_NewFrame();
// BEGIN: Header
ImGui::SetNextWindowPos(ImVec2(0, 0));
ImGui::SetNextWindowSize(ImVec2(io.DisplaySize.x, io.DisplaySize.y));
ImGui::Begin("Main Window", NULL, fullscreenFlags);
ImVec2 headerButtonSize = ImVec2(200.0f, 75.0f);
// This is effectively a poor man's tab bar, but ImGui doesn't have native tabs yet
ImGui::Columns(3, "tabbar", false);
if (ImGui::Button("Browse", headerButtonSize)) current_window = BT_WIN_BROWSE;
ImGui::NextColumn();
if (ImGui::Button("Search", headerButtonSize)) current_window = BT_WIN_SEARCH;
ImGui::NextColumn();
if (ImGui::Button("Updates", headerButtonSize)) current_window = BT_WIN_UPDATE;
ImGui::Columns(1);
ImGui::Spacing();
//ImGui::Dummy(ImVec2(0.0f, 5.0f));
// BEGIN: Contents
switch (current_window) {
case BT_WIN_SEARCH:
break;
default: // This is here so if something goes wrong, we default to showing the Browse page
current_window = BT_WIN_BROWSE;
case BT_WIN_BROWSE:
ImGui::Columns(2, "category", false);
ImGui::SetColumnWidth(-1, 200.0f);
ImGui::PushItemWidth(-1.0f);
ImGui::Text("Category:");
ImGui::PopItemWidth();
ImGui::NextColumn();
ImGui::PushItemWidth(-1.0f);
ImGui::Combo("##categories", ¤t_category, categories, IM_ARRAYSIZE(categories));
ImGui::Columns(1);
ImGui::Spacing();
//ImGui::Dummy(ImVec2(0.0f, 5.0f));
ImGui::PushItemWidth(-1.0f);
ImGui::ListBox("##apps", &selected_app, apps, IM_ARRAYSIZE(apps), 11);
break;
case BT_WIN_UPDATE:
break;
}
// BEGIN: Footer
ImGui::End();
// Rendering
glViewport(0, 0, (int)ImGui::GetIO().DisplaySize.x, (int)ImGui::GetIO().DisplaySize.y);
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);
//glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound
ImGui::Render();
ImGui_ImplVitaGL_RenderDrawData(ImGui::GetDrawData());
vglStopRendering();
}
// Cleanup
ImGui_ImplVitaGL_Shutdown();
ImGui::DestroyContext();
vglEnd();
return 0;
}