Skip to content

Commit

Permalink
Solved Alpha blend bug with UIElements
Browse files Browse the repository at this point in the history
  • Loading branch information
Guriva committed Mar 14, 2018
1 parent c1cc04c commit 5eecc1b
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 32 deletions.
2 changes: 1 addition & 1 deletion LCSEngine/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Application::Application()
modules.push_back(json = new ModuleJson());
modules.push_back(camera = new ModuleCamera());
modules.push_back(renderer = new ModuleRender());
modules.push_back(gameUI = new ModuleGameUI());
modules.push_back(gui = new ModuleGUI());
modules.push_back(textures = new ModuleTextures());
modules.push_back(audio = new ModuleAudio());
modules.push_back(fade = new ModuleFadeToBlack());
modules.push_back(animations = new ModuleAnimation());
modules.push_back(sceneMain = new ModuleSceneMain(false));
modules.push_back(gameUI = new ModuleGameUI());
modules.push_back(type = new ModuleType());

timer = 0;
Expand Down
6 changes: 0 additions & 6 deletions LCSEngine/ModuleGameUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ ModuleGameUI::ModuleGameUI() {}

ModuleGameUI::~ModuleGameUI() {}

update_status ModuleGameUI::update(float deltaTime)
{
printGameUI();
return UPDATE_CONTINUE;
}

void ModuleGameUI::printGameUI()
{
GLuint program = App->sceneMain->shader->programs[App->sceneMain->shader->defaultShaders[DEFAULTSHADER]];
Expand Down
7 changes: 1 addition & 6 deletions LCSEngine/ModuleGameUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@ class ModuleGameUI : public Module
public:
ModuleGameUI();
~ModuleGameUI();
update_status update(float deltaTime) override;

void printGameUI();

public:
vector<ElementGameUI*> elements;

private:
void printGameUI();


};

#endif // __MODULEGAMEUI_H__
6 changes: 3 additions & 3 deletions LCSEngine/ModuleRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "ModuleGUI.h"
#include "ModuleSceneMain.h"
#include "ModuleCamera.h"
#include "ModuleGameUI.h"
#include "Shader.h"
#include "SDL/include/SDL.h"
#include "Glew/include/glew.h"
Expand Down Expand Up @@ -56,12 +57,12 @@ bool ModuleRender::init()
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glClearDepth(1.0f);
glClearColor(0.f, 0.f, 0.f, 1.f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
//glEnable(GL_LIGHTING);
//glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_TEXTURE_2D);
glFrontFace(GL_CCW);
glCullFace(GL_BACK);
Expand Down Expand Up @@ -95,9 +96,8 @@ update_status ModuleRender::postUpdate(float deltaTime)
renderObjects();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
App->gui->draw();
App->gameUI->printGameUI();
//SDL_GL_SwapWindow(App->window->window);


swap();
return UPDATE_CONTINUE;
}
Expand Down
3 changes: 1 addition & 2 deletions LCSEngine/ProjectDir/Assets/Shaders/fragshader.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ uniform bool useText;

void main()
{
float myColor = 1.f;
if (useText)
{
color = vec4(texture(text, UV).rgb * col, 1.0f);
color = vec4(texture(text,UV).rgb * col, texture(text,UV).a);
}
else
{
Expand Down
14 changes: 0 additions & 14 deletions LCSEngine/UIImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ void UIImage::init()
float x1 = (float)((rect.x / screenWidth) * 2) - 1;
float x2 = (float)(x1 + (rect.w / screenWidth) * 2);
float y1 = (float)(2 - ((rect.y / screenHeight) * 2) - 1);
//float y2 = (float)(2 - (y1 + ((*it)->rect.h) / (screenHeight / 2)));
float y2 = (float)(y1 - (rect.h / screenHeight) * 2);

verticesVBO.push_back(float3(x1, y1, 0.f));
Expand All @@ -94,18 +93,6 @@ void UIImage::init()
texCoordsVBO.push_back(float2(0.f, 0.f));
texCoordsVBO.push_back(float2(1.f, 0.f));
texCoordsVBO.push_back(float2(1.f, 1.f));

/*verticesVBO = { float3(-1 / 2.f, 1 / 2.f, 1 / 2.f), float3(1 / 2.f, 1 / 2.f, 1 / 2.f),
float3(1 / 2.f, -1 / 2.f, 1 / 2.f), float3(-1 / 2.f, -1 / 2.f, 1 / 2.f),
float3(-1 / 2.f, 1 / 2.f, -1 / 2.f), float3(1 / 2.f, 1 / 2.f, -1 / 2.f),
float3(1 / 2.f, -1 / 2.f, -1 / 2.f), float3(-1 / 2.f, -1 / 2.f, -1 / 2.f) };
indicesVAO = { 1, 3, 2, 1, 0, 3,
0, 7, 3, 0, 4, 7,
5, 2, 6, 5, 1, 2,
5, 0, 1, 5, 4, 0,
2, 7, 6, 2, 3, 7,
4, 6, 7, 4, 5, 6 };*/
}

void UIImage::generateIDs()
Expand Down Expand Up @@ -142,7 +129,6 @@ void UIImage::updateCoords()
float x1 = (float)((rect.x / screenWidth) * 2) - 1;
float x2 = (float)(x1 + (rect.w / screenWidth) * 2);
float y1 = (float)(2 - ((rect.y / screenHeight) * 2) - 1);
//float y2 = (float)(2 - (y1 + ((*it)->rect.h) / (screenHeight / 2)));
float y2 = (float)(y1 - (rect.h / screenHeight) * 2);

verticesVBO.clear();
Expand Down

0 comments on commit 5eecc1b

Please sign in to comment.