#ifndef STIM_GL_TEXTURE_H #define STIM_GL_TEXTURE_H /* includes not necessary (yet) #include #include */ #include #include #include #include "../grids/image_stack.h" #include //#include #include "./error.h" namespace stim{ /* class gl_texture Uses image_stack class in order to create a texture object. */ template class gl_texture : public virtual image_stack { protected: std::string path; GLuint texID; using image_stack::R; using image_stack::ptr; using image_stack::samples; public: /* Method: Basic Constructor Inputs: Outputs: Creates an instance of the gl_texture object. */ gl_texture(){ } /* Method: Path Constructor Inputs: string file_path Outputs: Creates an instance of the gl_texture object with a path to the data. */ gl_texture(std::string file_path) { path = file_path; } /* Method: setPath Inputs:string file_Path Outputs: sets the protected path variable of an instance of the gl_texture class to the method input. */ void setPath(std::string file_path) { path = file_path; } /* Method: getPath Inputs: Outputs: string path Returns the path associated with an instance of the gl_texture class. */ std::string getPath() { return path; } /* Method: getTexture Inputs: Outputs: GLuint texID Returns the id of the texture create by/associated with the instance of the gl_texture class. */ GLuint getTexture() { return texID; } /* Method: createTexture Inputs: Outputs: Creates a texture and from the data located at and assigns that texture to texID */ //TO DO :::: Add handling for 2D and 1D textures void createTexture() { image_stack::load_images(path.append("/*.jpg")); glPixelStorei(GL_UNPACK_ALIGNMENT,1); glGenTextures(1, &texID); CHECK_OPENGL_ERROR glBindTexture(GL_TEXTURE_3D, texID); CHECK_OPENGL_ERROR glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT); CHECK_OPENGL_ERROR glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT); CHECK_OPENGL_ERROR glTexImage3D(GL_TEXTURE_3D, 0, // GL_RGB16, 1, R[1], R[2], R[3], 0, GL_LUMINANCE, // GL_RGB, GL_UNSIGNED_BYTE, ptr); //GL_UNSIGNED_BYTE can be TYPES, convert to GL equivalents CHECK_OPENGL_ERROR glPixelStorei(GL_PACK_ALIGNMENT,1); } //Binds the texture void Bind() { glBindTexture(GL_TEXTURE_3D, texID); } stim::vec getDims() { return R; } T* getData() { return ptr; } //TO DO:::add methods for handling the cases of T and convert them to GL equivalent. }; } #endif