这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bc9ee7a
skeleton code for minimap
jfeo May 7, 2015
da8a881
basic shaders for minimap
jfeo May 7, 2015
def5c6e
minimap code to game_main.cpp
jfeo May 7, 2015
0035e8f
add minimap shader generation code
jfeo May 7, 2015
c037977
included minimap header
jfeo May 7, 2015
f3052a5
added minimap to source list
jfeo May 7, 2015
7495853
Stuff
jfeo May 11, 2015
7004b17
added terrain_id to color mapping, diamond-shaped quad, simulated 3d …
jfeo May 12, 2015
a95df25
messy commit
jfeo May 13, 2015
d698861
Added minimap-shader, that only draws view port window inside minimap…
jfeo Jul 22, 2015
c932095
Unit display, coloring of units by player color and selected status.
jfeo Jul 25, 2015
18e35fa
master merged with minimap
jfeo Jul 26, 2015
55125a9
fixed duplicate code
jfeo Jul 26, 2015
62f836a
changed terrain conversion to keep terrain minimap colors
jfeo Jul 26, 2015
08df097
Use gamedata for unit and terrain colors
jfeo Jul 28, 2015
9037b68
Comments, indentation, is_within to absolute coord
jfeo Jul 30, 2015
aa3327b
Indentation, added left and right mouse click on the minimap
jfeo Jul 30, 2015
3254c2c
Indentation
jfeo Jul 30, 2015
c330a51
changing GL_TEXTURE_MAG_FILTER back to GL_LINEAR
jfeo Jul 30, 2015
e622e2f
Changing the names of 'color' values
jfeo Jul 30, 2015
b7742d0
merged with master
jfeo Aug 6, 2015
cc167c5
Merged with HD media conversion
jfeo Aug 6, 2015
e933bee
Minor fixes
jfeo Aug 7, 2015
480ce4f
* Minimap resolution calculation changed - now method `set_mapping`
jfeo Aug 7, 2015
035c6fd
merged with minimap-new. (minimap resolution, update frequency, gamed…
jfeo Aug 8, 2015
c6a2e1d
merged with hd media fix
jfeo Aug 8, 2015
d7fd202
merged with master, moved minimap code to game_renderer
jfeo Aug 12, 2015
ebcfcb3
fixed player color number, ignore resources for now, fixed some inden…
jfeo Aug 12, 2015
b8c45b1
move minimap from game_main to main, access unit container and terrai…
jfeo Aug 13, 2015
99fa15f
merged with master
jfeo Aug 13, 2015
8638374
indentation fix
jfeo Aug 14, 2015
8e68e38
remove minimap from game_renderer, changed minimap initialization
jfeo Aug 14, 2015
64b3d2b
removed trailing whitespaces
jfeo Aug 14, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Jonathan Remnant <jono4728@gmail.com>
Henry Snoek <?> <snoek09@users.noreply.github.com>
coop shell (Michael Enßlin, Jonas Jelten, Andre Kupka) <coop@sft.mx>
Franz-Niclas Muschter <fm@stusta.net> <franz-niclas.muschter@stusta.net>
Jens Feodor Nielsen <xws747@alumni.ku.dk>
20 changes: 20 additions & 0 deletions assets/shaders/minimap.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#version 120

uniform ivec2 minimap_orig;
uniform ivec2 minimap_size;

varying vec4 out_vertex_position;
varying vec3 out_color;

void main(void) {
ivec2 center = ivec2(minimap_size.x/2, minimap_size.y/2);
ivec2 vpos = minimap_orig + center - ivec2(out_vertex_position.x, out_vertex_position.y);
vec3 color;

if (!(abs(vpos.x) * center.y + abs(vpos.y) * center.x <= center.x * center.y))
discard;
else
color = out_color;

gl_FragColor = vec4(color, 1.0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tab indent pls.

}
13 changes: 13 additions & 0 deletions assets/shaders/minimap.vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#version 120

attribute vec4 vertex_position;
attribute vec3 color;

varying vec4 out_vertex_position;
varying vec3 out_color;

void main() {
out_vertex_position = vertex_position;
out_color = color;
gl_Position = gl_ModelViewProjectionMatrix * vertex_position;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hihi whitespace, tab indent pls

}
2 changes: 1 addition & 1 deletion libopenage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ add_sources(libopenage
player.cpp
screenshot.cpp
texture.cpp

minimap.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whtitespace

config.cpp
)

Expand Down
2 changes: 2 additions & 0 deletions libopenage/game_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "game_main.h"
#include "game_spec.h"
#include "generator.h"
#include "engine.h"
#include "minimap.h"

namespace openage {

Expand Down
23 changes: 22 additions & 1 deletion libopenage/game_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ GameRenderer::GameRenderer(openage::Engine *e)
// load textures and stuff
gaben = new Texture{data_dir->join("gaben.png")};

std::vector<gamedata::palette_color> player_color_lines;
std::vector<gamedata::palette_color> player_color_lines, general_color_lines;
util::read_csv_file(asset_dir.join("player_palette.docx"), player_color_lines);

GLfloat *playercolors = new GLfloat[player_color_lines.size() * 4];
Expand Down Expand Up @@ -91,6 +91,15 @@ GameRenderer::GameRenderer(openage::Engine *e)
auto alphamask_frag = new shader::Shader(GL_FRAGMENT_SHADER, alphamask_frag_code);
delete[] alphamask_frag_code;

char *minimap_vert_code;
util::read_whole_file(&minimap_vert_code, data_dir->join("shaders/minimap.vert.glsl"));
auto minimap_vert = new shader::Shader(GL_VERTEX_SHADER, minimap_vert_code);
delete[] minimap_vert_code;

char *minimap_frag_code;
util::read_whole_file(&minimap_frag_code, data_dir->join("shaders/minimap.frag.glsl"));
auto minimap_frag = new shader::Shader(GL_FRAGMENT_SHADER, minimap_frag_code);
delete[] minimap_frag_code;


// create program for rendering simple textures
Expand Down Expand Up @@ -134,12 +143,23 @@ GameRenderer::GameRenderer(openage::Engine *e)
glUniform1i(alphamask_shader::mask_texture, 1);
alphamask_shader::program->stopusing();


// create program for rendering within the minimap
minimap_shader::program = new shader::Program(minimap_vert, minimap_frag);
minimap_shader::program->link();
minimap_shader::size = minimap_shader::program->get_uniform_id("minimap_size");
minimap_shader::orig = minimap_shader::program->get_uniform_id("minimap_orig");
minimap_shader::color = minimap_shader::program->get_attribute_id("color");


// after linking, the shaders are no longer necessary
delete plaintexture_vert;
delete plaintexture_frag;
delete teamcolor_frag;
delete alphamask_vert;
delete alphamask_frag;
delete minimap_vert;
delete minimap_frag;

// Renderer keybinds
// TODO: a renderer settings struct
Expand All @@ -165,6 +185,7 @@ GameRenderer::~GameRenderer() {
delete texture_shader::program;
delete teamcolor_shader::program;
delete alphamask_shader::program;
delete minimap_shader::program;
}

bool GameRenderer::on_draw() {
Expand Down
6 changes: 6 additions & 0 deletions libopenage/game_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
#include "options.h"
#include "player.h"

#include "minimap.h"

namespace openage {
/* namespace minimap_shader { */
/* extern shader::Program *program; */
/* extern GLint size, orig, color; */
/* } */


/**
Expand Down
6 changes: 6 additions & 0 deletions libopenage/game_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ void GameSpec::load_terrain(AssetManager &am) {
terrain_data.blending_masks.reserve(terrain_data.blendmode_count);
terrain_data.terrain_id_priority_map = std::make_unique<int[]>(terrain_data.terrain_id_count);
terrain_data.terrain_id_blendmode_map = std::make_unique<int[]>(terrain_data.terrain_id_count);
terrain_data.terrain_id_map_color_hi_map = std::make_unique<uint8_t[]>(terrain_data.terrain_id_count);
terrain_data.terrain_id_map_color_med_map = std::make_unique<uint8_t[]>(terrain_data.terrain_id_count);
terrain_data.terrain_id_map_color_low_map = std::make_unique<uint8_t[]>(terrain_data.terrain_id_count);
terrain_data.influences_buf = std::make_unique<struct influence[]>(terrain_data.terrain_id_count);


Expand All @@ -345,6 +348,9 @@ void GameSpec::load_terrain(AssetManager &am) {
// TODO: terrain double-define check?
terrain_data.terrain_id_priority_map[terrain_id] = line->blend_priority;
terrain_data.terrain_id_blendmode_map[terrain_id] = line->blend_mode;
terrain_data.terrain_id_map_color_hi_map[terrain_id] = line->map_color_hi;
terrain_data.terrain_id_map_color_med_map[terrain_id] = line->map_color_med;
terrain_data.terrain_id_map_color_low_map[terrain_id] = line->map_color_low;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace


// TODO: remove hardcoding and rely on nyan data
auto terraintex_filename = util::sformat("%s/%d.slp.png", this->terrain_path.c_str(), line->slp_id);
Expand Down
2 changes: 2 additions & 0 deletions libopenage/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ int run_game(const main_arguments &args) {
GameRenderer renderer{&engine};
GameControl control{&engine};
Generator generator{&engine};
Minimap minimap = Minimap(coord::camhud_delta{200, 100}, coord::camhud{5, 5});
engine.register_drawhud_action(&minimap);

log::log(MSG(info).fmt("Loading time [game]: %5.3f s", timer.getval() / 1.0e9));

Expand Down
Loading