/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ /** * @file Texture.h * @brief クラス MGGridCursor の宣言 */ #ifndef _mgTexture_HH #define _mgTexture_HH #include "mg/MGCL.h" class MGImage; class mgGLSLProgram; // @class mgTexture Texture.h "mgGL/Texture.h" ///Texture definition class. ///Before use of mgTexture, set_image must be invoked, and ///set_sampler is optionally invoked. If set_sampler is not invoked, ///uniform of spampler2D "texture1" is assumed. ///Since mgTexture does not invoke glUseProgram(mgGLSLProgram's use() function) ///the current program's uniform variable texture1(or the variable set by set_sampler) ///must be spamler2D. ///When set_textureUnit is not invoked, unit number 0 is assumed. class MG_DLL_DECLR mgTexture{ public: /// デフォルトコンストラクター ///Before use of mgTexture, set_image and set_sampler must be invoked. mgTexture( GLenum target=GL_TEXTURE_2D///Currently only GL_TEXTURE_2D is allowed. ); ~mgTexture(); ///Set the glsl program and sampler variable name of ///*****glUseProgram() is not invoked, glsl must be the current program. void set_sampler(mgGLSLProgram* glsl, const std::string& samplerName); const std::string& getDefaultSamplerVariable()const; ///image データをtextureにセットする /// @note pixelsピクセルデータのフォーマットについて説明すると、 /// GLuint 型の配列を利用し、各 4 バイトを 1 ピクセルの色に対応させている。 /// 整数の上位バイトから A, B, G, R の順に格納されていることを前提とする。 /// 例えば値 0xFF000000, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF はそれぞれ /// 黒、青、緑、赤を意味する。 ///Set the image data. set_image() invokes: ///1. glGenTextures(if m_textureID was 0) ///2. glBindTexture ///3. glTexImage2D or glTexStorege2D ///4. glTexSubImage2D ///*******After set_image is invoked, image data is unnecessary since the data ///is transfered to GPU. void set_image( GLsizei width ///< ビットマップデータの横幅。ピクセル幅 ,GLsizei height///< ビットマップデータの縦幅。 ,const GLuint* pixels///< RGBA バイト列。各整数の上位バイトが A 値。 ,bool mutableTexture=true///