Working on improve rendering.
This commit is contained in:
parent
a0991a45fb
commit
7d3c51cdce
2
Makefile
2
Makefile
@ -14,7 +14,7 @@ LDFLAGS := -g -Wl
|
||||
#---------------------------------------------------------------------------------
|
||||
# Any extra libraries you wish to link with your project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lGL -lGLU -lSDL
|
||||
LIBS := -lglfw -lGL -lGLU -lSDL -lXrandr
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
|
1
TODO
1
TODO
@ -1,5 +1,6 @@
|
||||
- Multi-biome: Working on
|
||||
- Improve multi-biome display
|
||||
- Bugs with biomes at (1;0) and (0;1)
|
||||
- Fix cube selected from a biome to another one bug
|
||||
- Fix problem in manageEvents
|
||||
- Big map && map generation
|
||||
|
@ -39,6 +39,7 @@ class Scene {
|
||||
void display();
|
||||
|
||||
void loadTextures();
|
||||
void drawBiomes();
|
||||
void drawField();
|
||||
|
||||
void lockMouse();
|
||||
|
@ -23,8 +23,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <GL/glfw.h>
|
||||
|
||||
#include "sdlglutils.h"
|
||||
|
||||
@ -37,6 +36,8 @@
|
||||
#include "scene.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
glfwInit();
|
||||
|
||||
// Init SDL and OpenGL
|
||||
initSDL();
|
||||
initOpenGL();
|
||||
@ -48,6 +49,8 @@ int main(int argc, char *argv[]) {
|
||||
// Stop SDL
|
||||
SDL_Quit();
|
||||
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,7 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <GL/glfw.h>
|
||||
|
||||
#include "sdlglutils.h"
|
||||
|
||||
@ -55,7 +54,7 @@ bool Scene::intersectionLinePlane(vect3D normal, vect3D planePoint, vect3D lineO
|
||||
|
||||
float k = p2 / p1;
|
||||
|
||||
if(k < 0) return false;
|
||||
if((k < 0) || (k > 5)) return false;
|
||||
|
||||
vect3D i; // Intersection point
|
||||
|
||||
@ -267,12 +266,24 @@ void Scene::exec() {
|
||||
|
||||
m_cont = true;
|
||||
|
||||
double lastTime = glfwGetTime();
|
||||
int nbFrames = 0;
|
||||
|
||||
while(m_cont) {
|
||||
// Measure speed
|
||||
double currentTime = glfwGetTime();
|
||||
nbFrames++;
|
||||
if(currentTime - lastTime >= 1.0) {
|
||||
cout << 1000.0/double(nbFrames) << " ms/frame" << endl;
|
||||
nbFrames = 0;
|
||||
lastTime += 1.0;
|
||||
}
|
||||
|
||||
manageEvents();
|
||||
animate();
|
||||
draw();
|
||||
display();
|
||||
cout << "Selected: (" << selectedCube->x() << ";" << selectedCube->y() << ";" << selectedCube->z() << ") face: " << (int)selectedCube->selectedFace() << endl;
|
||||
//cout << "Current biome: (" << biome->x() << ";" << biome->y() << ";" << biome->z() << ")" << endl;
|
||||
}
|
||||
|
||||
unlockMouse();
|
||||
@ -401,10 +412,7 @@ void Scene::loadTextures() {
|
||||
m_textures["bedrock"] = loadTexture("textures/bedrock.bmp");
|
||||
}
|
||||
|
||||
void Scene::drawField() {
|
||||
// Turn on textures
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
void Scene::drawBiomes() {
|
||||
biome = findNearestBiome(player->x(), player->y(), player->z());
|
||||
biome->draw();
|
||||
testCubes(biome->cubes());
|
||||
@ -412,6 +420,19 @@ void Scene::drawField() {
|
||||
findNearestBiome(player->x() + 16, player->y(), player->z())->draw();
|
||||
findNearestBiome(player->x(), player->y() + 16, player->z())->draw();
|
||||
findNearestBiome(player->x() + 16, player->y() + 16, player->z())->draw();
|
||||
findNearestBiome(player->x() - 16, player->y() + 16, player->z())->draw();
|
||||
|
||||
findNearestBiome(player->x() - 16, player->y(), player->z())->draw();
|
||||
findNearestBiome(player->x(), player->y() - 16, player->z())->draw();
|
||||
findNearestBiome(player->x() - 16, player->y() - 16, player->z())->draw();
|
||||
findNearestBiome(player->x() + 16, player->y() - 16, player->z())->draw();
|
||||
}
|
||||
|
||||
void Scene::drawField() {
|
||||
drawBiomes();
|
||||
|
||||
// Turn on textures
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
Loading…
x
Reference in New Issue
Block a user