mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
Began writing the skeleton for the program.
This commit is contained in:
parent
c0e9683f45
commit
cf77599950
18
Makefile
Normal file
18
Makefile
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
CC=g++
|
||||||
|
CFLAGS=-c -Wall
|
||||||
|
LDFLAGS=-lSDL
|
||||||
|
SRCSOURCES=main.cpp Renderer.cpp GuiComponent.cpp
|
||||||
|
SOURCES=$(addprefix src/,$(SRCSOURCES))
|
||||||
|
OBJECTS=$(SOURCES:.cpp=.o)
|
||||||
|
EXECUTABLE=emulationstation
|
||||||
|
|
||||||
|
all: $(SOURCES) $(EXECUTABLE)
|
||||||
|
|
||||||
|
$(EXECUTABLE): $(OBJECTS)
|
||||||
|
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
.cpp.o:
|
||||||
|
$(CC) $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf *o $(EXECUTABLE)
|
12
src/GuiComponent.cpp
Normal file
12
src/GuiComponent.cpp
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#include "GuiComponent.h"
|
||||||
|
#include "Renderer.h"
|
||||||
|
|
||||||
|
GuiComponent::GuiComponent()
|
||||||
|
{
|
||||||
|
Renderer::registerComponent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiComponent::~GuiComponent()
|
||||||
|
{
|
||||||
|
Renderer::unregisterComponent(this);
|
||||||
|
}
|
13
src/GuiComponent.h
Normal file
13
src/GuiComponent.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef _GUICOMPONENT_H_
|
||||||
|
#define _GUICOMPONENT_H_
|
||||||
|
|
||||||
|
class GuiComponent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiComponent();
|
||||||
|
~GuiComponent();
|
||||||
|
virtual void render() { };
|
||||||
|
virtual unsigned int getLayer() { return 0; };
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
31
src/Renderer.cpp
Normal file
31
src/Renderer.cpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#include "Renderer.h"
|
||||||
|
|
||||||
|
void Renderer::registerComponent(GuiComponent* comp)
|
||||||
|
{
|
||||||
|
renderVector.push_back(comp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::unregisterComponent(GuiComponent* comp)
|
||||||
|
{
|
||||||
|
for(unsigned int i = 0; i < renderVector.size(); i++)
|
||||||
|
{
|
||||||
|
if(renderVector.at(i) == comp)
|
||||||
|
{
|
||||||
|
renderVector.erase(renderVector.begin() + i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::render()
|
||||||
|
{
|
||||||
|
for(unsigned int layer = 0; layer < LAYER_COUNT; layer++)
|
||||||
|
{
|
||||||
|
unsigned int layerBit = BIT(layer);
|
||||||
|
for(unsigned int i = 0; i < renderVector.size(); i++)
|
||||||
|
{
|
||||||
|
if(renderVector.at(i)->getLayer() & layerBit)
|
||||||
|
renderVector.at(i)->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
src/Renderer.h
Normal file
20
src/Renderer.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#ifndef _RENDERER_H_
|
||||||
|
#define _RENDERER_H_
|
||||||
|
|
||||||
|
#define LAYER_COUNT 3
|
||||||
|
|
||||||
|
#define BIT(x) (1 << (x))
|
||||||
|
|
||||||
|
#include "GuiComponent.h"
|
||||||
|
#include <vector>
|
||||||
|
namespace Renderer
|
||||||
|
{
|
||||||
|
void registerComponent(GuiComponent* comp);
|
||||||
|
void unregisterComponent(GuiComponent* comp);
|
||||||
|
|
||||||
|
void render();
|
||||||
|
|
||||||
|
std::vector<GuiComponent*> renderVector;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
18
src/main.cpp
Normal file
18
src/main.cpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <SDL/SDL.h>
|
||||||
|
#include "Renderer.h"
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0)
|
||||||
|
{
|
||||||
|
std::cerr << "Error - could not initialize SDL!\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SDL_Quit();
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue