TerraForge3D  2.3.1
3D Terrain And Landscape Generator

◆ Resize()

void Texture2D::Resize ( int  width,
int  height,
bool  resetOpenGL = true 
)

Definition at line 126 of file Texture2D.cpp.

127{
128 if (m_Width == width && m_Height == height)
129 {
130 return;
131 }
132
133 if (!m_Data)
134 {
135 return;
136 }
137
138 unsigned char *data = (unsigned char *)malloc(width * height * 3 * sizeof(unsigned char));
139 memset(data, 0, width * height * 3 * sizeof(unsigned char));
140 avir::CImageResizer<> ImageResizer(8);
141 ImageResizer.resizeImage(m_Data, m_Width, m_Height, 0, data, width, height, 3, 0);
142
143 if (data)
144 {
145 if (m_Data)
146 {
147 delete m_Data;
148 }
149
150 m_Data = data;
151 m_Width = width;
152 m_Height = height;
153
154 if (resetOpenGL)
155 {
156 glBindTexture(GL_TEXTURE_2D, m_RendererID);
157 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, m_Width, m_Height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
158 glGenerateMipmap(GL_TEXTURE_2D);
159 }
160 }
161}