<repo_name>nad314/core-game<file_sep>/core-game/gameMesh/glGameMesh.h
#pragma once

namespace core {
	class glGameMesh {
	public:
		GLuint buff[6];
		GLuint vao;
		int ind;
		glGameMesh() { memset(buff, 0, sizeof(buff)); ind = 0; }
		GAMEDLL ~glGameMesh();
		GAMEDLL void dispose();

		GAMEDLL bool make(GameMesh& mesh, glShader& shader, const char* pos, const char* nor, const char* tex);
		GAMEDLL bool make(GameMesh& mesh, glShader& shader, const char* pos, const char* nor, const char* tan, const char* btan, const char* tex);
		GAMEDLL void drawTris();
		GAMEDLL void drawQuads();
	};
}
<file_sep>/core-game/glTexture/glTexture.h
#pragma once

namespace core {
	class glTexture {
	private:
		GLuint t;
	public:
		glTexture() : t(0) {}
		GAMEDLL ~glTexture();
		
		inline operator GLuint&() { return t; }
		inline operator const GLuint() const { return t; }
		inline glTexture& bind() { glBindTexture(GL_TEXTURE_2D, t); return *this; }
		inline glTexture& bind(const int& n) { glExt::activeTexture(GL_TEXTURE0 + n); bind(); return *this; }
		inline static void unbind() { glBindTexture(GL_TEXTURE_2D, 0); }
		inline static void unbind(const int& n) { glExt::activeTexture(GL_TEXTURE0 + n); unbind(); }
		GAMEDLL void dispose();
		GAMEDLL bool make(const Image& img);
		GAMEDLL bool construct(Image& img); //construct an image from opengl
		GAMEDLL bool loadPng(char* path);
		GAMEDLL void genMipmaps();
		
	};
}
<file_sep>/core-game/glExt/glExtensions.defines.h
#pragma once

#define GL_BUFFER_SIZE                    0x8764
#define GL_BUFFER_USAGE                   0x8765
#define GL_QUERY_COUNTER_BITS             0x8864
#define GL_CURRENT_QUERY                  0x8865
#define GL_QUERY_RESULT                   0x8866
#define GL_QUERY_RESULT_AVAILABLE         0x8867
#define GL_ARRAY_BUFFER                   0x8892
#define GL_ELEMENT_ARRAY_BUFFER           0x8893
#define GL_ARRAY_BUFFER_BINDING           0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING   0x8895
#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
#define GL_READ_ONLY                      0x88B8
#define GL_WRITE_ONLY                     0x88B9
#define GL_READ_WRITE                     0x88BA
#define GL_BUFFER_ACCESS                  0x88BB
#define GL_BUFFER_MAPPED                  0x88BC
#define GL_BUFFER_MAP_POINTER             0x88BD
#define GL_STREAM_DRAW                    0x88E0
#define GL_STREAM_READ                    0x88E1
#define GL_STREAM_COPY                    0x88E2
#define GL_STATIC_DRAW                    0x88E4
#define GL_STATIC_READ                    0x88E5
#define GL_STATIC_COPY                    0x88E6
#define GL_DYNAMIC_DRAW                   0x88E8
#define GL_DYNAMIC_READ                   0x88E9
#define GL_DYNAMIC_COPY                   0x88EA
#define GL_SAMPLES_PASSED                 0x8914
#define GL_SRC1_ALPHA                     0x8589
#define GL_VERTEX_ARRAY_BUFFER_BINDING    0x8896
#define GL_NORMAL_ARRAY_BUFFER_BINDING    0x8897
#define GL_COLOR_ARRAY_BUFFER_BINDING     0x8898
#define GL_INDEX_ARRAY_BUFFER_BINDING     0x8899
#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B
#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D
#define GL_WEIGHT_ARRAY_BUFFER_BINDING    0x889E
#define GL_FOG_COORD_SRC                  0x8450
#define GL_FOG_COORD                      0x8451
#define GL_CURRENT_FOG_COORD              0x8453
#define GL_FOG_COORD_ARRAY_TYPE           0x8454
#define GL_FOG_COORD_ARRAY_STRIDE         0x8455
#define GL_FOG_COORD_ARRAY_POINTER        0x8456
#define GL_FOG_COORD_ARRAY                0x8457
#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D
#define GL_SRC0_RGB                       0x8580
#define GL_SRC1_RGB                       0x8581
#define GL_SRC2_RGB                       0x8582
#define GL_SRC0_ALPHA                     0x8588
#define GL_SRC2_ALPHA                     0x858A


#define GL_MAP_READ_BIT 0x0001
#define GL_MAP_WRITE_BIT 0x0002
#define GL_MAP_PERSISTENT_BIT 0x00000040
#define GL_MAP_COHERENT_BIT 0x00000080
#define GL_DYNAMIC_STORAGE_BIT 0x0100
#define GL_CLIENT_STORAGE_BIT 0x0200
#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000
#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F
#define GL_BUFFER_STORAGE_FLAGS 0x8220


#define GL_SHADER_STORAGE_BUFFER          0x90D2
#define GL_SHADER_STORAGE_BUFFER_BINDING  0x90D3
#define GL_SHADER_STORAGE_BUFFER_START    0x90D4
#define GL_SHADER_STORAGE_BUFFER_SIZE     0x90D5
#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6
#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7
#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8
#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9
#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA
#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB
#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC
#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD
#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE  0x90DE
#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF
#define GL_SHADER_STORAGE_BARRIER_BIT     0x2000

#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
#define GL_ELEMENT_ARRAY_BARRIER_BIT      0x00000002
#define GL_UNIFORM_BARRIER_BIT            0x00000004
#define GL_TEXTURE_FETCH_BARRIER_BIT      0x00000008
#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
#define GL_COMMAND_BARRIER_BIT            0x00000040
#define GL_PIXEL_BUFFER_BARRIER_BIT       0x00000080
#define GL_TEXTURE_UPDATE_BARRIER_BIT     0x00000100
#define GL_BUFFER_UPDATE_BARRIER_BIT      0x00000200
#define GL_FRAMEBUFFER_BARRIER_BIT        0x00000400
#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800
#define GL_ATOMIC_COUNTER_BARRIER_BIT     0x00001000
#define GL_ALL_BARRIER_BITS               0xFFFFFFFF

#define GL_R32F 0x822E
#define GL_R16F 0x822D
#define 	GL_DEPTH_COMPONENT16   0x81A5
#define 	GL_DEPTH_COMPONENT24   0x81A6
#define 	GL_DEPTH_COMPONENT32   0x81A7
#define 	GL_DEPTH_COMPONENT32F   0x8CAC
#define 	GL_DEPTH_COMPONENT32F_NV   0x8DAB


#define GL_VERTEX_SHADER_ARB 0x8B31
#define GL_GEOMETRY_SHADER_ARB 0x8DD9
#define GL_FRAGMENT_SHADER_ARB 0x8B30
#define GL_MAX_VERTEX_UNIFORM_VECTORS       0x8DFB
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS     0x8DFD
#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
#define GL_MAX_VERTEX_UNIFORM_COMPONENTS  0x8B4A

#define GL_COMPUTE_SHADER 0x91B9
#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB
#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC
#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD
#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262
#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263
#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264
#define GL_MAX_COMPUTE_ATOMIC_COUNTERS  0x8265
#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266
#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS 0x90EB
#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE
#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF
#define GL_COMPUTE_LOCAL_WORK_SIZE 0x8267
#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC
#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED
#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE
#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF
#define GL_COMPUTE_SHADER_BIT 0x00000020

#define GL_UNIFORM 0x92E1	
#define GL_UNIFORM_BLOCK 0x92E2	
#define GL_PROGRAM_INPUT 0x92E3	
#define GL_PROGRAM_OUTPUT 0x92E4	
#define GL_BUFFER_VARIABLE 0x92E5	
#define GL_SHADER_STORAGE_BLOCK 0x92E6	
#define GL_IS_PER_PATCH 0x92E7	
#define GL_VERTEX_SUBROUTINE 0x92E8	
#define GL_TESS_CONTROL_SUBROUTINE 0x92E9	
#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA	
#define GL_GEOMETRY_SUBROUTINE 0x92EB	
#define GL_FRAGMENT_SUBROUTINE 0x92EC	
#define GL_COMPUTE_SUBROUTINE 0x92ED	
#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE	
#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF	
#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0	
#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1	
#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2	
#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3	
#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4	
#define GL_ACTIVE_RESOURCES 0x92F5	
#define GL_MAX_NAME_LENGTH 0x92F6	
#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7	
#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8	
#define GL_NAME_LENGTH 0x92F9	
#define GL_TYPE 0x92FA	
#define GL_ARRAY_SIZE 0x92FB	
#define GL_OFFSET 0x92FC	
#define GL_BLOCK_INDEX 0x92FD	
#define GL_ARRAY_STRIDE 0x92FE	
#define GL_MATRIX_STRIDE 0x92FF	
#define GL_IS_ROW_MAJOR 0x9300	
#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301	
#define GL_BUFFER_BINDING 0x9302	
#define GL_BUFFER_DATA_SIZE 0x9303	
#define GL_NUM_ACTIVE_VARIABLES 0x9304	
#define GL_ACTIVE_VARIABLES 0x9305	
#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306	
#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307	
#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308	
#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309	
#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A	
#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B	
#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C	
#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D	
#define GL_LOCATION 0x930E	
#define GL_LOCATION_INDEX 0x930F	

#define GL_TEXTURE0                       0x84C0
#define GL_TEXTURE1                       0x84C1
#define GL_TEXTURE2                       0x84C2
#define GL_TEXTURE3                       0x84C3
#define GL_TEXTURE4                       0x84C4
#define GL_TEXTURE5                       0x84C5
#define GL_TEXTURE6                       0x84C6
#define GL_TEXTURE7                       0x84C7
#define GL_TEXTURE8                       0x84C8
#define GL_TEXTURE9                       0x84C9
#define GL_TEXTURE10                      0x84CA
#define GL_TEXTURE11                      0x84CB
#define GL_TEXTURE12                      0x84CC
#define GL_TEXTURE13                      0x84CD
#define GL_TEXTURE14                      0x84CE
#define GL_TEXTURE15                      0x84CF
#define GL_TEXTURE16                      0x84D0
#define GL_TEXTURE17                      0x84D1
#define GL_TEXTURE18                      0x84D2
#define GL_TEXTURE19                      0x84D3
#define GL_TEXTURE20                      0x84D4
#define GL_TEXTURE21                      0x84D5
#define GL_TEXTURE22                      0x84D6
#define GL_TEXTURE23                      0x84D7
#define GL_TEXTURE24                      0x84D8
#define GL_TEXTURE25                      0x84D9
#define GL_TEXTURE26                      0x84DA
#define GL_TEXTURE27                      0x84DB
#define GL_TEXTURE28                      0x84DC
#define GL_TEXTURE29                      0x84DD
#define GL_TEXTURE30                      0x84DE
#define GL_TEXTURE31                      0x84DF

#define GL_CLAMP_TO_EDGE 0x812F


