
/*
 * normal mapping
 * from Nopper ogl 3.3 tutorial 06
*/
#pragma once

#include <memory>
#include <vector>

#include "demo_base.h"
#include "common.hpp"
#include "shader.hpp"
#include "tga.h"
#include "transformation_node.h"
#include "geometry_node.h"
#include "object_node.h"

class demo_normal_mapping : public demo_base {
public:
	demo_normal_mapping(void);
	virtual ~demo_normal_mapping(void);
	virtual bool init();

protected:
	enum tex_indices {TEX, NORM, NUM_TEXTURES};
	GLuint texture[NUM_TEXTURES];
	//GLfloat g_projection[16];
	//GLfloat g_modelviev[16];
	std::auto_ptr<Shader> normmap;
	std::auto_ptr<Shader> texture_simple;

	GLint g_projectionLocation, //locations for shader variables
		g_modelViewLocation,
		g_lightDirLocation,
		g_vertexLocation,
		g_normalLocation,
		g_tangentLocation, 
		g_texCoordLocation,
		g_textureLocation,
		g_normalMapLocation;
	GLuint g_vao;
	GLuint g_vertices;
	GLuint g_normals;
	GLuint g_tangents;
	GLuint g_texCoords;
	GLuint g_indices;
	GLuint g_texture;
	GLuint numberIndices;
	GLuint g_normalMap;

	GLfloat angle;

	//loadscreen
	GLuint loadscreen_vao, loadscreen_vbo[3];
	object_node loadscreen_node;


	//functions
	virtual void process_keys();
	virtual void draw();	//main drawing method
	virtual void cleanup(); //do some cleanup if necessary
	void update();
	
	void init_loadscreen(const Shader &shader, GLuint *vbo_id, GLuint *vao_id);
	void draw_loadscreen(scene_node& node, GLuint texture_id );

};