PageRenderTime 15ms CodeModel.GetById 12ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Example_RendererBaseUsage/Example_TextureCubeFile.h

http://github.com/Akranar/daguerreo
C Header | 42 lines | 34 code | 8 blank | 0 comment | 0 complexity | d00d501f4a16dd6fbcffeec89ce0f424 MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1, LGPL-3.0, GPL-2.0
 1#ifndef _EXAMPLE_TEXTURE_CUBE_FILE_H_
 2#define _EXAMPLE_TEXTURE_CUBE_FILE_H_
 3
 4#include "ExLib_RendererBase.h"
 5#include "ExLib_TextureLoader.h"
 6
 7class Example_TextureCubeFile
 8{
 9	TextureCube texture_cube;
10	ShaderProgram * shader_program;
11	RendererBase * renderer;
12	unsigned int unit;
13public:
14	void Init(RendererBase * _renderer, ShaderProgram * _shader_program, unsigned int _unit, const char * filenames[6])
15	{
16		shader_program = _shader_program;
17		renderer = _renderer;
18		unit = _unit;
19
20
21		DescTextureCube texdesc;
22		texdesc.BindFlags = BIND_SHADER_RESOURCE;
23		texdesc.MipLevels = 0;
24		texdesc.Usage = TEXTURE_USAGE_WRITE_ONLY;
25		
26		FixedArray<unsigned char> texdata;
27		TextureLoader::LoadTextureCube(filenames, texdesc, texdata);
28		renderer->CreateResource(texdesc, &texture_cube);
29
30	}
31
32	void Deinit()
33	{
34		renderer->Delete(&texture_cube);
35	}
36
37	void PreRender()
38	{
39		renderer->Bind(shader_program, unit, &texture_cube);
40	}
41};
42#endif