Big changes
This commit is contained in:
@@ -118,7 +118,7 @@ void Texture2D::CreateRaw(void* data, int width, int height, PixelFormat pf)
|
||||
|
||||
glGenTextures(1, &m_handle);
|
||||
glBindTexture(GL_TEXTURE_2D, m_handle);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, getGLInternalPF(pf), width, height, 0, getGLInternalPF(pf), GL_UNSIGNED_BYTE, data);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GetGLInternalPF(pf), width, height, 0, GetGLInternalPF(pf), GL_UNSIGNED_BYTE, data);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
@@ -131,6 +131,9 @@ void Texture2D::CreateRaw(void* data, int width, int height, PixelFormat pf)
|
||||
|
||||
void Texture2D::GenerateMipmaps()
|
||||
{
|
||||
assert(0 && "Not Implemented");
|
||||
|
||||
#if 0
|
||||
glBindTexture(GL_TEXTURE_2D, m_handle);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
@@ -142,6 +145,7 @@ void Texture2D::GenerateMipmaps()
|
||||
//}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture2D::Bind()
|
||||
@@ -151,105 +155,24 @@ void Texture2D::Bind()
|
||||
|
||||
void Texture2D::SetWrapS(TextureWrap wrap)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, getGlWrap(wrap));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GetGlWrap(wrap));
|
||||
}
|
||||
|
||||
void Texture2D::SetWrapT(TextureWrap wrap)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, getGlWrap(wrap));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GetGlWrap(wrap));
|
||||
}
|
||||
|
||||
void Texture2D::SetMin(TextureFilter filter)
|
||||
{
|
||||
GLint param = 0;
|
||||
param = getGlTexFilter(filter);
|
||||
param = GetGlTexFilter(filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, param);
|
||||
}
|
||||
|
||||
void Texture2D::SetMag(TextureFilter filter)
|
||||
{
|
||||
GLint param = 0;
|
||||
param = getGlTexFilter(filter);
|
||||
param = GetGlTexFilter(filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, param);
|
||||
}
|
||||
|
||||
GLint GetGlWrap(TextureWrap wrap)
|
||||
{
|
||||
GLint param = 0;
|
||||
|
||||
if (wrap == TextureWrap::Repeat)
|
||||
param = GL_REPEAT;
|
||||
else if (wrap == TextureWrap::MirroredRepeat)
|
||||
param = GL_MIRRORED_REPEAT;
|
||||
else if (wrap == TextureWrap::ClampToEdge)
|
||||
param = GL_CLAMP_TO_EDGE;
|
||||
else if (wrap == TextureWrap::ClampToBorder)
|
||||
param = GL_CLAMP_TO_BORDER;
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
GLint GetGlTexFilter(TextureFilter filter)
|
||||
{
|
||||
GLint param = 0;
|
||||
|
||||
if (filter == TextureFilter::Linear)
|
||||
param = GL_LINEAR;
|
||||
else if (filter == TextureFilter::Nearest)
|
||||
param = GL_NEAREST;
|
||||
else if (filter == TextureFilter::LinearMipmapLinear)
|
||||
param = GL_LINEAR_MIPMAP_LINEAR;
|
||||
else if (filter == TextureFilter::LinearMipmapNearest)
|
||||
param = GL_LINEAR_MIPMAP_NEAREST;
|
||||
else if (filter == TextureFilter::NearestMipmapLinear)
|
||||
param = GL_NEAREST_MIPMAP_LINEAR;
|
||||
else if (filter == TextureFilter::NearestMipmapNearest)
|
||||
param = GL_NEAREST_MIPMAP_NEAREST;
|
||||
|
||||
return param;
|
||||
}
|
||||
|
||||
uint getGLPF(PixelFormat pf)
|
||||
{
|
||||
return 0;
|
||||
//return uint32_t();
|
||||
}
|
||||
|
||||
// Kirill: Remove to render_main.cpp or something else
|
||||
uint getGLInternalPF(PixelFormat pf)
|
||||
{
|
||||
switch (pf)
|
||||
{
|
||||
case PF_UNKNOWN:
|
||||
return 0;
|
||||
|
||||
case PF_R8G8B8:
|
||||
case PF_R8G8B8F:
|
||||
return GL_RGB;
|
||||
|
||||
case PF_R8G8B8A8:
|
||||
case PF_R8G8B8A8F:
|
||||
return GL_RGBA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint getGLTypePF(PixelFormat pf)
|
||||
{
|
||||
switch (pf)
|
||||
{
|
||||
case PF_UNKNOWN:
|
||||
return 0;
|
||||
|
||||
case PF_R8G8B8:
|
||||
case PF_R8G8B8A8:
|
||||
return GL_UNSIGNED_BYTE;
|
||||
|
||||
case PF_R8G8B8F:
|
||||
case PF_R8G8B8A8F:
|
||||
return GL_FLOAT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user