typedef unsigned short GLhalf;
#define GL_COMPARE_REF_TO_TEXTURE         0x884E
#define GL_CLIP_DISTANCE0                 0x3000
#define GL_CLIP_DISTANCE1                 0x3001
#define GL_CLIP_DISTANCE2                 0x3002
#define GL_CLIP_DISTANCE3                 0x3003
#define GL_CLIP_DISTANCE4                 0x3004
#define GL_CLIP_DISTANCE5                 0x3005
#define GL_CLIP_DISTANCE6                 0x3006
#define GL_CLIP_DISTANCE7                 0x3007
#define GL_MAX_CLIP_DISTANCES             0x0D32
#define GL_MAJOR_VERSION                  0x821B
#define GL_MINOR_VERSION                  0x821C
#define GL_NUM_EXTENSIONS                 0x821D
#define GL_CONTEXT_FLAGS                  0x821E
#define GL_COMPRESSED_RED                 0x8225
#define GL_COMPRESSED_RG                  0x8226
#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
#define GL_RGBA32F                        0x8814
#define GL_RGB32F                         0x8815
#define GL_RGBA16F                        0x881A
#define GL_RGB16F                         0x881B
#define GL_VERTEX_ATTRIB_ARRAY_INTEGER    0x88FD
#define GL_MAX_ARRAY_TEXTURE_LAYERS       0x88FF
#define GL_MIN_PROGRAM_TEXEL_OFFSET       0x8904
#define GL_MAX_PROGRAM_TEXEL_OFFSET       0x8905
#define GL_CLAMP_READ_COLOR               0x891C
#define GL_FIXED_ONLY                     0x891D
#define GL_MAX_VARYING_COMPONENTS         0x8B4B
#define GL_TEXTURE_1D_ARRAY               0x8C18
#define GL_PROXY_TEXTURE_1D_ARRAY         0x8C19
#define GL_TEXTURE_2D_ARRAY               0x8C1A
#define GL_PROXY_TEXTURE_2D_ARRAY         0x8C1B
#define GL_TEXTURE_BINDING_1D_ARRAY       0x8C1C
#define GL_TEXTURE_BINDING_2D_ARRAY       0x8C1D
#define GL_R11F_G11F_B10F                 0x8C3A
#define GL_UNSIGNED_INT_10F_11F_11F_REV   0x8C3B
#define GL_RGB9_E5                        0x8C3D
#define GL_UNSIGNED_INT_5_9_9_9_REV       0x8C3E
#define GL_TEXTURE_SHARED_SIZE            0x8C3F
#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
#define GL_TRANSFORM_FEEDBACK_VARYINGS    0x8C83
#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
#define GL_PRIMITIVES_GENERATED           0x8C87
#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
#define GL_RASTERIZER_DISCARD             0x8C89
#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
#define GL_INTERLEAVED_ATTRIBS            0x8C8C
#define GL_SEPARATE_ATTRIBS               0x8C8D
#define GL_TRANSFORM_FEEDBACK_BUFFER      0x8C8E
#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
#define GL_RGBA32UI                       0x8D70
#define GL_RGB32UI                        0x8D71
#define GL_RGBA16UI                       0x8D76
#define GL_RGB16UI                        0x8D77
#define GL_RGBA8UI                        0x8D7C
#define GL_RGB8UI                         0x8D7D
#define GL_RGBA32I                        0x8D82
#define GL_RGB32I                         0x8D83
#define GL_RGBA16I                        0x8D88
#define GL_RGB16I                         0x8D89
#define GL_RGBA8I                         0x8D8E
#define GL_RGB8I                          0x8D8F
#define GL_RED_INTEGER                    0x8D94
#define GL_GREEN_INTEGER                  0x8D95
#define GL_BLUE_INTEGER                   0x8D96
#define GL_RGB_INTEGER                    0x8D98
#define GL_RGBA_INTEGER                   0x8D99
#define GL_BGR_INTEGER                    0x8D9A
#define GL_BGRA_INTEGER                   0x8D9B
#define GL_SAMPLER_1D_ARRAY               0x8DC0
#define GL_SAMPLER_2D_ARRAY               0x8DC1
#define GL_SAMPLER_1D_ARRAY_SHADOW        0x8DC3
#define GL_SAMPLER_2D_ARRAY_SHADOW        0x8DC4
#define GL_SAMPLER_CUBE_SHADOW            0x8DC5
#define GL_UNSIGNED_INT_VEC2              0x8DC6
#define GL_UNSIGNED_INT_VEC3              0x8DC7
#define GL_UNSIGNED_INT_VEC4              0x8DC8
#define GL_INT_SAMPLER_1D                 0x8DC9
#define GL_INT_SAMPLER_2D                 0x8DCA
#define GL_INT_SAMPLER_3D                 0x8DCB
#define GL_INT_SAMPLER_CUBE               0x8DCC
#define GL_INT_SAMPLER_1D_ARRAY           0x8DCE
#define GL_INT_SAMPLER_2D_ARRAY           0x8DCF
#define GL_UNSIGNED_INT_SAMPLER_1D        0x8DD1
#define GL_UNSIGNED_INT_SAMPLER_2D        0x8DD2
#define GL_UNSIGNED_INT_SAMPLER_3D        0x8DD3
#define GL_UNSIGNED_INT_SAMPLER_CUBE      0x8DD4
#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY  0x8DD6
#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY  0x8DD7
#define GL_QUERY_WAIT                     0x8E13
#define GL_QUERY_NO_WAIT                  0x8E14
#define GL_QUERY_BY_REGION_WAIT           0x8E15
#define GL_QUERY_BY_REGION_NO_WAIT        0x8E16
#define GL_BUFFER_ACCESS_FLAGS            0x911F
#define GL_BUFFER_MAP_LENGTH              0x9120
#define GL_BUFFER_MAP_OFFSET              0x9121
#define GL_DEPTH_COMPONENT32F             0x8CAC
#define GL_DEPTH32F_STENCIL8              0x8CAD
#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
#define GL_INVALID_FRAMEBUFFER_OPERATION  0x0506
#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
#define GL_FRAMEBUFFER_DEFAULT            0x8218
#define GL_FRAMEBUFFER_UNDEFINED          0x8219
#define GL_DEPTH_STENCIL_ATTACHMENT       0x821A
#define GL_MAX_RENDERBUFFER_SIZE          0x84E8
#define GL_DEPTH_STENCIL                  0x84F9
#define GL_UNSIGNED_INT_24_8              0x84FA
#define GL_DEPTH24_STENCIL8               0x88F0
#define GL_TEXTURE_STENCIL_SIZE           0x88F1
#define GL_TEXTURE_RED_TYPE               0x8C10
#define GL_TEXTURE_GREEN_TYPE             0x8C11
#define GL_TEXTURE_BLUE_TYPE              0x8C12
#define GL_TEXTURE_ALPHA_TYPE             0x8C13
#define GL_TEXTURE_DEPTH_TYPE             0x8C16
#define GL_UNSIGNED_NORMALIZED            0x8C17
#define GL_FRAMEBUFFER_BINDING            0x8CA6
#define GL_DRAW_FRAMEBUFFER_BINDING       0x8CA6
#define GL_RENDERBUFFER_BINDING           0x8CA7
#define GL_READ_FRAMEBUFFER               0x8CA8
#define GL_DRAW_FRAMEBUFFER               0x8CA9
#define GL_READ_FRAMEBUFFER_BINDING       0x8CAA
#define GL_RENDERBUFFER_SAMPLES           0x8CAB
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
#define GL_FRAMEBUFFER_COMPLETE           0x8CD5
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
#define GL_FRAMEBUFFER_UNSUPPORTED        0x8CDD
#define GL_MAX_COLOR_ATTACHMENTS          0x8CDF
#define GL_COLOR_ATTACHMENT0              0x8CE0
#define GL_COLOR_ATTACHMENT1              0x8CE1
#define GL_COLOR_ATTACHMENT2              0x8CE2
#define GL_COLOR_ATTACHMENT3              0x8CE3
#define GL_COLOR_ATTACHMENT4              0x8CE4
#define GL_COLOR_ATTACHMENT5              0x8CE5
#define GL_COLOR_ATTACHMENT6              0x8CE6
#define GL_COLOR_ATTACHMENT7              0x8CE7
#define GL_COLOR_ATTACHMENT8              0x8CE8
#define GL_COLOR_ATTACHMENT9              0x8CE9
#define GL_COLOR_ATTACHMENT10             0x8CEA
#define GL_COLOR_ATTACHMENT11             0x8CEB
#define GL_COLOR_ATTACHMENT12             0x8CEC
#define GL_COLOR_ATTACHMENT13             0x8CED
#define GL_COLOR_ATTACHMENT14             0x8CEE
#define GL_COLOR_ATTACHMENT15             0x8CEF
#define GL_COLOR_ATTACHMENT16             0x8CF0
#define GL_COLOR_ATTACHMENT17             0x8CF1
#define GL_COLOR_ATTACHMENT18             0x8CF2
#define GL_COLOR_ATTACHMENT19             0x8CF3
#define GL_COLOR_ATTACHMENT20             0x8CF4
#define GL_COLOR_ATTACHMENT21             0x8CF5
#define GL_COLOR_ATTACHMENT22             0x8CF6
#define GL_COLOR_ATTACHMENT23             0x8CF7
#define GL_COLOR_ATTACHMENT24             0x8CF8
#define GL_COLOR_ATTACHMENT25             0x8CF9
#define GL_COLOR_ATTACHMENT26             0x8CFA
#define GL_COLOR_ATTACHMENT27             0x8CFB
#define GL_COLOR_ATTACHMENT28             0x8CFC
#define GL_COLOR_ATTACHMENT29             0x8CFD
#define GL_COLOR_ATTACHMENT30             0x8CFE
#define GL_COLOR_ATTACHMENT31             0x8CFF
#define GL_DEPTH_ATTACHMENT               0x8D00
#define GL_STENCIL_ATTACHMENT             0x8D20
#define GL_FRAMEBUFFER                    0x8D40
#define GL_RENDERBUFFER                   0x8D41
#define GL_RENDERBUFFER_WIDTH             0x8D42
#define GL_RENDERBUFFER_HEIGHT            0x8D43
#define GL_RENDERBUFFER_INTERNAL_FORMAT   0x8D44
#define GL_STENCIL_INDEX1                 0x8D46
#define GL_STENCIL_INDEX4                 0x8D47
#define GL_STENCIL_INDEX8                 0x8D48
#define GL_STENCIL_INDEX16                0x8D49
#define GL_RENDERBUFFER_RED_SIZE          0x8D50
#define GL_RENDERBUFFER_GREEN_SIZE        0x8D51
#define GL_RENDERBUFFER_BLUE_SIZE         0x8D52
#define GL_RENDERBUFFER_ALPHA_SIZE        0x8D53
#define GL_RENDERBUFFER_DEPTH_SIZE        0x8D54
#define GL_RENDERBUFFER_STENCIL_SIZE      0x8D55
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
#define GL_MAX_SAMPLES                    0x8D57
#define GL_INDEX                          0x8222
#define GL_TEXTURE_LUMINANCE_TYPE         0x8C14
#define GL_TEXTURE_INTENSITY_TYPE         0x8C15
#define GL_FRAMEBUFFER_SRGB               0x8DB9
#define GL_HALF_FLOAT                     0x140B
#define GL_MAP_READ_BIT                   0x0001
#define GL_MAP_WRITE_BIT                  0x0002
#define GL_MAP_INVALIDATE_RANGE_BIT       0x0004
#define GL_MAP_INVALIDATE_BUFFER_BIT      0x0008
#define GL_MAP_FLUSH_EXPLICIT_BIT         0x0010
#define GL_MAP_UNSYNCHRONIZED_BIT         0x0020
#define GL_COMPRESSED_RED_RGTC1           0x8DBB
#define GL_COMPRESSED_SIGNED_RED_RGTC1    0x8DBC
#define GL_COMPRESSED_RG_RGTC2            0x8DBD
#define GL_COMPRESSED_SIGNED_RG_RGTC2     0x8DBE
#define GL_RG                             0x8227
#define GL_RG_INTEGER                     0x8228
#define GL_R8                             0x8229
#define GL_R16                            0x822A
#define GL_RG8                            0x822B
#define GL_RG16                           0x822C
#define GL_R16F                           0x822D
#define GL_R32F                           0x822E
#define GL_RG16F                          0x822F
#define GL_RG32F                          0x8230
#define GL_R8I                            0x8231
#define GL_R8UI                           0x8232
#define GL_R16I                           0x8233
#define GL_R16UI                          0x8234
#define GL_R32I                           0x8235
#define GL_R32UI                          0x8236
#define GL_RG8I                           0x8237
#define GL_RG8UI                          0x8238
#define GL_RG16I                          0x8239
#define GL_RG16UI                         0x823A
#define GL_RG32I                          0x823B
#define GL_RG32UI                         0x823C
#define GL_VERTEX_ARRAY_BINDING           0x85B5
#define GL_CLAMP_VERTEX_COLOR             0x891A
#define GL_CLAMP_FRAGMENT_COLOR           0x891B
#define GL_ALPHA_INTEGER                  0x8D97

