Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
|
3a07155756 | ||
e1a41a526d |
11 changed files with 48 additions and 37 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,3 +11,4 @@ tests/tests
|
||||||
*.swp
|
*.swp
|
||||||
*.core
|
*.core
|
||||||
vgcore*
|
vgcore*
|
||||||
|
.cache
|
||||||
|
|
|
@ -7,19 +7,19 @@ varying vec2 uv;
|
||||||
|
|
||||||
const int gaussRadius = 11;
|
const int gaussRadius = 11;
|
||||||
const float gaussFilter[gaussRadius] = float[gaussRadius](
|
const float gaussFilter[gaussRadius] = float[gaussRadius](
|
||||||
0.0402,0.0623,0.0877,0.1120,0.1297,0.1362,0.1297,0.1120,0.0877,0.0623,0.0402
|
0.0402,0.0623,0.0877,0.1120,0.1297,0.1362,0.1297,0.1120,0.0877,0.0623,0.0402
|
||||||
);
|
);
|
||||||
|
|
||||||
uniform vec2 scale;
|
uniform vec2 scale;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 texCoord = uv.xy - float(int(gaussRadius/2)) * scale;
|
vec2 texCoord = uv.xy - float(int(gaussRadius/2)) * scale;
|
||||||
vec3 color = vec3(0.0, 0.0, 0.0);
|
vec3 color = vec3(0.0, 0.0, 0.0);
|
||||||
for (int i=0; i<gaussRadius; ++i) {
|
for (int i=0; i<gaussRadius; ++i) {
|
||||||
color += gaussFilter[i] * texture2D(tex, texCoord).xyz;
|
color += gaussFilter[i] * texture2D(tex, texCoord).xyz-0.0002;
|
||||||
texCoord += scale;
|
texCoord += scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_FragColor = vec4(color, 1.0);
|
gl_FragColor = vec4(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,6 @@ class GameWindow : public endofthejedi::GLWindow {
|
||||||
|
|
||||||
void resize() override
|
void resize() override
|
||||||
{
|
{
|
||||||
std::cout<<"resize()" << std::endl;
|
|
||||||
|
|
||||||
glViewport(0, 0, getwidth(), getheight());
|
glViewport(0, 0, getwidth(), getheight());
|
||||||
|
|
||||||
// resize the game
|
// resize the game
|
||||||
|
|
|
@ -99,7 +99,15 @@ namespace endofthejedi {
|
||||||
m_width = attribs.width;
|
m_width = attribs.width;
|
||||||
m_height = attribs.height;
|
m_height = attribs.height;
|
||||||
resize();
|
resize();
|
||||||
|
} else if (event.type == ConfigureNotify) {
|
||||||
|
XConfigureEvent xce = event.xconfigure;
|
||||||
|
|
||||||
|
if ((unsigned int)xce.width != m_width||
|
||||||
|
(unsigned int)xce.height != m_height) {
|
||||||
|
m_width = xce.width;
|
||||||
|
m_height = xce.height;
|
||||||
|
resize();
|
||||||
|
}
|
||||||
} else if (event.type == ClientMessage) {
|
} else if (event.type == ClientMessage) {
|
||||||
if (event.xclient.data.l[0] == (int) m_atomWmDeleteWindow) {
|
if (event.xclient.data.l[0] == (int) m_atomWmDeleteWindow) {
|
||||||
stop();
|
stop();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "polygon_model.hpp"
|
#include "polygon_model.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
namespace endofthejedi {
|
namespace endofthejedi {
|
||||||
PolygonModel::PolygonModel(const std::string &filename)
|
PolygonModel::PolygonModel(const std::string &filename)
|
||||||
|
@ -99,9 +100,7 @@ namespace endofthejedi {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
aiNode *node = scene->mRootNode;
|
const aiMesh* mesh = scene->mMeshes[0];
|
||||||
const aiMesh* mesh = scene->mMeshes[node->mMeshes[0]];
|
|
||||||
|
|
||||||
// 3 vertices per face, 3 floats per vertex
|
// 3 vertices per face, 3 floats per vertex
|
||||||
m_numVertices = mesh->mNumFaces*3;
|
m_numVertices = mesh->mNumFaces*3;
|
||||||
|
|
||||||
|
|
|
@ -153,27 +153,25 @@ void RendererPolygon3d::setup() {
|
||||||
|
|
||||||
m_postprocess_fbo.attachTexture(GL_COLOR_ATTACHMENT0,
|
m_postprocess_fbo.attachTexture(GL_COLOR_ATTACHMENT0,
|
||||||
m_postprocess_tex0.getName());
|
m_postprocess_tex0.getName());
|
||||||
renderBackgroundImage();
|
renderBackgroundImage();
|
||||||
|
|
||||||
//float s = 0.1;
|
//float s = 0.1;
|
||||||
//glClearColor(s, s, 1.2*s, 1.0);
|
//glClearColor(s, s, 1.2*s, 1.0);
|
||||||
|
|
||||||
m_shader_game_objects.bind();
|
m_shader_game_objects.bind();
|
||||||
|
|
||||||
// TODO: add ONE sun planet
|
// TODO: add ONE sun planet
|
||||||
// TODO: add lights for explosions
|
// TODO: add lights for explosions
|
||||||
|
|
||||||
configureLightningInShader(&m_shader_game_objects);
|
configureLightningInShader(&m_shader_game_objects);
|
||||||
|
|
||||||
//std::cout<<"setting aspect ratio: " << m_aspectRatio << std::endl;
|
//std::cout<<"setting aspect ratio: " << m_aspectRatio << std::endl;
|
||||||
|
|
||||||
renderPlanets();
|
renderPlanets();
|
||||||
renderShips();
|
renderShips();
|
||||||
renderMissiles();
|
renderMissiles();
|
||||||
|
renderParticles();
|
||||||
renderParticles();
|
renderTraces();
|
||||||
|
|
||||||
renderTraces();
|
|
||||||
|
|
||||||
glUniform1f(m_shader_game_objects.location("aspectRatio"), m_aspectRatio);
|
glUniform1f(m_shader_game_objects.location("aspectRatio"), m_aspectRatio);
|
||||||
m_postprocess_tex1.bind();
|
m_postprocess_tex1.bind();
|
||||||
|
@ -184,14 +182,12 @@ void RendererPolygon3d::setup() {
|
||||||
m_shader_game_objects.bind();
|
m_shader_game_objects.bind();
|
||||||
configureLightningInShader(&m_shader_game_objects);
|
configureLightningInShader(&m_shader_game_objects);
|
||||||
glUniform1f(m_shader_game_objects.location("aspectRatio"), m_aspectRatio);
|
glUniform1f(m_shader_game_objects.location("aspectRatio"), m_aspectRatio);
|
||||||
|
|
||||||
renderPlanets();
|
renderPlanets();
|
||||||
renderShips();
|
renderShips();
|
||||||
renderMissiles();
|
renderMissiles();
|
||||||
|
|
||||||
renderParticles();
|
renderParticles();
|
||||||
|
|
||||||
renderTraces();
|
|
||||||
|
|
||||||
// postprocessing
|
// postprocessing
|
||||||
m_postprocess_shader.bind();
|
m_postprocess_shader.bind();
|
||||||
//glColor3f(1.0, 0.0, 0.0);
|
//glColor3f(1.0, 0.0, 0.0);
|
||||||
|
@ -520,6 +516,10 @@ void RendererPolygon3d::renderPlanets() {
|
||||||
m_planetModel->render();
|
m_planetModel->render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void RendererPolygon3d::renderSun() {
|
void RendererPolygon3d::renderSun() {
|
||||||
m_planetModel->bind();
|
m_planetModel->bind();
|
||||||
|
@ -553,8 +553,8 @@ void RendererPolygon3d::renderMissiles() {
|
||||||
m_missileModel->bind();
|
m_missileModel->bind();
|
||||||
|
|
||||||
for (const game::Missile *missile : m_missiles) {
|
for (const game::Missile *missile : m_missiles) {
|
||||||
glm::vec3 c = glm::vec3(1.0, 1.0, 0.3);
|
glm::vec3 c = glm::vec3(missile->color);
|
||||||
glUniform3f(m_shader_game_objects.location("materialColor"), c.x, c.y, c.z);
|
glUniform3f(m_shader_game_objects.location("materialColor"), c.x/2, c.y/2, c.z/2);
|
||||||
|
|
||||||
// TODO: rename functions so their name represents what args they
|
// TODO: rename functions so their name represents what args they
|
||||||
// take
|
// take
|
||||||
|
@ -665,6 +665,7 @@ void RendererPolygon3d::renderMissiles() {
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
|
|
||||||
// TODO dont use line mode. make that with own quads
|
// TODO dont use line mode. make that with own quads
|
||||||
|
|
||||||
glPolygonMode(GL_FRONT, GL_LINE);
|
glPolygonMode(GL_FRONT, GL_LINE);
|
||||||
for (const game::Trace *trace : m_state->traces) {
|
for (const game::Trace *trace : m_state->traces) {
|
||||||
float fade_out = 1.0;
|
float fade_out = 1.0;
|
||||||
|
@ -680,7 +681,7 @@ void RendererPolygon3d::renderMissiles() {
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
glLineWidth(1.0f);
|
glLineWidth(1.0f);
|
||||||
glPolygonMode(GL_FRONT, GL_FILL);
|
glPolygonMode(GL_FRONT, GL_FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ namespace endofthejedi {
|
||||||
void renderMissiles();
|
void renderMissiles();
|
||||||
void renderShips();
|
void renderShips();
|
||||||
void renderParticles();
|
void renderParticles();
|
||||||
|
void renderText(const char *text, float x, float y, float sx, float sy);
|
||||||
|
|
||||||
void addModel(const std::string &filename, PolygonModel **dest);
|
void addModel(const std::string &filename, PolygonModel **dest);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace game {
|
||||||
state->generateId(),
|
state->generateId(),
|
||||||
player,
|
player,
|
||||||
player->ship->position,
|
player->ship->position,
|
||||||
|
player->color,
|
||||||
-util::deg2rad(m_angle),
|
-util::deg2rad(m_angle),
|
||||||
0.005*player->speed);
|
0.005*player->speed);
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,10 @@
|
||||||
#include <glm/gtx/norm.hpp>
|
#include <glm/gtx/norm.hpp>
|
||||||
|
|
||||||
namespace game {
|
namespace game {
|
||||||
Missile::Missile(size_t id, Player *player, const glm::vec2 &pos, float angle, float speed)
|
Missile::Missile(size_t id, Player *player, const glm::vec2 &pos, const glm::vec3 &col, float angle, float speed)
|
||||||
: Object(id, pos)
|
: Object(id, pos)
|
||||||
, player(player)
|
, player(player)
|
||||||
|
, color(col)
|
||||||
{
|
{
|
||||||
velocity = speed * glm::vec2(std::sin(angle), std::cos(angle));
|
velocity = speed * glm::vec2(std::sin(angle), std::cos(angle));
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace game {
|
||||||
size_t planetId;
|
size_t planetId;
|
||||||
};
|
};
|
||||||
|
|
||||||
Missile(size_t id, Player *player, const glm::vec2 &pos, float angle, float speed);
|
Missile(size_t id, Player *player, const glm::vec2 &pos, const glm::vec3 &col, float angle, float speed);
|
||||||
~Missile();
|
~Missile();
|
||||||
|
|
||||||
// try to advance. if something will be hit, return the first hit in
|
// try to advance. if something will be hit, return the first hit in
|
||||||
|
@ -68,6 +68,7 @@ namespace game {
|
||||||
Player *player; // owner won't be hit by own missiles
|
Player *player; // owner won't be hit by own missiles
|
||||||
glm::vec2 velocity;
|
glm::vec2 velocity;
|
||||||
Trace *trace;
|
Trace *trace;
|
||||||
|
glm::vec3 color;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,10 +164,10 @@ namespace game {
|
||||||
Player *player = playerForId(playerId);
|
Player *player = playerForId(playerId);
|
||||||
if (player != nullptr) {
|
if (player != nullptr) {
|
||||||
for (Missile *missile : player->missiles) {
|
for (Missile *missile : player->missiles) {
|
||||||
player->missiles.remove(missile);
|
player->missiles.remove(missile);
|
||||||
missile->player = nullptr;
|
missile->player = nullptr;
|
||||||
m_nextEvents.push_back(new MissileEvent(LifeCycle::Destroy, missile));
|
m_nextEvents.push_back(new MissileEvent(LifeCycle::Destroy, missile));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player->ship != nullptr) {
|
if (player->ship != nullptr) {
|
||||||
ships.remove(player->ship);
|
ships.remove(player->ship);
|
||||||
|
|
Loading…
Reference in a new issue