Skip to content

Commit

Permalink
Lums 2.3.0 - Better API, Cleaner tests & examples, singleton Core, go…
Browse files Browse the repository at this point in the history
…od png support
  • Loading branch information
Maxime committed Jan 17, 2015
1 parent d96eed7 commit 7bced71
Show file tree
Hide file tree
Showing 55 changed files with 687 additions and 1,133 deletions.
360 changes: 21 additions & 339 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -33,9 +33,9 @@ Because of this.

![A lums](http://raymanpc.com/wiki/script-en/images/f/f6/YellowLum-RR-TheWoodsofLight.jpg)

## Some boring legal stuff
## License

This software is under the GPLv2 license.
This software is under the MIT license.
You may find a copy of the license along with this software.

## Author
Expand Down
46 changes: 34 additions & 12 deletions example/01_Cube/Cube.cpp
@@ -1,9 +1,23 @@
#include "Cube.h"
/* ************************************************************************** */
/* */
/* */
/* Cube.cpp oooooo oooooo */
/* oooooooooo oooooooooo */
/* o%%%%%o */
/* %:::::% */
/* %:::::::% */
/* This file is part of the %:::::% */
/* Lums library. %%%%% */
/* */
/* ************************************************************************** */

#include "Cube.hpp"
#include <iostream>

using namespace lm;

const GLfloat vertices[] = {
const static GLfloat
vertices[] = {
1, 1, 1,
1, 1, -1,
1, -1, 1,
Expand All @@ -14,7 +28,8 @@ const GLfloat vertices[] = {
-1, -1, -1
};

const GLfloat colors[] = {
const static GLfloat
colors[] = {
1, 0, 0,
0, 1, 0,
0, 0, 1,
Expand All @@ -25,7 +40,8 @@ const GLfloat colors[] = {
1, 1, 1
};

const GLubyte indices[] = {
const static GLubyte
indices[] = {
0, 2, 6, 3,
3, 5, 7, 6,
5, 1, 4, 7,
Expand All @@ -34,33 +50,37 @@ const GLubyte indices[] = {
2, 4, 7, 6
};

Cube::Cube(lm::Core* core) : lm::GameState(core), speed(10, 0)
Cube::Cube()
: speed(10, 0)
{

}

void Cube::load()
void
Cube::load()
{
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPerspective(70, 1.333f, 0.001f, 100.0f);
glMatrixMode(GL_MODELVIEW);
}

void Cube::update()
void
Cube::update()
{
angle.x += 0.1_deg * speed.x;
angle.y += 0.1_deg * speed.y;
}

void Cube::handleEvent(const Event& event)
void
Cube::handleEvent(const Event& event)
{
if (event.type == Event::Type::KeyDown)
{
switch (event.key)
{
case Key::Escape:
Core().stop();
Core::get().stop();
break;
case Key::Right:
speed.x++;
Expand All @@ -80,7 +100,8 @@ void Cube::handleEvent(const Event& event)
}
}

void Cube::render()
void
Cube::render() const
{
glLookAt(-2, 2, -2, 0, 0, 0, 0, 1, 0);
glRotatef(angle.x.toDegrees(), 0, 1, 0);
Expand All @@ -95,7 +116,8 @@ void Cube::render()

}

void Cube::unload()
void
Cube::unload()
{
glDisable(GL_DEPTH_TEST);
}
}
21 changes: 0 additions & 21 deletions example/01_Cube/Cube.h

This file was deleted.

34 changes: 34 additions & 0 deletions example/01_Cube/Cube.hpp
@@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* */
/* Cube.hpp oooooo oooooo */
/* oooooooooo oooooooooo */
/* o%%%%%o */
/* %:::::% */
/* %:::::::% */
/* This file is part of the %:::::% */
/* Lums library. %%%%% */
/* */
/* ************************************************************************** */

#ifndef CUBE_HPP
#define CUBE_HPP

#include <Lums/Lums.hpp>

class Cube : public lm::GameState
{
public:
Cube();
void load();
void update();
void handleEvent(const lm::Event& event);
void render() const;
void unload();

private:
lm::Vector2a angle;
lm::Vector2f speed;
};

#endif
20 changes: 17 additions & 3 deletions example/01_Cube/main.cpp
@@ -1,10 +1,24 @@
#include "Cube.h"
/* ************************************************************************** */
/* */
/* */
/* main.cpp oooooo oooooo */
/* oooooooooo oooooooooo */
/* o%%%%%o */
/* %:::::% */
/* %:::::::% */
/* This file is part of the %:::::% */
/* Lums library. %%%%% */
/* */
/* ************************************************************************** */

#include "Cube.hpp"

using namespace lm;

int main()
int
main()
{
Core gl(800, 600, "Cube");
Core gl(800, 600, "Cube");

gl.push<Cube>();
gl.start();
Expand Down
4 changes: 4 additions & 0 deletions example/02_Nyan/CMakeLists.txt
@@ -0,0 +1,4 @@
file(GLOB SRC "*.cpp")
add_executable(02_Nyan ${SRC})
configure_file(Nyan.png Nyan.png COPYONLY)
target_link_libraries(02_Nyan Lums_shared)
23 changes: 18 additions & 5 deletions example/03_Nyan/Nyan.cpp → example/02_Nyan/Nyan.cpp
@@ -1,10 +1,23 @@
#include <Lums/Lums.h>
/* ************************************************************************** */
/* */
/* */
/* Nyan.cpp oooooo oooooo */
/* oooooooooo oooooooooo */
/* o%%%%%o */
/* %:::::% */
/* %:::::::% */
/* This file is part of the %:::::% */
/* Lums library. %%%%% */
/* */
/* ************************************************************************** */

#include <Lums/Lums.hpp>

class Nyan : public lm::GameState
{
public:
Nyan(lm::Core* core)
: lm::GameState(core), _linear(true)
Nyan()
: _linear(true)
{
_image.loadFile("Nyan.png");
}
Expand All @@ -26,12 +39,12 @@ class Nyan : public lm::GameState
_image.linear(_linear);
}
else
Core().stop();
lm::Core::get().stop();
}
}

void
render()
render() const
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
Expand Down
File renamed without changes
3 changes: 0 additions & 3 deletions example/02_Platformer/CMakeLists.txt

This file was deleted.

52 changes: 0 additions & 52 deletions example/02_Platformer/Game.cpp

This file was deleted.

23 changes: 0 additions & 23 deletions example/02_Platformer/Game.h

This file was deleted.

0 comments on commit 7bced71

Please sign in to comment.