<file_sep>/core-game/glFramebuffer/glFramebuffer.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL bool glFramebuffer::build(const int w, const int h) {
		try {
			glGetError();
			glExt::genFramebuffers(1, &name);
			glExt::bindFramebuffer(GL_FRAMEBUFFER, name);
			if (glGetError() != 0)
				throw core::exception("Couldn't build framebuffer\n");
			glGenTextures(1, &rgb);
			if (glGetError() != 0)
				throw core::exception("Couldn't build rgb texture\n");
			glGenTextures(1, &depth);
			if (glGetError() != 0)
				throw core::exception("Couldn't build depth texture\n");

			glBindTexture(GL_TEXTURE_2D, rgb);
			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

			glExt::genRenderBuffers(1, &depth);
			glExt::bindRenderBuffer(GL_RENDERBUFFER, depth);
			glExt::renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, w, h);
			glExt::framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth);

			glExt::framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rgb, 0);
			GLenum DrawBuffers[1] = { GL_COLOR_ATTACHMENT0 };
			glExt::drawBuffers(1, DrawBuffers);

			if (glExt::checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
				throw core::exception("Framebuffer build error\n");

			unbind();
		}
		catch (std::exception& e) { 
			core::Debug::log("%s\n", e.what()); 
			dispose();
			return false;
		}
		return true;
	}

	GAMEDLL void glFramebuffer::resize(const int w, const int h) {
		if (name == 0)
			return;
		glExt::bindRenderBuffer(GL_RENDERBUFFER, depth);
		glExt::renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, w, h);
		glBindTexture(GL_TEXTURE_2D, rgb);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
	}


	GAMEDLL void glFramebuffer::drawToScreen(const int w, const int h) const{
		glExt::bindFramebuffer(GL_READ_FRAMEBUFFER, *this);
		glExt::bindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
		glExt::blitFramebuffer(0, 0, w, h, 0, 0, w, h, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
		glExt::bindFramebuffer(GL_READ_FRAMEBUFFER, 0);
	}

	GAMEDLL void glFramebuffer::dispose() {
		if (glIsTexture(rgb))
			glDeleteTextures(1, &rgb);
		glExt::deleteRenderBuffers(1, &depth);
		glExt::deleteFramebuffers(1, &name);
		name = rgb = depth = 0;
	}
}


<file_sep>/core-game/gameMesh/gameMesh.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL void GameMesh::computeNormals() {
		vec3 nor;
		size_t i;
		normal.reserve(position.count());
		normal.count() = position.count();
		for (i = 0; i < normal.count(); ++i)
			normal[i] = vec3(0.0f);
		for (i = 0; i < indices.count(); i += 3) {
			nor = vector::normal(position[indices[i]], position[indices[i+1]], position[indices[i+2]]);
			normal[indices[i]] += nor;
			normal[indices[i+1]] += nor;
			normal[indices[i+2]] += nor;
		}
		for (i = 0; i < normal.count(); ++i)
			normal[i].normalize();
	}

	GAMEDLL void GameMesh::computeTangentSpace(buffer<vec3>& tangents, buffer<vec3>& bitangents) {
		tangents.reserve(position.count());
		tangents.count() = position.count();
		bitangents.reserve(position.count());
		bitangents.count() = position.count();
		size_t i;
		for (i = 0; i < tangents.count(); ++i) {
			tangents[i] = vec3(0.0f);
			bitangents[i] = vec3(0.0f);
		}

		for (i = 0; i < indices.count(); i += 3) {
			vec3 d1 = position[indices[i + 1]] - position[indices[i]];
			vec3 d2 = position[indices[i + 2]] - position[indices[i]];
			vec2 uv1 = texcoord[indices[i + 1]] - texcoord[indices[i]];
			vec2 uv2 = texcoord[indices[i + 2]] - texcoord[indices[i]];

			float r = 1.0f / (uv1.x*uv2.y - uv1.y*uv2.x);
			vec3 tg = ((d1*uv2.y - d2*uv1.y)*r).normalize();
			vec3 btg = ((d2*uv1.x - d1*uv2.x)*r).normalize();

			tangents[indices[i]] += tg;
			tangents[indices[i+1]] += tg;
			tangents[indices[i+2]] += tg;

			bitangents[indices[i]] += btg;
			bitangents[indices[i+1]] += btg;
			bitangents[indices[i+2]] += btg;
		}

		for (i = 0; i < tangents.count(); ++i) {
			tangents[i].normalize();
			bitangents[i].normalize();
			float f = (vector::dot(vector::cross(normal[i], tangents[i]), bitangents[i])<0.0f) ? -1.0f : 1.0f;

			tangents[i] = (normal[i] * vector::dot(normal[i], tangents[i]) - tangents[i]).normalize()*f;
			//bitangents[i] = (vector::cross(normal[indices[i]], tangents[i])*f).normalize();
		}

	}
}
<file_sep>/core-game/glFrame/glFrame.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL int glFrame::onMouseMove(const eventInfo& e) {
		if (!visible)
			return e;
		int f = flags&2;
		if (e.x() >= rect.x && e.x() <= rect.z && e.y() >= rect.y && e.y() <= rect.w)
			__hover();
		else __unhover();
		/*
		eventInfo translated = e;
		translated.lP = MAKELPARAM((short)e.x() - rect.x, (short)e.y() - rect.y);
		*/
		eventInfo translated = e.translateEvent(-rect.x, -rect.y);
		if (f > 0 || (flags & 2) > 0) {
			for (auto& i : items)
				i->onMouseMove(translated);
			invalidate();
			return 1;
		}
		if (e.y() < rect.y || e.y() > rect.w) {
			hide();
			invalidate();
			return 0;
		}
		return 0;
	}

	GAMEDLL int glFrame::onRightButtonDown(const eventInfo& e) {
		if ((flags & 2) > 0)
			for (auto& i : items)
				if (i->onRightButtonDown(e))
					return 1;
		return 0;
	}

	GAMEDLL int glFrame::onRightButtonUp(const eventInfo& e) {
		for (auto& i : items)
			if (i->onRightButtonUp(e))
				return 1;
		return 0;
	}

	GAMEDLL int glFrame::onPaint(const eventInfo& e) {
		if (!visible)
			return e;
		glTranslatef((float)rect.x, (float)rect.y, 0.0f);
		for (auto& i : items)
			i->onPaint(e);
		glTranslatef((float)-rect.x, (float)-rect.y, 0.0f);
		return 0;
	}

	GAMEDLL int glFrame::onLButtonDown(const eventInfo& e) {
		if ((flags & 2) > 0)
			for (auto& i : items)
				if (i->onLButtonDown(e))
					return 1;
		return 0;
	}

	GAMEDLL int glFrame::onLButtonUp(const eventInfo& e) {
		for (auto& i : items)
			if (i->onLButtonUp(e))
				return 1;
		return 0;
	}

	GAMEDLL int glFrame::onResize(const eventInfo& e) {
		return e;
	}

	GAMEDLL int glFrame::onLButtonDblClk(const eventInfo& e) {
		if ((flags & 2) > 0)
			for (auto& i : items)
				if (i->onLButtonDblClk(e))
					return 1;
		return 0;
	}

	GAMEDLL Rect glFrame::nextHorizontal() {
		Rect r(0,0,0,0);
		for (auto& i : items)
			r = r.max(i->rect);
		r.x = r.z;
		r.w = r.y;
		return r;
	}

	GAMEDLL Rect glFrame::nextVertical() {
		Rect r(0, 0, 0, 0);
		for (auto& i : items)
			r = r.max(i->rect);
		r.z = r.x;
		r.y = r.w;
		return r;
	}

	GAMEDLL glFrame& glFrame::wrap() {
		Rect nh = nextHorizontal();
		Rect nv = nextVertical();
		rect.z = rect.x + nh.x;
		rect.w = rect.y + nv.y;
		return *this;
	}
}
<file_sep>/core-game/glShader/glShader.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL glShader& glShader::dispose() {
		if (glExt::isProgram(program))
			glExt::deleteObject(program);
		if (glExt::isShader(fragment))
			glExt::deleteObject(fragment);
		if (glExt::isShader(vertex))
			glExt::deleteObject(vertex);
		vertex = fragment = program = 0;
		return *this;
	}

	GAMEDLL bool glShader::load(const char* vertexPath, const char* fragmentPath, const char* fragName) {
		dispose();
		glGetError();
		char *v=NULL, *f=NULL;
		if (!Path::fileToString(vertexPath, &v)) return 0;
		if (!Path::fileToString(fragmentPath, &f)) { delete[] v; return 0; }

		program = glExt::createProgramObject();
		vertex = glExt::createShaderObject(GL_VERTEX_SHADER_ARB);
		fragment = glExt::createShaderObject(GL_FRAGMENT_SHADER_ARB);

		glExt::shaderSource(vertex, 1, const_cast<const char**>(&v), NULL);
		glExt::shaderSource(fragment, 1, const_cast<const char**>(&f), NULL);

		glExt::compileShader(vertex);
		glExt::compileShader(fragment);

		glExt::attachObject(program, vertex);
		glExt::attachObject(program, fragment);

		glExt::bindFragDataLocation(program, 0, fragName);
		glExt::linkProgram(program);

		delete[] v;
		delete[] f;

		return glGetError()==0;
	}

	GAMEDLL glShader& glShader::printDebugInfo() {
		char c[256];
		int l;
		glExt::getShaderInfoLog(vertex, 256, &l, c);
		Debug::log("Vertex Shader Log:\n%s\n", c);
		glExt::getShaderInfoLog(fragment, 256, &l, c);
		Debug::log("Fragment Shader Log:\n%s\n", c);
		return *this;
	}
}
<file_sep>/core-game/view/view.h
#pragma once

namespace core {
	class View {
	public:
		matrixf projection;
		matrixf modelview;
		float fov;

		virtual ~View() {}
		GAMEDLL View& perspective(const int& width, const int& height, const float& FoV, const float& znear, const float& zfar);
		GAMEDLL View& perspective(Window& wnd, const float& FoV, const float& znear, const float& zfar);
		
		GAMEDLL vec4 project(const vec4& v, const Window& wnd) const;
		GAMEDLL vec4 unproject(const vec4& v, const Window& wnd) const;
		GAMEDLL vec4 mult(const vec4& v) const;
		GAMEDLL vec4 multInv(const vec4& v) const;
		GAMEDLL vec4 projectFull(const vec4& v, const Window& wnd) const;
		GAMEDLL vec4 unprojectFull(const vec4& v, const Window& wnd) const;
	};
}
<file_sep>/core-game/glControl/glImageButton.h
#pragma once

namespace core {
	class glImageButton : public ImageButton {
	protected:
		glTexture glDef, glHov, glAct;
		float pos[8];
		GAMEDLL static float tex[8];
	public:
		glImageButton() : ImageButton() {}
		glImageButton(const vec4i& r) : ImageButton(r) {}
		glImageButton(const vec4i& r, Image* img, Form& f) : ImageButton(r, img, f) {}
		virtual ~glImageButton() {}


		GAMEDLL virtual ImageButton& make(const vec4i& r, Image* img, Form& f);
		GAMEDLL virtual ImageButton& make(const vec4i& r, Image* img, Form& f, buttonFunc func);
		GAMEDLL virtual ImageButton& prerender();

		GAMEDLL virtual ButtonObject& move(const vec4i& r) override;
		GAMEDLL virtual int onPaint(const eventInfo& e) override;
		inline virtual void manualUnhover() { __unhover(); }
	};
}
<file_sep>/core-game/speleoMesh/glSpeleoModel.h
#pragma once

namespace core {
	class glSpeleoModel {
	private:
		buffer<glSpeleoMesh> mesh;
		buffer<glTexture> albedo;
		buffer<glTexture> normal;

	public:
		glSpeleoModel() {}
		~glSpeleoModel() {}

