#pragma once
#include "../stdafx.h"
#include "glLibFBO.h"
#include "glLibLight.h"
#include "glLibShader.h"
#include "glLibView.h"

template <typename type_float> void glLibAlpha(type_float alpha) {
	GLfloat current_color[4]; glGetFloatv(GL_CURRENT_COLOR,current_color);
    glColor4f(current_color[0],current_color[1],current_color[2],alpha);
}

void glLibSceneToTexture(int rect[4], glLibTexture2D* texture);
void glLibSceneToTexture(glLibFlag rect, glLibTexture2D* texture);

void glLibSetCamera(glLibInternal_glLibView* view, double* eye, double* center, double* up);
void glLibGetCameraFrustumPoints(
	glLibInternal_glLibView* view,
	double* eye, double* center, double* up,
	double data[2][4][3]);

void glLibGetMatricesProjView(float* proj_mat, float* view_mat);

void glLibInternal_make_depthmap( void(*draw_objects)(void), float offset );
void glLibMakeDepthMap(glLibTexture2D*  depthmap, void(*draw_objects)(void), float offset=1.0f);
void glLibMakeDepthMap(      glLibFBO* depth_fbo, void(*draw_objects)(void), float offset=1.0f);

const GLfloat glLibInternal_matrix_depthmap_scale_and_bias[] = {
	0.5f, 0.0f, 0.0f, 0.0f,
	0.0f, 0.5f, 0.0f, 0.0f,
	0.0f, 0.0f, 0.5f, 0.0f,
	0.5f, 0.5f, 0.5f, 1.0f};
void glLibUseDepthMaps(
	glLibTexture2D** depthmaps,
	float** projection_matrices, float** view_matrices,
	int number_of_depthmaps,
	int starting_number_effect,
	int starting_number_texture,
	glLibShader* shader,
	void(*transform_objects)(void) );

void glLibInternal_update_cubemap(
	glLibTextureCube* cubemap, glLibView3D* cubemap_view,
	double x, double y, double z,
	void(*draw_reflectees)(void),
	bool update[6]);
//TODO: Add FBO override
void glLibUpdateCubeMap(
	glLibTextureCube* cubemap, glLibView3D* cubemap_view, double center[3],
	void(*draw_reflectees)(void),
	glLibFlag update_flag=GLLIB_ALL);

void glLibSendTransform( glLibShader* shader, void(*transform_function)(void) );

bool glLibCheckExtension(const char *extension);

void glLibDrawMode(glLibFlagType mode);

void glLibTranslatefv(GLfloat vec[3]);
void glLibTranslatedv(GLdouble vec[3]);