SDRPlusPlus/src/icons.cpp

32 wiersze
1.1 KiB
C++
Czysty Zwykły widok Historia

2020-07-19 13:59:44 +00:00
#include <icons.h>
#define STB_IMAGE_IMPLEMENTATION
#include <imgui/stb_image.h>
namespace icons {
2020-07-19 16:09:59 +00:00
ImTextureID LOGO;
2020-07-19 13:59:44 +00:00
ImTextureID PLAY;
ImTextureID STOP;
2020-08-21 13:34:50 +00:00
ImTextureID MENU;
2020-07-19 13:59:44 +00:00
2020-09-06 13:39:09 +00:00
GLuint loadTexture(std::string path) {
2020-07-19 13:59:44 +00:00
int w,h,n;
2020-09-06 13:39:09 +00:00
stbi_uc* data = stbi_load(path.c_str(), &w, &h, &n, NULL);
2020-07-19 13:59:44 +00:00
GLuint texId;
glGenTextures(1, &texId);
glBindTexture(GL_TEXTURE_2D, texId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (uint8_t*)data);
stbi_image_free(data);
return texId;
}
void load() {
2020-09-06 13:39:09 +00:00
LOGO = (ImTextureID)loadTexture(config::getRootDirectory() + "/res/icons/sdrpp.png");
PLAY = (ImTextureID)loadTexture(config::getRootDirectory() + "/res/icons/play.png");
STOP = (ImTextureID)loadTexture(config::getRootDirectory() + "/res/icons/stop.png");
MENU = (ImTextureID)loadTexture(config::getRootDirectory() + "/res/icons/menu.png");
2020-07-19 13:59:44 +00:00
}
}