		GAMEDLL bool make(const TModel& model, glShader& shader, const char* pos, const char* tex);
		GAMEDLL void dispose();
		GAMEDLL void draw();
	};
}<file_sep>/core-game/view/view.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL View& View::perspective(const int& width, const int& height, const float& FoV, const float& znear, const float& zfar) {
		if (height == 0)
			return *this;
		projection.projection(FoV, (float)width / height, znear, zfar);
		fov = FoV;
		return *this;
	}

	GAMEDLL View& View::perspective(Window& window, const float &FoV, const float& znear, const float& zfar) {
		return perspective(window.width, window.height, FoV, znear, zfar);
	}

	GAMEDLL vec4 View::project(const vec4& v, const Window& wnd) const {
		vec4 r(0.0f);
		if (v.w == 0.0f)return r;
		r.w = 1.0f / v.w;
		r.x = (v.x*r.w*0.5f + 0.5f)*wnd.width + 0;
		r.y = (v.y*r.w*0.5f + 0.5f)*wnd.height + 0;
		r.z = (1.0f + v.z*r.w)*0.5f;
		return r;
	}

	GAMEDLL vec4 View::unproject(const vec4& v, const Window& wnd) const {
		if (v.w == 0.0f)
			return vec4(0.0f);
		vec4 r = v / vec4((float)wnd.width, (float)wnd.height, 1.0f, 1.0f) - vec4(0.5f, 0.5f, 0.0f, 0.0f);
		r /= vec4(0.5f, 0.5f, 0.5f, 1.0f);
		r.x /= r.w;
		r.y /= r.w;
		r.z = (r.z - 1.0f) / r.w;
		r.w = 1.0f;
		return r;
	}

	GAMEDLL vec4 View::mult(const vec4& v) const {
		return modelview*projection*v;
	}

	GAMEDLL vec4 View::multInv(const vec4& v) const {
		matrixf inv = modelview*projection;
		inv.invert();
		return inv*v;
	}


	GAMEDLL vec4 View::projectFull(const vec4& v, const Window& wnd) const {
		return project(modelview*projection*v, wnd);
	}

	GAMEDLL vec4 View::unprojectFull(const vec4& v, const Window& wnd) const {
		vec4 p = multInv(unproject(v, wnd));
		return p / p.w;
	}

}
<file_sep>/core-game/view/glview.h
#pragma once

namespace core {
	class glView : public View {
	public:
		GAMEDLL glView& sendTo(glShader& shader, const char* modelviewName, const char* projectionName);
		GAMEDLL glView& sendTo(glShader& shader, const uint& modelviewName, const uint& projectionName);
	};
}
<file_sep>/core-game/glTextureMaterial/glTextureMaterial.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL const int glTextureMaterial::fileChunk::type_image = 1;
	GAMEDLL const int glTextureMaterial::fileChunk::subtype_diffuse = 1;
	GAMEDLL const int glTextureMaterial::fileChunk::subtype_normal = 2;
	GAMEDLL const int glTextureMaterial::fileChunk::type_scale_vector = 2;

	GAMEDLL bool glTextureMaterial::save(const char* path, const char* tempDir) {
		bool ret = 1;
		Path::pushDir();
		Path::cd(tempDir);
		Image img;
		ret &= diffuse.construct(img);
		ret &= img.savePng("tmp.diffuse");
		ret &= normal.construct(img);
		ret &= img.savePng("tmp.normal");
		//file to file
		FILE* f;
		fileChunk chunk;
		char* data = NULL;
		if (!(f = fopen(path, "wb")))
			ret = 0;
		if (ret) {
			chunk.type = fileChunk::type_image;
			chunk.subtype = fileChunk::subtype_diffuse;
			chunk.bytes = Path::getFileSize("tmp.diffuse");
			fwrite(&chunk, sizeof(chunk), 1, f);
			ret &= Path::fileToString("tmp.diffuse", &data);
			fwrite(data, 1, chunk, f);
			delete[] data;
			data = NULL;
			if (!ret) core::Debug::print("Could not save diffuse image\n");
		}
		if (ret) {
			chunk.type = fileChunk::type_image;
			chunk.subtype = fileChunk::subtype_normal;
			chunk.bytes = Path::getFileSize("tmp.normal");
			fwrite(&chunk, sizeof(chunk), 1, f);
			ret &= Path::fileToString("tmp.normal", &data);
			fwrite(data, 1, chunk, f);
			delete[] data;
			data = NULL;
			if (!ret) core::Debug::print("Could not save normal image\n");
		}
		if (ret) {
			chunk.type = fileChunk::type_scale_vector;
			chunk.subtype = 0;
			chunk.bytes = sizeof(vec2);
			fwrite(&chunk, sizeof(chunk), 1, f);
			fwrite(&scale, sizeof(vec2), 1, f);
		}
		fclose(f);
		//remove files
		remove("tmp.diffuse");
		remove("tmp.normal");
		Path::popDir();
		return ret;
	}

	GAMEDLL bool glTextureMaterial::load(const char* path, const char* tempDir) {
		Path::pushDir();
		Path::cd(tempDir);
		FILE *f;
		if (!(f = fopen(path, "rb")))
			return 0;
		bool ret = 1;
		fileChunk chunk;
		while (!feof(f)) {
			fread(&chunk, sizeof(chunk), 1, f);
			switch (chunk.type) {
			case fileChunk::type_image: {
				char* data = new char[chunk];
				FILE* ff = fopen("tmp.png", "wb");
				if (ff == NULL) {
					ret = 0;
					break;
				}
				fread(data, chunk, 1, f);
				fwrite(data, chunk, 1, ff);
				fclose(ff);
				delete[] data;
				if (chunk.subtype == fileChunk::subtype_diffuse)
					ret &= diffuse.loadPng("tmp.png");
				else if (chunk.subtype == fileChunk::subtype_normal)
					ret &= normal.loadPng("tmp.png");
				break;
			}
			case fileChunk::type_scale_vector: {
				fread(&scale, sizeof(scale), 1, f);
				break;
			}
			}
		}
		remove("tmp.png");
		Path::popDir();
		return ret;
	}

	GAMEDLL glTextureMaterial& glTextureMaterial::makeDefault(const int size) {
		Image img;
		img.make(size, size, 32);
		int n = size*size * 4;
		Core2D::clearImage(img, Color(255));
		diffuse.make(img);
		Core2D::clearImage(img, core::Color(128, 128, 255, 255));
		normal.make(img);
		return *this;
	}
}
<file_sep>/core-game/glShader/glComputeShader.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL glComputeShader& glComputeShader::dispose() {
		if (glExt::isProgram(program))
			glExt::deleteObject(program);
		if (glExt::isShader(shader))
			glExt::deleteObject(shader);
		program = shader = 0;
		return *this;
	}

	GAMEDLL bool glComputeShader::load(const char* path) {
		dispose();
		glGetError();
		char *v = NULL;
		if (!Path::fileToString(path, &v)) return 0;

		program = glExt::createProgramObject();
		shader = glExt::createShaderObject(GL_COMPUTE_SHADER);

		glExt::shaderSource(shader, 1, const_cast<const char**>(&v), NULL);
		glExt::compileShader(shader);
		glExt::attachObject(program, shader);
		glExt::linkProgram(program);

		delete[] v;
		return glGetError() == 0;
	}

	GAMEDLL glComputeShader& glComputeShader::printDebugInfo() {
		char c[256];
		int l;
		glExt::getShaderInfoLog(shader, 256, &l, c);
		Debug::log("Compute Shader Log:\n%s\n", c);
		return *this;
	}
}
<file_sep>/core-game/gameMesh/gameMesh.h
#pragma once

namespace core {
	class GameMesh {
	public:
		buffer<vec3> position;
		buffer<vec3> normal;
		buffer<vec2> texcoord;
		buffer<int> indices;

		GAMEDLL void computeNormals();
		GAMEDLL void computeTangentSpace(buffer<vec3>& tangents, buffer<vec3>& bitangents);
	};
}
<file_sep>/core-game/glTexture/glTexture.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL glTexture::~glTexture() {
		dispose();
	}

	GAMEDLL void glTexture::dispose() {
		if (glIsTexture(t))
			glDeleteTextures(1, &t);
		t = 0;
	}

	GAMEDLL bool glTexture::construct(Image& img) {
		vec2i size;
		int format;
		int bpp;
		bind();
		glGetError(); //clear error
		glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &size.x);
		glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &size.y);
		glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &format);
		switch (format) {
		case GL_RED: bpp = 8;
		case GL_RGB: bpp = 24;
		case GL_RGBA: bpp = 32;
		default: bpp = 32;
		}
		img.make(size.x, size.y, bpp);
		glGetTexImage(GL_TEXTURE_2D, 0, format, GL_UNSIGNED_BYTE, img.data);
		unbind();
		return glGetError()==0;
	}

	GAMEDLL bool glTexture::make(const Image& img) {
		if (img.width == 0 || img.height == 0)
			return 0;
		dispose();
		glBindTexture(GL_TEXTURE_2D, 0);
		glGenTextures(1, &t);
		glBindTexture(GL_TEXTURE_2D, t);
		if (!glIsTexture(t))
			return 0;
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		int format;
		int internalFormat;
		switch (img.bits) {
		case 8: format = GL_R; internalFormat = GL_R;  break;
		case 24: format = GL_RGB; internalFormat = GL_RGB;  break;
		case 32: format = GL_RGBA; internalFormat = GL_RGBA;  break;
		default: format = GL_RGBA; internalFormat = GL_RGBA; break;
		}
		glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, img.data);
		return 1;
	}

	GAMEDLL bool glTexture::loadPng(char* path) {
		Image img;
		if (!img.loadPng(path))
			return 0;
		return make(img);
	}

	GAMEDLL void glTexture::genMipmaps() {
		bind();
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
		glExt::generateMipmap(GL_TEXTURE_2D);
		unbind();
	}
}
<file_sep>/core-game/glControl/glFrameImageButton.h
#pragma once
namespace core {
	class glFrameImageButton: public glImageButton {
	protected:
		glAnimatedFrame* frame;
	public:
		glFrameImageButton() :glImageButton(), frame(NULL) {}
		GAMEDLL virtual int onPaint(const eventInfo& e) override;
		virtual glFrameImageButton& setFrame(glAnimatedFrame* f) { frame = f; return *this; }
	};
}<file_sep>/core-game/glShader/glShader.h
#pragma once

namespace core {
	class glShader {
	protected:
		GLuint vertex;
		GLuint fragment;
		GLuint program;
	public:
		glShader() : vertex(0), fragment(0), program(0) {}
		glShader(const char* vp, const char* fp, const char* fragName) : vertex(0), fragment(0), program(0) { load(vp, fp, fragName); }
		~glShader() { dispose(); }
		GAMEDLL glShader& dispose();
		GAMEDLL bool load(const char* vertexPath, const char* fragmentPath, const char* fragName);
		inline glShader& start() { glExt::useProgram(program); return *this; }
		inline glShader& stop() { glExt::useProgram(0); return *this; }
		inline operator const GLint() const { return program; }
		inline operator const GLuint() const { return program; }
		GAMEDLL glShader& printDebugInfo();
	};

	class glComputeShader {
	protected:
		GLuint shader;
		GLuint program;
	public:
		glComputeShader() : program(0) {}
		glComputeShader(const char* path) : program(0) { load(path); }
		~glComputeShader() { dispose(); }

		GAMEDLL glComputeShader& dispose();
		GAMEDLL bool load(const char* path);
		inline operator GLint() { return program; }
		GAMEDLL glComputeShader& printDebugInfo();

		inline glComputeShader& start() { glExt::useProgramObject(program); return *this; }
		inline glComputeShader& stop() { glExt::useProgramObject(0); return *this; }
	};
}

