-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The GameUI manager and element class has been created and now u can draw an element form GameUI
- Loading branch information
ferran coma rosell
committed
Mar 7, 2018
1 parent
fb01722
commit 949e250
Showing
12 changed files
with
168 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "Globals.h" | ||
#include "Application.h" | ||
#include "ElementGameUI.h" | ||
|
||
ElementGameUI::ElementGameUI(TypeElemeneGametUI typeElement, int x, int y, int h, int w, bool isVisible) | ||
{ | ||
type = typeElement; | ||
visible = isVisible; | ||
rect.x = x; | ||
rect.y = y; | ||
rect.h = h; | ||
rect.w = w; | ||
} | ||
|
||
ElementGameUI::~ElementGameUI() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef __ELEMENTGAMEUI_H__ | ||
#define __ELEMENTGAMEUI_H__ | ||
|
||
#include "Module.h" | ||
#include <string> | ||
|
||
class ElementGameUI | ||
{ | ||
public: | ||
ElementGameUI(TypeElemeneGametUI typeElement, int x, int y, int h, int w, bool isVisible = true); | ||
~ElementGameUI(); | ||
|
||
public: | ||
TypeElemeneGametUI type; | ||
SDL_Rect rect; | ||
bool visible; | ||
}; | ||
|
||
#endif // __ELEMENTGAMEUI_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "Globals.h" | ||
#include "Application.h" | ||
#include "ModuleSceneMain.h" | ||
#include "ModuleWindow.h" | ||
#include "ModuleGameUI.h" | ||
#include "ModuleCamera.h" | ||
#include "CameraComponent.h" | ||
#include "ElementGameUI.h" | ||
#include "Shader.h" | ||
#include "Glew/include/glew.h" | ||
#include "MathGeoLib/src/Math/float4x4.h" | ||
|
||
ModuleGameUI::ModuleGameUI() | ||
{ | ||
//TO_DEBUG | ||
ElementGameUI* element = new ElementGameUI(BUTTON, 0, 0, 200, 200); | ||
elements.push_back(element); | ||
//END_DEBUG | ||
} | ||
|
||
ModuleGameUI::~ModuleGameUI() {} | ||
|
||
update_status ModuleGameUI::update(float deltaTime) | ||
{ | ||
printGameUI(); | ||
return UPDATE_CONTINUE; | ||
} | ||
|
||
void ModuleGameUI::printGameUI() | ||
{ | ||
//TODO: Not working yet | ||
glOrtho(-1.0, 1.0, -1.0, 1.0, 5, 100); | ||
glMatrixMode(GL_MODELVIEW); | ||
|
||
for (vector<ElementGameUI*>::iterator it = elements.begin(); it != elements.end(); ++it) | ||
{ | ||
if ((*it)->visible) | ||
{ | ||
/*GLuint program = App->sceneMain->shader->programs[App->sceneMain->shader->defaultShaders[DEFAULTSHADER]]; | ||
glUseProgram(program); | ||
float4x4 identity = float4x4::identity; | ||
GLint modelLoc = glGetUniformLocation(program, "model_matrix"); | ||
glUniformMatrix4fv(modelLoc, 1, GL_FALSE, &identity[0][0]); | ||
GLint viewLoc = glGetUniformLocation(program, "view"); | ||
glUniformMatrix4fv(viewLoc, 1, GL_FALSE, App->camera->getViewMatrix()); | ||
GLint projectLoc = glGetUniformLocation(program, "projection"); | ||
glUniformMatrix4fv(projectLoc, 1, GL_FALSE, App->camera->getProjectMatrix()); | ||
float3 cameraPos = App->camera->currentCamera->frustum.pos;*/ | ||
|
||
float x1 = (float)((*it)->rect.x); | ||
float x2 = (float)((*it)->rect.x + (*it)->rect.w); | ||
float y1 = (float)((*it)->rect.y); | ||
float y2 = (float)((*it)->rect.y + (*it)->rect.h); | ||
|
||
glBegin(GL_POLYGON); | ||
glVertex2f(x1, y1); | ||
glVertex2f(x2, y1); | ||
glVertex2f(x2, y2); | ||
glVertex2f(x1, y2); | ||
glEnd(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef __MODULEGAMEUI_H__ | ||
#define __MODULEGAMEUI_H__ | ||
|
||
#include "Module.h" | ||
#include <vector> | ||
|
||
using namespace std; | ||
|
||
class ElementGameUI; | ||
|
||
class ModuleGameUI : public Module | ||
{ | ||
public: | ||
ModuleGameUI(); | ||
~ModuleGameUI(); | ||
update_status update(float deltaTime) override; | ||
|
||
|
||
public: | ||
vector<ElementGameUI*> elements; | ||
|
||
private: | ||
void printGameUI(); | ||
|
||
|
||
}; | ||
|
||
#endif // __MODULEGAMEUI_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters