WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
ExporterPlugin.cpp
Go to the documentation of this file.
1#include "ExporterPlugin.h"
2#include <string>
3#include "SoftwareImage.h"
4
5void ExporterPlugin::exportGLTexture(GLuint id, std::wstring filename) const
6{
7 LOG_INFO << "Exporting GL texture with id " << id << " in " << filename.c_str();
8 glEnable(GL_TEXTURE_2D);
9 glBindTexture(GL_TEXTURE_2D, id);
10
11 GLint width, height;
12 glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
13 glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
14
15 unsigned char* pixels = new unsigned char[width * height * 4];
16
17 glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
18
19 const SoftwareImage texture(pixels, width, height);
20 texture.savePNG(filename);
21
22 delete[] pixels;
23
24 glBindTexture(GL_TEXTURE_2D, 0);
25 glDisable(GL_TEXTURE_2D);
26}
#define LOG_INFO
Definition Logger.h:10
void exportGLTexture(GLuint id, std::wstring filename) const
CPU-side image buffer storing BGRA pixel data.
bool savePNG(const std::string &path) const
Save as PNG to the given file path.