Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't flip 2D textures on load, required for texelFetch #232

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/SHADERed/Engine/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace ed {

// read file via ASSIMP
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs);
const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate);

// check for errors
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) // if is Not Zero
Expand Down
4 changes: 2 additions & 2 deletions src/SHADERed/Objects/ObjectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ namespace ed {
height = ddsImage->header.height;
} else {
int nrChannels = 0;
stbi_set_flip_vertically_on_load(1);
stbi_set_flip_vertically_on_load(0);
data = stbi_load(path.c_str(), &width, &height, &nrChannels, STBI_rgb_alpha);
}

Expand Down Expand Up @@ -793,7 +793,7 @@ namespace ed {

bool ObjectManager::ReloadTexture(ObjectManagerItem* item, const std::string& newPath)
{
stbi_set_flip_vertically_on_load(1);
stbi_set_flip_vertically_on_load(0);

for (int i = 0; i < m_items.size(); i++) {
if (m_items[i] == item) {
Expand Down
9 changes: 6 additions & 3 deletions src/SHADERed/Objects/RenderEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2192,16 +2192,19 @@ namespace ed {
m_msgs->Add(MessageStack::Type::Error, items[i]->Name, "Failed to compile the shader");
m_shaders[i] = 0;
} else {
m_msgs->ClearGroup(items[i]->Name);

m_shaders[i] = glCreateProgram();
glAttachShader(m_shaders[i], vs);
glAttachShader(m_shaders[i], ps);
if (data->GSUsed) glAttachShader(m_shaders[i], gs);
if (data->TSUsed) glAttachShader(m_shaders[i], tcs);
if (data->TSUsed) glAttachShader(m_shaders[i], tes);
glLinkProgram(m_shaders[i]);
// XXX TODO check link status

if (!gl::CheckShaderLinkStatus(m_shaders[i], shaderMessage)) {
m_msgs->Add(MessageStack::Type::Error, items[i]->Name, shaderMessage);
m_msgs->Add(MessageStack::Type::Error, items[i]->Name, "Failed to link the shader");
} else
m_msgs->ClearGroup(items[i]->Name);

m_debugShaders[i] = glCreateProgram();
glAttachShader(m_debugShaders[i], m_generalDebugShader);
Expand Down
4 changes: 4 additions & 0 deletions src/SHADERed/UI/ObjectListUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ namespace ed {
if (oItem->Type == ObjectType::CubeMap) {
m_cubePrev.Draw(tex);
ImGui::Image((void*)(intptr_t)m_cubePrev.GetTexture(), ImVec2(IMAGE_CONTEXT_WIDTH, ((float)imgWH) * IMAGE_CONTEXT_WIDTH), ImVec2(0, 1), ImVec2(1, 0));
} else if (oItem->Type == ObjectType::Texture) {
ImGui::Image(*(void **)&tex, ImVec2(IMAGE_CONTEXT_WIDTH, ((float)imgWH) * IMAGE_CONTEXT_WIDTH));
} else if (!isBuf && !isImg3D && !isPluginOwner)
ImGui::Image((void*)(intptr_t)tex, ImVec2(IMAGE_CONTEXT_WIDTH, ((float)imgWH) * IMAGE_CONTEXT_WIDTH), ImVec2(0, 1), ImVec2(1, 0));
else if (hasPluginPreview)
Expand All @@ -105,6 +107,8 @@ namespace ed {
m_tex3DPrev.Draw(tex, IMAGE_CONTEXT_WIDTH, ((float)imgWH) * IMAGE_CONTEXT_WIDTH);
ImGui::Image((void*)(intptr_t)m_tex3DPrev.GetTexture(), ImVec2(IMAGE_CONTEXT_WIDTH, ((float)imgWH) * IMAGE_CONTEXT_WIDTH));
}
else if (oItem->Type == ObjectType::Texture)
ImGui::Image(*(void **)&tex, ImVec2(IMAGE_CONTEXT_WIDTH, ((float)imgWH) * IMAGE_CONTEXT_WIDTH));
else if (!isBuf && !isImg3D && !isPluginOwner)
ImGui::Image((void*)(intptr_t)tex, ImVec2(IMAGE_CONTEXT_WIDTH, ((float)imgWH) * IMAGE_CONTEXT_WIDTH), ImVec2(0, 1), ImVec2(1, 0));
else if (hasPluginPreview)
Expand Down
4 changes: 2 additions & 2 deletions src/SHADERed/UI/ObjectPreviewUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ namespace ed {

const glm::vec2& zPos = m_zoom[i].GetZoomPosition();
const glm::vec2& zSize = m_zoom[i].GetZoomSize();
ImGui::Image((void*)(intptr_t)item->Texture, aSize, ImVec2(zPos.x, zPos.y + zSize.y), ImVec2(zPos.x + zSize.x, zPos.y));

ImGui::Image(*(void **)&item->Texture, aSize, ImVec2(zPos.x, zPos.y), ImVec2(zPos.x + zSize.x, zPos.y + zSize.y));

if (ImGui::IsItemHovered()) {
m_curHoveredItem = i;
Expand Down