summaryrefslogtreecommitdiff
path: root/scene.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene.cpp')
-rw-r--r--scene.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/scene.cpp b/scene.cpp
index 180c90d..f994627 100644
--- a/scene.cpp
+++ b/scene.cpp
@@ -35,12 +35,15 @@ Scene::Scene() {
glUniform1i(tex1loc, 1);
GLint tex2loc = glGetUniformLocation(terrain_program.get_program(), "tex[2]");
glUniform1i(tex2loc, 2);
+ GLint markloc = glGetUniformLocation(terrain_program.get_program(), "marktex");
+ glUniform1i(markloc, 3);
glUseProgram(0);
/* load textures */
grass_texture = load_texture("textures/zooboing-366-grass.jpg");
rock_texture = load_texture("textures/zooboing-825-stone-modified.jpg");
soil_texture = load_texture("textures/zooboing-469-sand-modified.jpg");
+ marker_texture = load_texture("textures/cross.png");
/* load heightmap */
SDL_Surface *hm = IMG_Load("heightmap.png");
@@ -250,7 +253,6 @@ void Scene::render() {
CEGUI::System::getSingleton().injectTimePulse(0.001*(float)steps);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
video::persp();
unsigned char *keystate = SDL_GetKeyState(NULL);
@@ -316,6 +318,13 @@ void Scene::render() {
unsigned int chunks_rendered = 0;
if(terrain) {
terrain_program.use();
+ GLint show_sel = glGetUniformLocation(terrain_program.get_program(), "show_sel");
+ glUniform1i(show_sel, show_selection ? 1 : 0);
+ if(show_selection) {
+ GLint selpos = glGetUniformLocation(terrain_program.get_program(), "selpos");
+ glUniform3f(selpos, selected.x, selected.y, selected.z);
+ }
+
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
@@ -327,6 +336,9 @@ void Scene::render() {
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, soil_texture);
+ glActiveTexture(GL_TEXTURE3);
+ glBindTexture(GL_TEXTURE_2D, marker_texture);
+
std::queue<Quadtree::QuadChunk*> q;
q.push(qt->root);
while(!q.empty()) {
@@ -386,17 +398,6 @@ void Scene::render() {
selected = Vector3(px, py, pz);
show_selection = true;
}
- if(show_selection) {
- glColor3f(1, 0, 0);
- glBegin(GL_TRIANGLE_FAN);
- glVertex3f(selected.x, selected.y, selected.z);
- glVertex3f(selected.x+.5, selected.y+1, selected.z-.5);
- glVertex3f(selected.x+.5, selected.y+1, selected.z+.5);
- glVertex3f(selected.x-.5, selected.y+1, selected.z+.5);
- glVertex3f(selected.x-.5, selected.y+1, selected.z-.5);
- glVertex3f(selected.x+.5, selected.y+1, selected.z-.5);
- glEnd();
- }
video::ortho();
float height = font->LineHeight();