mirror of
https://github.com/devZoGok/vb01.git
synced 2026-08-27 03:53:24 +00:00
loading new image data into a texture
additional ImageAsset property
This commit is contained in:
+12
-9
@@ -60,6 +60,16 @@ namespace vb01{
|
||||
}
|
||||
}
|
||||
|
||||
void Texture::loadImageData(ImageAsset *asset, int i){
|
||||
width = asset->width;
|
||||
height = asset->height;
|
||||
|
||||
glGenTextures(1, &texture[i]);
|
||||
glBindTexture(GL_TEXTURE_2D, texture[i]);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, png ? GL_RGBA : GL_RGB, width, height, 0, png ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, asset->image);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void Texture::create2DTexture(bool flip){
|
||||
mixRatio = .1;
|
||||
|
||||
@@ -69,19 +79,12 @@ namespace vb01{
|
||||
if(paths[i].substr(length - 4, string::npos) == ".png")
|
||||
png = true;
|
||||
|
||||
glGenTextures(1, &texture[i]);
|
||||
glBindTexture(GL_TEXTURE_2D, texture[i]);
|
||||
loadImageData((ImageAsset*)AssetManager::getSingleton()->getAsset(paths[i]));
|
||||
|
||||
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_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
ImageAsset *asset = (ImageAsset*)AssetManager::getSingleton()->getAsset(paths[i]);
|
||||
width = asset->width;
|
||||
height = asset->height;
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, png ? GL_RGBA : GL_RGB, width, height, 0, png ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, asset->image);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user