<file_sep>/core-game/glControl/glImageButton.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL float glImageButton::tex[8] = {0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f};

	GAMEDLL ImageButton& glImageButton::make(const vec4i& r, Image* img, Form& f) {
		ImageButton::make(r, img, f);
		move(r);
		return *this;
	}

	GAMEDLL ImageButton& glImageButton::make(const vec4i& r, Image* img, Form& f, buttonFunc func) {
		ImageButton::make(r, img, f, func);
		move(r);
		return *this;
	}

	GAMEDLL ImageButton& glImageButton::prerender() {
		prerendered = true;
		def.make(rect.z - rect.x, rect.w - rect.y, 32);
		hov.make(rect.z - rect.x, rect.w - rect.y, 32);
		act.make(rect.z - rect.x, rect.w - rect.y, 32);

		Core2D::clearImage(def, backColor);
		Core2D::blendImage(Rect(0, 0, (int)def.width, (int)def.height), *ref, def);
		Core2D::clearImage(hov, backColorHover);
		Core2D::blendImage(Rect(0, 0, (int)hov.width, (int)hov.height), *refHov, hov);
		Core2D::clearImage(act, backColorActivated);
		Core2D::blendImage(Rect(0, 0, (int)act.width, (int)act.height), *refHov, act);

		glDef.make(def);
		glAct.make(act);
		glHov.make(hov);

		return *this;
	}

	GAMEDLL ButtonObject& glImageButton::move(const vec4i& r) {
		ButtonObject::move(r);
		pos[0] = (float)r.x;
		pos[1] = (float)r.y;
		pos[2] = (float)r.z;
		pos[3] = (float)r.y;
		pos[4] = (float)r.z;
		pos[5] = (float)r.w;
		pos[6] = (float)r.x;
		pos[7] = (float)r.w;
		return *this;
	}

	GAMEDLL int glImageButton::onPaint(const eventInfo& e) {
		if (ref == NULL)
			return 1;
		if (!prerendered)
			prerender();
		glBindTexture(GL_TEXTURE_2D, (flags & 4) ? glAct : ((flags & 2 || pinned()) ? glHov : glDef));
		glVertexPointer(2, GL_FLOAT, 0, pos);
		glTexCoordPointer(2, GL_FLOAT, 0, tex);
		glDrawArrays(GL_QUADS, 0, 4);
		glBindTexture(GL_TEXTURE_2D, 0);
		return 0;
	}

}<file_sep>/core-game/glFrame/glFrame.h
#pragma once

namespace core {
	class glFrame : public Control {
	protected:
		bool visible;
		buffer<Control*> items;
		Form* form;
	public:
		glFrame():Control(), visible(true), items(), form(NULL) {}
		virtual ~glFrame() {}
		inline glFrame& make(Form* f) { form = f; return *this; }
		inline void invalidate() { __invalidate();  if (form)form->invalidate(); }
		GAMEDLL virtual int onMouseMove(const eventInfo& e);
		GAMEDLL virtual int onRightButtonDown(const eventInfo& e);
		GAMEDLL virtual int onRightButtonUp(const eventInfo& e);
		GAMEDLL virtual int onPaint(const eventInfo& e);
		GAMEDLL virtual int onLButtonDown(const eventInfo& e);
		GAMEDLL virtual int onLButtonUp(const eventInfo& e);
		GAMEDLL virtual int onResize(const eventInfo& e);
		GAMEDLL virtual int onLButtonDblClk(const eventInfo& e);

		virtual int show() { visible = 1; __invalidate(); return 0; }
		virtual int hide() { __unhover(); visible = 0; __invalidate(); return 0; }
		virtual void push(Control& c) { items.push_back(&c); if (form)form->setControlColors(c); }

		GAMEDLL virtual Rect nextHorizontal();
		GAMEDLL virtual Rect nextVertical();
		GAMEDLL virtual glFrame& wrap();

	};
}
<file_sep>/core-game/glFrame/glAnimatedFrame.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL int glAnimatedFrame::onPaint(const eventInfo& e) {
		if (!visible && timer.stop().ms()>fadeInterval)
			return 0;
		float t = std::min(1.0f, timer.stop().ms() / fadeInterval);
		if (!visible)
			t = 1.0f - t;
		glColor4f(1.0f, 1.0f, 1.0f, t);
		bool v = visible;
		visible = true;
		glFrame::onPaint(e);
		visible = v;
		glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
		if (t < 1.0f)
			invalidate();
		return 0;
	}
}<file_sep>/core-game/main/core-game.h
#pragma once

#ifdef __WIN
#if defined GAME_DLL_EXPORT
#define GAMEDLL __declspec(dllexport)
#else
#define GAMEDLL __declspec(dllimport)
#endif
#else
#define GAMEDLL
#endif

using namespace core::opengl;

#include <view/view.h>
#include <glExt/glExtensions.h>
#include <glShader/glShader.h>
#include <gameMesh/gameMesh.h>
#include <gameMesh/glGameMesh.h>
#include <view/glview.h>
#include <glTexture/glTexture.h>
#include <glTextureMaterial/glTextureMaterial.h>
#include <frustum/frustum.h>
#include <glFramebuffer/glFramebuffer.h>

//controls
#include <glControl/glImageButton.h>
#include <glFrame/glFrame.h>
#include <glFrame/glAnimatedFrame.h>
#include <glControl/glFrameImageButton.h>

//speleo
#include <speleoMesh/glSpeleoMesh.h>
#include <speleoMesh/glSpeleoModel.h><file_sep>/core-game/view/glview.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL glView& glView::sendTo(glShader& shader, const char* modelviewName, const char* projectionName) {
		int l[2];
		l[0] = glExt::getUniformLocation(shader, modelviewName);
		l[1] = glExt::getUniformLocation(shader, projectionName);
		glExt::uniformMatrix4fv(l[0], 1, false, modelview);
		glExt::uniformMatrix4fv(l[1], 1, false, projection);
		return *this;
	}
	GAMEDLL glView& glView::sendTo(glShader& shader, const uint& modelviewName, const uint& projectionName) {
		glExt::uniformMatrix4fv(modelviewName, 1, false, modelview);
		glExt::uniformMatrix4fv(projectionName, 1, false, projection);
		return *this;
	}
}
<file_sep>/core-game/glTextureMaterial/glTextureMaterial.h
#pragma once

namespace core {
	class glTextureMaterial {
	protected:
	public:
		glTexture diffuse;
		glTexture normal;
		vec2 scale;

		struct fileChunk {
			GAMEDLL static const int type_image;
			GAMEDLL static const int subtype_diffuse;
			GAMEDLL static const int subtype_normal;
			GAMEDLL static const int type_scale_vector;

			int type; // 1-image
			int subtype; //1-map, 2-normal map
			int bytes;

			operator int() { return bytes; }
		};

		glTextureMaterial(): diffuse(), normal(), scale(1.0f, 1.0f){}
		~glTextureMaterial(){ dispose(); }
		GAMEDLL bool save(const char* path, const char* tempDir);
		GAMEDLL bool load(const char* path, const char* tempDir);
		inline void genMipmaps() { diffuse.genMipmaps(); normal.genMipmaps(); }
		inline void dispose() { diffuse.dispose(); normal.dispose(); scale = vec2(1.0f, 1.0f); }
		GAMEDLL glTextureMaterial& makeDefault(const int size);
	};
}<file_sep>/core-game/glExt/glExtensions.cpp
#include <core>
#include <core-forms>
#include <core-game>

#ifndef __WIN
#include <GL/glx.h>
#endif

namespace core {
	namespace opengl {
		GAMEDLL buffer<int> glExt::error;
		GAMEDLL int glExt::errCounter;
		GAMEDLL int glExt::version = 0;

		//buffers
		GAMEDLL void (APIENTRY* glExt::bindBuffer) (GLenum target, GLuint buffer);
		GAMEDLL void (APIENTRY* glExt::bufferData) (GLenum target, GLsizeiptrARB size, const GLvoid* data, GLenum usage);
		GAMEDLL void (APIENTRY* glExt::bufferSubData) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid* data);
		GAMEDLL void (APIENTRY* glExt::deleteBuffers) (GLsizei n, const GLuint* buffers);
		GAMEDLL void (APIENTRY* glExt::genBuffers) (GLsizei n, GLuint* buffers);
		GAMEDLL void (APIENTRY* glExt::getBufferParameteriv) (GLenum target, GLenum pname, GLint* params);
		GAMEDLL void (APIENTRY* glExt::getBufferPointerv) (GLenum target, GLenum pname, GLvoid** params);
		GAMEDLL void (APIENTRY* glExt::getBufferSubData) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid* data);
		GAMEDLL GLboolean(APIENTRY* glExt::isBuffer) (GLuint buffer);
		GAMEDLL GLvoid* (APIENTRY* glExt::mapBuffer) (GLenum target, GLenum access);
		GAMEDLL GLvoid* (APIENTRY* glExt::mapBufferRange) (GLenum target, GLintptrARB offset, GLsizeiptrARB length, GLenum access);
		GAMEDLL GLboolean(APIENTRY* glExt::unmapBuffer) (GLenum target);
		GAMEDLL void (APIENTRY* glExt::bufferStorage) (GLenum, GLsizeiptrARB, const GLvoid*, GLbitfield);
		GAMEDLL void (APIENTRY* glExt::bindBufferBase) (GLenum target, GLuint index, GLuint buffer);

		//arrays
		GAMEDLL void (APIENTRY* glExt::genVertexArrays) (GLsizei n, GLuint *arrays);
		GAMEDLL void (APIENTRY* glExt::bindVertexArray) (GLuint array);
		GAMEDLL void (APIENTRY* glExt::deleteVertexArrays) (GLsizei n, GLuint *arrays);
		GAMEDLL void (APIENTRY* glExt::enableVertexAttribArray) (GLuint index);
		GAMEDLL void (APIENTRY* glExt::vertexAttribPointer) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer);
		GAMEDLL GLboolean (APIENTRY* glExt::isVertexArray) (GLuint array);

		//framebuffers
		GAMEDLL void (APIENTRY* glExt::genFramebuffers) (GLsizei n, GLuint *framebuffers);
		GAMEDLL void (APIENTRY* glExt::deleteFramebuffers) (GLsizei n, const GLuint *framebuffers);
		GAMEDLL void (APIENTRY* glExt::bindFramebuffer) (GLenum target, GLuint framebuffer);
		GAMEDLL void (APIENTRY* glExt::framebufferTexture2D) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
		GAMEDLL void (APIENTRY* glExt::genRenderBuffers) (GLsizei n, GLuint *buffer);
		GAMEDLL void (APIENTRY* glExt::deleteRenderBuffers) (GLsizei n, const GLuint *buffer);
		GAMEDLL void (APIENTRY* glExt::bindRenderBuffer) (GLenum target, const GLuint buffer);
		GAMEDLL void (APIENTRY* glExt::framebufferRenderbuffer) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
		GAMEDLL void (APIENTRY* glExt::renderbufferStorage) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
		GAMEDLL GLenum(APIENTRY* glExt::checkFramebufferStatus) (GLenum target);
		GAMEDLL void (APIENTRY* glExt::blitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
		GAMEDLL void (APIENTRY* glExt::drawBuffers) (GLsizei n, const GLenum *bufs);

		//misc
		GAMEDLL void (APIENTRY* glExt::memoryBarrier) (GLbitfield barriers);
		GAMEDLL void (APIENTRY* glExt::texStorage2D) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height);
		GAMEDLL void (APIENTRY* glExt::generateMipmap) (GLuint target);

		//shaders
		GAMEDLL GLint(APIENTRY* glExt::deleteObject) (GLenum object);
		GAMEDLL void (APIENTRY* glExt::shaderSource) (GLuint shader, GLenum number_strings, const char **strings, GLint *length);
		GAMEDLL void (APIENTRY* glExt::compileShader) (GLenum shader);
		GAMEDLL void (APIENTRY* glExt::attachObject) (GLenum program, GLenum shader);
		GAMEDLL void (APIENTRY* glExt::linkProgram) (GLenum program);
		GAMEDLL void (APIENTRY* glExt::useProgramObject) (GLhandleARB object);
		GAMEDLL void (APIENTRY* glExt::useProgram) (GLuint program);
		GAMEDLL glExt::GLhandleARB(APIENTRY* glExt::createProgramObject) ();
		GAMEDLL glExt::GLhandleARB(APIENTRY* glExt::createShaderObject) (GLenum shaderType);
		GAMEDLL void (APIENTRY* glExt::activeTexture) (GLenum texture);
		GAMEDLL GLint(APIENTRY* glExt::getUniformLocation) (GLhandleARB program, const GLcharARB *name);
		GAMEDLL GLint(APIENTRY* glExt::getAttribLocation) (GLhandleARB program, const GLcharARB *name);
		GAMEDLL void (APIENTRY* glExt::getShaderInfoLog) (GLuint shader, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
		GAMEDLL void (APIENTRY* glExt::bindFragDataLocation) (GLuint program, GLuint colorNumber, const char *name);
		GAMEDLL void (APIENTRY* glExt::uniform1i) (GLint location, GLint v0);
		GAMEDLL void (APIENTRY* glExt::uniformMatrix4fv) (GLint location, GLsizei count, bool transpose, const GLfloat *value);
		GAMEDLL void (APIENTRY* glExt::uniformMatrix4dv) (GLint location, GLsizei count, bool transpose, const GLdouble *value);
		GAMEDLL void (APIENTRY* glExt::uniform4fv) (GLint location, int count, GLfloat *v0);
		GAMEDLL void (APIENTRY* glExt::uniformMatrix3fv) (GLint location, GLsizei count, bool transpose, const GLfloat *value);
		GAMEDLL void (APIENTRY* glExt::uniform1f) (GLint location, GLfloat v0);
		GAMEDLL void (APIENTRY* glExt::uniform4iv) (GLint location, int count, GLint *v0);
		GAMEDLL void (APIENTRY* glExt::uniform3fv) (GLint location, int count, GLfloat *v0);
		GAMEDLL void (APIENTRY* glExt::uniform2fv) (GLint location, int count, GLfloat* v0);
		GAMEDLL GLboolean (APIENTRY* glExt::isProgram) (GLuint program);
		GAMEDLL GLboolean (APIENTRY* glExt::isShader) (GLuint shader);

		//compute
		GAMEDLL void (APIENTRY* glExt::dispatchCompute) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
		GAMEDLL GLuint(APIENTRY* glExt::getProgramResourceIndex) (GLuint program, GLenum programInterface, const char* name);
		GAMEDLL void (APIENTRY* glExt::shaderStorageBlockBinding) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);
		GAMEDLL void (APIENTRY* glExt::bindImageTexture) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);

		GAMEDLL void* glExt::get(const char* name) {
			static char extName[256];
			#ifdef __WIN
			void *f = wglGetProcAddress(name);
			#else
			void *f = (void (*))glXGetProcAddress((const byte*)name);
			#endif
			if (!f) {
				memset(extName, 0, sizeof(extName));
				strcpy(extName, name);
				strcat(extName, "ARB");
				#ifdef __WIN
				f = wglGetProcAddress(extName);
				#else
				f = (void (*))glXGetProcAddress((const byte*)extName);
				#endif
			}
			if (!f) {
				error.push_back(errCounter);
				core::Debug::log("error: %s\n", name);
			}
			++errCounter;
			return f;
		}


		GAMEDLL void glExt::init() {
			error.clear();
			errCounter = 0;

			//buffers 1.5
			bindBuffer = (decltype(bindBuffer))get("glBindBuffer"); //1.5
			bufferData = (decltype(bufferData))get("glBufferData"); //1.5
			bufferSubData = (decltype(bufferSubData))get("glBufferSubData"); //1.5
			deleteBuffers = (decltype(deleteBuffers))get("glDeleteBuffers"); //1.5
			genBuffers = (decltype(genBuffers))get("glGenBuffers"); //1.5
			getBufferParameteriv = (decltype(getBufferParameteriv))get("glGetBufferParameteriv"); //1.5
			getBufferPointerv = (decltype(getBufferPointerv))get("glGetBufferPointerv"); //1.5
			getBufferSubData = (decltype(getBufferSubData))get("glGetBufferSubData"); //1.5
			isBuffer = (decltype(isBuffer))get("glIsBuffer"); //1.5
			mapBuffer = (decltype(mapBuffer))get("glMapBuffer"); //1.5
			unmapBuffer = (decltype(unmapBuffer))get("glUnmapBuffer"); //1.5

			if (error.size() == 0)
				version = 150;

			//array 2.0
			enableVertexAttribArray = (decltype(enableVertexAttribArray))get("glEnableVertexAttribArray"); //2.0
			vertexAttribPointer = (decltype(vertexAttribPointer))get("glVertexAttribPointer"); //2.0

			//FBO 2.0
			drawBuffers = (decltype(drawBuffers))get("glDrawBuffers"); //2.0

			//shaders 2.0
			deleteObject = (decltype(deleteObject))get("glDeleteObject"); //2.0
			shaderSource = (decltype(shaderSource))get("glShaderSource"); //2.0
			compileShader = (decltype(compileShader))get("glCompileShader"); //2.0
			attachObject = (decltype(attachObject))get("glAttachObject"); //2.0
			linkProgram = (decltype(linkProgram))get("glLinkProgram"); //2.0
			useProgramObject = (decltype(useProgramObject))get("glUseProgramObject"); //2.0
			useProgram = (decltype(useProgram))get("glUseProgram"); //2.0
			createProgramObject = (decltype(createProgramObject))get("glCreateProgram"); //2.0
			createShaderObject = (decltype(createShaderObject))get("glCreateShader"); //2.0
			getUniformLocation = (decltype(getUniformLocation))get("glGetUniformLocation"); //2.0
			getAttribLocation = (decltype(getAttribLocation))get("glGetAttribLocation"); //2.0
			getShaderInfoLog = (decltype(getShaderInfoLog))get("glGetShaderInfoLog"); //2.0
			uniform1i = (decltype(uniform1i))get("glUniform1i"); //2.0
			uniform1f = (decltype(uniform1f))get("glUniform1f"); //2.0
			uniformMatrix4fv = (decltype(uniformMatrix4fv))get("glUniformMatrix4fv"); //2.0
			uniform4fv = (decltype(uniform4fv))get("glUniform4fv"); //2.0
			uniformMatrix3fv = (decltype(uniformMatrix3fv))get("glUniformMatrix3fv"); //2.0
			uniform3fv = (decltype(uniform3fv))get("glUniform3fv"); //2.0
			uniform2fv = (decltype(uniform2fv))get("glUniform2fv"); //2.0
			uniform4iv = (decltype(uniform4iv))get("glUniform4iv"); //2.0
			isProgram = (decltype(isProgram))get("glIsProgram"); //2.0
			isShader = (decltype(isShader))get("glIsShader"); //2.0
			activeTexture = (decltype(activeTexture))get("glActiveTexture"); //2.0

			if (error.size() == 0)
				version = 200;

																	   
			//buffers 3.0
			bindBufferBase = (decltype(bindBufferBase))get("glBindBufferBase"); //3.0
			mapBufferRange = (decltype(mapBufferRange))get("glMapBufferRange"); //3.0

			//arrays 3.0
			genVertexArrays = (decltype(genVertexArrays))get("glGenVertexArrays"); //3.0
			bindVertexArray = (decltype(bindVertexArray))get("glBindVertexArray"); //3.0
			deleteVertexArrays = (decltype(deleteVertexArrays))get("glDeleteVertexArrays"); //3.0
			isVertexArray = (decltype(isVertexArray))get("glIsVertexArray"); //3.0

			//framebuffers 3.0
			genFramebuffers = (decltype(genFramebuffers))get("glGenFramebuffersEXT"); //3.0
			deleteFramebuffers = (decltype(deleteFramebuffers))get("glDeleteFramebuffersEXT"); //3.0
			bindFramebuffer = (decltype(bindFramebuffer))get("glBindFramebufferEXT"); //3.0
			genRenderBuffers = (decltype(genRenderBuffers))get("glGenRenderbuffersEXT"); //3.0
			deleteRenderBuffers = (decltype(deleteRenderBuffers))get("glDeleteRenderbuffersEXT"); //3.0
			bindRenderBuffer = (decltype(bindRenderBuffer))get("glBindRenderbufferEXT"); //3.0
			framebufferRenderbuffer = (decltype(framebufferRenderbuffer))get("glFramebufferRenderbufferEXT"); //3.0
			renderbufferStorage = (decltype(renderbufferStorage))get("glRenderbufferStorageEXT"); //3.0
			checkFramebufferStatus = (decltype(checkFramebufferStatus))get("glCheckFramebufferStatusEXT"); //3.0
			blitFramebuffer = (decltype(blitFramebuffer))get("glBlitFramebufferEXT"); //3.0

			//misc 3.0
			generateMipmap = (decltype(generateMipmap))get("glGenerateMipmap"); //3.0

			//shaders 3.0
			bindFragDataLocation = (decltype(bindFragDataLocation))get("glBindFragDataLocation"); //3.0

			if (error.size() == 0)
				version = 300;

			//FBO 3.2
			framebufferTexture2D = (decltype(framebufferTexture2D))get("glFramebufferTexture2DEXT"); //3.2

			if (error.size() == 0)
				version = 320;

			//misc 4.2
			memoryBarrier = (decltype(memoryBarrier))get("glMemoryBarrier"); //4.2
			texStorage2D = (decltype(texStorage2D))get("glTexStorage2D"); //4.2

			if (error.size() == 0)
				version = 420;

			//compute 4.3
			dispatchCompute = (decltype(dispatchCompute))get("glDispatchCompute"); //4.3
			getProgramResourceIndex = (decltype(getProgramResourceIndex))get("glGetProgramResourceIndex"); //4.3
			shaderStorageBlockBinding = (decltype(shaderStorageBlockBinding))get("glShaderStorageBlockBinding"); //4.3
			bindImageTexture = (decltype(bindImageTexture))get("glBindImageTexture"); //4.2

			if (error.size() == 0)
				version = 430;

			//buffers 4.4
			bufferStorage = (decltype(bufferStorage))get("glBufferStorage"); //4.4
			uniformMatrix4dv = (decltype(uniformMatrix4dv))get("glUniformMatrix4dv"); //2.0

			if (error.size() == 0)
				version = 440;
		}
	}
}<file_sep>/core-game/glFramebuffer/glFramebuffer.h
#pragma once

namespace core {
	class glFramebuffer {
	private:
		GLuint name;
		GLuint rgb;
		GLuint depth;

	public:
		glFramebuffer() :name(0), rgb(0), depth(0) {}
		~glFramebuffer() { dispose(); }

		inline operator const GLuint() const { return name; }
		inline const GLuint texture() const { return rgb; }

		GAMEDLL virtual void dispose();
		GAMEDLL virtual bool build(const int w, const int h);
		GAMEDLL virtual void resize(const int w, const int h);

		inline void bind() { glExt::bindFramebuffer(GL_FRAMEBUFFER, name); }
		inline void unbind() { glExt::bindFramebuffer(GL_FRAMEBUFFER, 0); }
		GAMEDLL void drawToScreen(const int w, const int h) const;
	};
}
<file_sep>/core-game/speleoMesh/glSpeleoMesh.h
#pragma once

namespace core {
	class glSpeleoMesh {
	public:
		GLuint buff[2];
		GLuint vao;
		int ind;
		glSpeleoMesh() { memset(buff, 0, sizeof(buff)); ind = 0; vao = 0; }
		GAMEDLL ~glSpeleoMesh();
		GAMEDLL void dispose();

		GAMEDLL bool make(const TMesh& mesh, glShader& shader, const char* pos, const char* tex);
		GAMEDLL void drawTris();
		GAMEDLL void drawQuads();
	};
}
<file_sep>/core-game/frustum/frustum.h
#pragma once
namespace core {
	class Frustum {
	public:
		vec4 p[6];
		vec3 v[8];
		GAMEDLL void get(const View& view, const core::Window& wnd);
		GAMEDLL const bool aabbIntersection(vec3 a, vec3 b) const;
		GAMEDLL const bool sphereIntersection(vec3 c, float r) const;
	};
}
<file_sep>/core-game/speleoMesh/glSpeleoModel.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL void glSpeleoModel::dispose() {
		mesh.clear();
		albedo.clear();
		normal.clear();
	}

	GAMEDLL bool glSpeleoModel::make(const TModel& model, glShader& shader, const char* cpos, const char* ctex) {
		try {
			mesh.reserve(model.mesh.size());
			albedo.reserve(model.albedo.size());
			normal.reserve(model.normal.size());
			mesh.count() = model.mesh.size();
			albedo.count() = model.albedo.size();
			normal.count() = model.normal.size();
			for (size_t i = 0; i < model.mesh.size(); ++i)
				if (!mesh[i].make(model.mesh[i], shader, cpos, ctex))
					throw core::exception("OpenGL buffer error\n");
			for (size_t i = 0; i < model.albedo.size(); ++i)
				if (!albedo[i].make(model.albedo[i]))
					throw core::exception("OpenGL texture error\n");
			for (size_t i = 0; i < model.normal.size(); ++i)
				if (!normal[i].make(model.normal[i]))
					throw core::exception("OpenGL texture error\n");
			glExt::activeTexture(GL_TEXTURE0);
			glBindTexture(GL_TEXTURE_2D, 0);
			glExt::bindVertexArray(0);
			glExt::bindBuffer(GL_ARRAY_BUFFER, 0);
			glExt::bindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
		}
		catch (std::exception& e) {
			Debug::error("%s\n", e.what());
			return false;
		}
		return true;
	}

	GAMEDLL void glSpeleoModel::draw() {
		const size_t count = std::min(mesh.size(), std::min(albedo.size(), normal.size()));
		for (size_t i = 0; i < count; ++i) {
			glExt::activeTexture(GL_TEXTURE1);
			glBindTexture(GL_TEXTURE_2D, normal[i]);
			glExt::activeTexture(GL_TEXTURE0);
			glBindTexture(GL_TEXTURE_2D, albedo[i]);
			mesh[i].drawTris();
		}
		glExt::bindVertexArray(0);
		glExt::bindBuffer(GL_ARRAY_BUFFER, 0);
		glExt::activeTexture(GL_TEXTURE1);
		glBindTexture(GL_TEXTURE_2D, 0);
		glExt::activeTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, 0);
	}

}
<file_sep>/core-game/glExt/glExtensions.h
#pragma once
#include <glExt/glExtensions.defines.h>
namespace core {
	namespace opengl {
		class glExt {
		private:
			GAMEDLL static int errCounter;
			GAMEDLL static int version;
			GAMEDLL static void* get(const char* name);
		public:
			GAMEDLL static buffer<int> error;

			typedef int GLsizeiptrARB;
			typedef int GLintptrARB;
			typedef unsigned int GLhandleARB;
			typedef char GLcharARB;

			static const int supportedVersion() { return version; }

			GAMEDLL static void init();

			//buffers
			GAMEDLL static void (APIENTRY* bindBuffer) (GLenum target, GLuint buffer);
			GAMEDLL static void (APIENTRY* bufferData) (GLenum target, GLsizeiptrARB size, const GLvoid* data, GLenum usage);
			GAMEDLL static void (APIENTRY* bufferSubData) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid* data);
			GAMEDLL static void (APIENTRY* deleteBuffers) (GLsizei n, const GLuint* buffers);
			GAMEDLL static void (APIENTRY* genBuffers) (GLsizei n, GLuint* buffers);
			GAMEDLL static void (APIENTRY* getBufferParameteriv) (GLenum target, GLenum pname, GLint* params);
			GAMEDLL static void (APIENTRY* getBufferPointerv) (GLenum target, GLenum pname, GLvoid** params);
			GAMEDLL static void (APIENTRY* getBufferSubData) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid* data);
			GAMEDLL static GLboolean(APIENTRY* isBuffer) (GLuint buffer);
			GAMEDLL static GLvoid* (APIENTRY* mapBuffer) (GLenum target, GLenum access);
			GAMEDLL static GLvoid* (APIENTRY* mapBufferRange) (GLenum target, GLintptrARB offset, GLsizeiptrARB length, GLenum access);
			GAMEDLL static GLboolean(APIENTRY* unmapBuffer) (GLenum target);
			GAMEDLL static void (APIENTRY* bufferStorage) (GLenum, GLsizeiptrARB, const GLvoid*, GLbitfield);
			GAMEDLL static void (APIENTRY* bindBufferBase) (GLenum target, GLuint index, GLuint buffer);

			//arrays
			GAMEDLL static void (APIENTRY* genVertexArrays) (GLsizei n, GLuint *arrays);
			GAMEDLL static void (APIENTRY* bindVertexArray) (GLuint array);
			GAMEDLL static void (APIENTRY* deleteVertexArrays) (GLsizei n, GLuint *arrays);
			GAMEDLL static void (APIENTRY* enableVertexAttribArray) (GLuint index);
			GAMEDLL static void (APIENTRY* vertexAttribPointer) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer);
			GAMEDLL static GLboolean(APIENTRY* isVertexArray) (GLuint array);

			//framebuffers
			GAMEDLL static void (APIENTRY* genFramebuffers) (GLsizei n, GLuint *framebuffers);
			GAMEDLL static void (APIENTRY* deleteFramebuffers) (GLsizei n, const GLuint *framebuffers);
			GAMEDLL static void (APIENTRY* bindFramebuffer) (GLenum target, GLuint framebuffer);
			GAMEDLL static void (APIENTRY* framebufferTexture2D) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
			GAMEDLL static void (APIENTRY* genRenderBuffers) (GLsizei n, GLuint *buffer);
			GAMEDLL static void (APIENTRY* deleteRenderBuffers) (GLsizei n, const GLuint *buffer);
			GAMEDLL static void (APIENTRY* bindRenderBuffer) (GLenum target, const GLuint buffer);
			GAMEDLL static void (APIENTRY* framebufferRenderbuffer) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
			GAMEDLL static void (APIENTRY* renderbufferStorage) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
			GAMEDLL static GLenum(APIENTRY* checkFramebufferStatus) (GLenum target);
			GAMEDLL static void (APIENTRY* blitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
			GAMEDLL static void (APIENTRY* drawBuffers) (GLsizei n, const GLenum *bufs);

			//misc
			GAMEDLL static void (APIENTRY* memoryBarrier) (GLbitfield barriers);
			GAMEDLL static void (APIENTRY* texStorage2D) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height);
			GAMEDLL static void (APIENTRY* generateMipmap) (GLuint target);

			//shaders
			GAMEDLL static GLint(APIENTRY* deleteObject) (GLenum object);
			GAMEDLL static void (APIENTRY* shaderSource) (GLuint shader, GLenum number_strings, const char **strings, GLint *length);
			GAMEDLL static void (APIENTRY* compileShader) (GLenum shader);
			GAMEDLL static void (APIENTRY* attachObject) (GLenum program, GLenum shader);
			GAMEDLL static void (APIENTRY* linkProgram) (GLenum program);
			GAMEDLL static void (APIENTRY* useProgramObject) (GLhandleARB object);
			GAMEDLL static void (APIENTRY* useProgram) (GLuint program);
			GAMEDLL static GLhandleARB(APIENTRY* createProgramObject) ();
			GAMEDLL static GLhandleARB(APIENTRY* createShaderObject) (GLenum shaderType);
			GAMEDLL static void (APIENTRY* activeTexture) (GLenum texture);
			GAMEDLL static GLint (APIENTRY* getUniformLocation) (GLhandleARB program, const GLcharARB *name);
			GAMEDLL static GLint (APIENTRY* getAttribLocation) (GLhandleARB program, const GLcharARB *name);
			GAMEDLL static void (APIENTRY* getShaderInfoLog) (GLuint shader, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
			GAMEDLL static void (APIENTRY* bindFragDataLocation) (GLuint program, GLuint colorNumber, const char *name);
			GAMEDLL static void (APIENTRY* uniform1i) (GLint location, GLint v0);
			GAMEDLL static void (APIENTRY* uniformMatrix4fv) (GLint location, GLsizei count, bool transpose, const GLfloat *value);
			GAMEDLL static void (APIENTRY* uniformMatrix4dv) (GLint location, GLsizei count, bool transpose, const GLdouble *value);
			GAMEDLL static void (APIENTRY* uniform4fv) (GLint location, int count, GLfloat *v0);
			GAMEDLL static void (APIENTRY* uniformMatrix3fv) (GLint location, GLsizei count, bool transpose, const GLfloat *value);
			GAMEDLL static void (APIENTRY* uniform1f) (GLint location, GLfloat v0);
			GAMEDLL static void (APIENTRY* uniform4iv) (GLint location, int count, GLint *v0);
			GAMEDLL static void (APIENTRY* uniform3fv) (GLint location, int count, GLfloat *v0);
			GAMEDLL static void (APIENTRY* uniform2fv) (GLint location, int count, GLfloat* v0);
			GAMEDLL static GLboolean (APIENTRY* isProgram) (GLuint program);
			GAMEDLL static GLboolean (APIENTRY* isShader) (GLuint shader);


			//compute
			GAMEDLL static void (APIENTRY* dispatchCompute) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
			GAMEDLL static GLuint(APIENTRY* getProgramResourceIndex) (GLuint program, GLenum programInterface, const char* name);
			GAMEDLL static void (APIENTRY* shaderStorageBlockBinding) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);
			GAMEDLL static void (APIENTRY* bindImageTexture) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
		};
	}
}<file_sep>/core-game/gameMesh/glGameMesh.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {

	GAMEDLL void glGameMesh::dispose() {
		if (glExt::isBuffer(buff[0]))
			glExt::deleteBuffers(6, buff);
		if (glExt::isVertexArray(vao))
			glExt::deleteVertexArrays(1, &vao);
		memset(buff, 0, sizeof(buff));
		ind = 0;
	}

	GAMEDLL glGameMesh::~glGameMesh() {
		dispose();
	}

	GAMEDLL bool glGameMesh::make(GameMesh& mesh, glShader& shader, const char* pos, const char* nor, const char* tex) {
		if (mesh.position.count() < 1 || mesh.indices.count() < 0)
			return 0;

		ind = mesh.indices.count();
		int index;

		vao = 0;
		glExt::genVertexArrays(1, &vao);
		glExt::genBuffers(6, buff);
		glExt::bindVertexArray(vao);

		glExt::bindBuffer(GL_ARRAY_BUFFER, buff[0]);
		glExt::bufferData(GL_ARRAY_BUFFER, mesh.position.count() * sizeof(vec3), mesh.position, GL_STATIC_DRAW);
		index = glExt::getAttribLocation(shader, pos);
		glExt::enableVertexAttribArray(index);
		glExt::vertexAttribPointer(index, 3, GL_FLOAT, false, 0, 0);

		glExt::bindBuffer(GL_ARRAY_BUFFER, buff[1]);
		glExt::bufferData(GL_ARRAY_BUFFER, mesh.normal.count() * sizeof(vec3), mesh.normal, GL_STATIC_DRAW);
		index = glExt::getAttribLocation(shader, nor);
		glExt::enableVertexAttribArray(index);
		glExt::vertexAttribPointer(index, 3, GL_FLOAT, false, 0, 0);

		glExt::bindBuffer(GL_ARRAY_BUFFER, buff[2]);
		glExt::bufferData(GL_ARRAY_BUFFER, mesh.texcoord.count() * sizeof(vec2), mesh.texcoord, GL_STATIC_DRAW);
		index = glExt::getAttribLocation(shader, tex);
		glExt::enableVertexAttribArray(index);
		glExt::vertexAttribPointer(index, 2, GL_FLOAT, false, 0, 0);

		glExt::bindBuffer(GL_ELEMENT_ARRAY_BUFFER, buff[3]);
		glExt::bufferData(GL_ELEMENT_ARRAY_BUFFER, mesh.indices.count() * sizeof(int), mesh.indices, GL_STATIC_DRAW);

		glExt::bindVertexArray(0);


		return 1;
	}

	GAMEDLL bool glGameMesh::make(GameMesh& mesh, glShader& shader, const char* pos, const char* nor, const char* tan, const char* btan, const char* tex) {
		if (mesh.position.count() < 1 || mesh.indices.count() < 0)
			return 0;

		buffer<vec3> tangents;
		buffer<vec3> bitangents;
		mesh.computeTangentSpace(tangents, bitangents);

		ind = mesh.indices.count();
		int index;

		vao = 0;
		glExt::genVertexArrays(1, &vao);
		glExt::genBuffers(6, buff);
		glExt::bindVertexArray(vao);

		glExt::bindBuffer(GL_ARRAY_BUFFER, buff[0]);
		glExt::bufferData(GL_ARRAY_BUFFER, mesh.position.count() * sizeof(vec3), mesh.position, GL_STATIC_DRAW);
		index = glExt::getAttribLocation(shader, pos);
		glExt::enableVertexAttribArray(index);
		glExt::vertexAttribPointer(index, 3, GL_FLOAT, false, 0, 0);

		glExt::bindBuffer(GL_ARRAY_BUFFER, buff[1]);
		glExt::bufferData(GL_ARRAY_BUFFER, mesh.normal.count() * sizeof(vec3), mesh.normal, GL_STATIC_DRAW);
		index = glExt::getAttribLocation(shader, nor);
		glExt::enableVertexAttribArray(index);
		glExt::vertexAttribPointer(index, 3, GL_FLOAT, false, 0, 0);

		glExt::bindBuffer(GL_ARRAY_BUFFER, buff[2]);
		glExt::bufferData(GL_ARRAY_BUFFER, tangents.count() * sizeof(vec3), tangents, GL_STATIC_DRAW);
		index = glExt::getAttribLocation(shader, tan);
		glExt::enableVertexAttribArray(index);
		glExt::vertexAttribPointer(index, 3, GL_FLOAT, false, 0, 0);

		glExt::bindBuffer(GL_ARRAY_BUFFER, buff[3]);
		glExt::bufferData(GL_ARRAY_BUFFER, bitangents.count() * sizeof(vec3), bitangents, GL_STATIC_DRAW);
		index = glExt::getAttribLocation(shader, btan);
		glExt::enableVertexAttribArray(index);
		glExt::vertexAttribPointer(index, 3, GL_FLOAT, false, 0, 0);

		glExt::bindBuffer(GL_ARRAY_BUFFER, buff[4]);
		glExt::bufferData(GL_ARRAY_BUFFER, mesh.texcoord.count() * sizeof(vec2), mesh.texcoord, GL_STATIC_DRAW);
		index = glExt::getAttribLocation(shader, tex);
		glExt::enableVertexAttribArray(index);
		glExt::vertexAttribPointer(index, 2, GL_FLOAT, false, 0, 0);

		glExt::bindBuffer(GL_ELEMENT_ARRAY_BUFFER, buff[5]);
		glExt::bufferData(GL_ELEMENT_ARRAY_BUFFER, mesh.indices.count() * sizeof(int), mesh.indices, GL_STATIC_DRAW);

		glExt::bindVertexArray(0);


		return 1;
	}

	GAMEDLL void glGameMesh::drawTris() {
		glExt::bindVertexArray(vao);
		glDrawElements(GL_TRIANGLES, ind, GL_UNSIGNED_INT, 0);
	}

	GAMEDLL void glGameMesh::drawQuads() {
		glExt::bindVertexArray(vao);
		glDrawElements(GL_QUADS, ind, GL_UNSIGNED_INT, 0);
	}
}
<file_sep>/core-game/speleoMesh/glSpeleoMesh.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {

	GAMEDLL void glSpeleoMesh::dispose() {
		glExt::bindVertexArray(0);
		glExt::bindBuffer(GL_ARRAY_BUFFER, 0);
		glExt::bindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
		if (buff[0] && glExt::isBuffer(buff[0]))
			glExt::deleteBuffers(2, buff);
		if (vao && glExt::isVertexArray(vao))
			glExt::deleteVertexArrays(1, &vao);
		memset(buff, 0, sizeof(buff));
		vao = 0;
		ind = 0;
	}

	GAMEDLL glSpeleoMesh::~glSpeleoMesh() {
		dispose();
	}

	GAMEDLL bool glSpeleoMesh::make(const TMesh& mesh, glShader& shader, const char* pos, const char* tex) {
		glGetError(); //clear current error
		if (mesh.position.size() < 1 || mesh.indices.size() < 1)
			return 0;

		ind = 0;
		int index;
		int err = 0;

		buffer<vec3> pbuf(mesh.indices.size());
		for (auto& i : mesh.indices)
			pbuf.push_back(mesh.position[i]);

		vao = 0;
		try {
			glExt::genVertexArrays(1, &vao);
			err = glGetError();
			if (err != 0) { dispose(); throw core::exception("glGenVertexArrays error"); }
			glExt::genBuffers(2, buff);
			err = glGetError();
			if (err != 0) { dispose(); throw core::exception("glGenBuffers error"); }

			glExt::bindVertexArray(vao);
			glExt::bindBuffer(GL_ARRAY_BUFFER, buff[0]);
			glExt::bufferData(GL_ARRAY_BUFFER, pbuf.size() * sizeof(vec3), pbuf, GL_STATIC_DRAW);
			if (glGetError())
				throw core::exception("Error creating position buffer");
			index = glExt::getAttribLocation(shader, pos);
			glExt::enableVertexAttribArray(index);
			glExt::vertexAttribPointer(index, 3, GL_FLOAT, false, 0, 0);
			if (glGetError())
				throw core::exception("Error indexing position buffer");

			glExt::bindBuffer(GL_ARRAY_BUFFER, buff[1]);
			glExt::bufferData(GL_ARRAY_BUFFER, mesh.texcoord.size() * sizeof(vec2), mesh.texcoord, GL_STATIC_DRAW);
			if (glGetError())
				throw core::exception("Error creating texcoord buffer");
			index = glExt::getAttribLocation(shader, tex);
			glExt::enableVertexAttribArray(index);
			glExt::vertexAttribPointer(index, 2, GL_FLOAT, false, 0, 0);
			if (glGetError())
				throw core::exception("Error indexing texcoord buffer");

			glExt::bindVertexArray(0);
			glExt::bindBuffer(GL_ARRAY_BUFFER, 0);
			ind = mesh.indices.size();
		}
		catch (std::exception& e) {
			core::Debug::log("%s\n", e.what());
			dispose();
			glExt::bindVertexArray(0);
			return false;
		}
		return true;
	}

	GAMEDLL void glSpeleoMesh::drawTris() {
		glExt::bindVertexArray(vao);
		glDrawArrays(GL_TRIANGLES, 0, ind);
	}

	GAMEDLL void glSpeleoMesh::drawQuads() {
		glExt::bindVertexArray(vao);
		glDrawArrays(GL_QUADS, 0, ind);
	}
}
<file_sep>/makefile
PROJ = core-game
OUT = libcore-game.so
BIN = bin
BUILD = build
CC = g++ -std=gnu++11 -msse -msse2 -msse3 -msse4 -mavx -mstackrealign -pthread -Wl,--no-as-needed
#WARN = -Wall -fpermissive -Wno-write-strings -Wno-unused-result -Wno-unknown-pragmas -Wno-format-security -Wno-parentheses
WARN = -w
DEFINE = -DDLL_EXPORT
BIN = bin
BUILD = build
INCLUDE = -I"../core/core" -I"core-game/" -I"../core-forms/core-forms" -I"/usr/include"
FLAGS = -O2 $(INCLUDE) $(WARN) $(DEFINE) -fPIC
LIBS = -L"lib" -lfreetype -lcore -lpthread

OBJ = \
	frustum/frustum.o \
	gameMesh/gameMesh.o \
	gameMesh/glGameMesh.o \
	glControl/glFrameImageButton.o \
	glControl/glImageButton.o \
	glExt/glExtensions.o \
	glFrame/glAnimatedFrame.o \
	glFrame/glFrame.o \
	glFramebuffer/glFramebuffer.o \
	glShader/glComputeShader.o \
	glShader/glShader.o \
	glTexture/glTexture.o \
	glTextureMaterial/glTextureMaterial.o \
	speleoMesh/glSpeleoMesh.o \
	speleoMesh/glSpeleoModel.o \
	view/glview.o \
	view/view.o


all: $(OBJ)
	$(CC) -shared $(BIN)/* -o $(BUILD)/$(OUT) $(LIBS)

$(OBJ): %.o: $(PROJ)/%.cpp
	$(CC) -c $< -o $(BIN)/$(notdir $@) $(FLAGS)

clean:
	rm -rf $(BUILD)
	rm -rf $(BIN)
	sudo rm -rf /usr/local/lib/$(OUT)

init:
	mkdir $(BUILD)
	mkdir $(BIN)

install:
	sudo cp $(BUILD)/$(OUT) /usr/local/lib/
<file_sep>/core-game/glControl/glFrameImageButton.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {
	GAMEDLL int glFrameImageButton::onPaint(const eventInfo& e) {
		if (ref == NULL)
			return 1;
		if (!prerendered)
			prerender();
		glBindTexture(GL_TEXTURE_2D, (flags & 4) ? glAct : ((flags & 2 || pinned() || frame&&frame->isVisible()) ? glHov : glDef));
		glVertexPointer(2, GL_FLOAT, 0, pos);
		glTexCoordPointer(2, GL_FLOAT, 0, tex);
		glDrawArrays(GL_QUADS, 0, 4);
		glBindTexture(GL_TEXTURE_2D, 0);
		return 0;
	}
}

<file_sep>/core-game/frustum/frustum.cpp
#include <core>
#include <core-forms>
#include <core-game>

namespace core {

	GAMEDLL void Frustum::get(const View& view, const core::Window& wnd) {
		v[0] = view.unprojectFull(vec4(0, 0, 0, 1), wnd);
		v[1] = view.unprojectFull(vec4((float)wnd.width, 0, 0, 1), wnd);
		v[2] = view.unprojectFull(vec4((float)wnd.width, (float)wnd.height, 0, 1), wnd);
		v[3] = view.unprojectFull(vec4(0, (float)wnd.height, 0, 1), wnd);
		v[4] = view.unprojectFull(vec4(0, 0, 1.0f, 1.0f), wnd);
		v[5] = view.unprojectFull(vec4((float)wnd.width, 0, 1.0f, 1.0f), wnd);
		v[6] = view.unprojectFull(vec4((float)wnd.width, (float)wnd.height, 1.0f, 1.0f), wnd);
		v[7] = view.unprojectFull(vec4(0, (float)wnd.height, 1.0f, 1.0f), wnd);


		p[0] = Math::plane(v[0], v[1], v[2]);
		p[1] = Math::plane(v[4], v[7], v[6]);
		p[2] = Math::plane(v[0], v[4], v[5]);
		p[3] = Math::plane(v[2], v[6], v[7]);
		p[4] = Math::plane(v[0], v[3], v[7]);
		p[5] = Math::plane(v[2], v[1], v[5]);

	}

	GAMEDLL const bool Frustum::aabbIntersection(vec3 a, vec3 b) const {
		vec3 v[8], n;
		v[0] = vec3(a.x, a.y, a.z);
		v[1] = vec3(b.x, a.y, a.z);
		v[2] = vec3(b.x, b.y, a.z);
		v[3] = vec3(a.x, b.y, a.z);
		v[4] = vec3(a.x, a.y, b.z);
		v[5] = vec3(b.x, a.y, b.z);
		v[6] = vec3(b.x, b.y, b.z);
		v[7] = vec3(a.x, b.y, b.z);

		for (int i = 0; i < 6; ++i) {
			int cnt = 8;
			//Distance = DotProduct(V, N) + D
			n = vec3(p[i].x, p[i].y, p[i].z);

			for (int j = 0; j < 8; ++j) {
				if (Math::dot(v[j], n) + p[i].w > 0.0f)
					--cnt;
			}
			if (cnt == 0)return 0;
		}
		return 1;
	}


	GAMEDLL const bool Frustum::sphereIntersection(vec3 c, float r) const {
		for (int i = 0; i < 6; ++i) {
			int cnt = 8;
			//Distance = DotProduct(V, N) + D
			vec3 n = vec3(p[i].x, p[i].y, p[i].z);

			if (Math::dot(c, n) + p[i].w > r)
				return 0;
		}
		return 1;
	}
}<file_sep>/core-game/glFrame/glAnimatedFrame.h
#pragma once
namespace core {
	class glAnimatedFrame: public glFrame {
	public:
		Timer<float> timer;
		float fadeInterval;
		glAnimatedFrame() :glFrame(), fadeInterval(125.0f) {}
		virtual ~glAnimatedFrame() {}
		virtual int show() { if (!visible)timer.start(); return glFrame::show(); }
		virtual int hide() { if(visible)timer.start(); return glFrame::hide(); }

		GAMEDLL virtual int onPaint(const eventInfo& e);
		virtual bool isVisible() { return visible || (!visible&&timer.stop() < fadeInterval); }
	};
}
