|
|
|
@ -1,10 +1,8 @@
@@ -1,10 +1,8 @@
|
|
|
|
|
#include "ImageComponent.h" |
|
|
|
|
#include <cmath> |
|
|
|
|
#include <iostream> |
|
|
|
|
#include <cstring> |
|
|
|
|
#include "../../pnm.h" |
|
|
|
|
#ifdef __MINGW32__ |
|
|
|
|
#include "../../../anime.h" |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
ImageComponent::ImageComponent(std::string filename, const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int passedWindowWidth, const int passedWindowHeight) : BoxComponent(rawX, rawY, rawWidth, rawHeight, 0x00000000, passedWindowWidth, passedWindowHeight) { |
|
|
|
|
//std::cout << "ImageComponent::ImageComponent" << std::endl;
|
|
|
|
@ -16,17 +14,7 @@ ImageComponent::ImageComponent(std::string filename, const float rawX, const flo
@@ -16,17 +14,7 @@ ImageComponent::ImageComponent(std::string filename, const float rawX, const flo
|
|
|
|
|
y = rawY; |
|
|
|
|
width = rawWidth; |
|
|
|
|
height = rawHeight; |
|
|
|
|
|
|
|
|
|
#ifdef __MINGW32__ // the old "huge string" works fine with mingw
|
|
|
|
|
//
|
|
|
|
|
for (int py = 0; py < 1024; py++) { |
|
|
|
|
for (int px = 0; px < 1024; px++) { |
|
|
|
|
for (int i = 0; i < 4; i++) { |
|
|
|
|
data[1023 - py][px][i] = anime.pixel_data[((px * 4) + (py * 4 * 1024)) + i]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#else // this is either non-Windows or Microsoft C/C++
|
|
|
|
|
|
|
|
|
|
RGBAPNMObject *anime = readPPM(filename.c_str()); |
|
|
|
|
if (!anime) { |
|
|
|
|
std::cout << "Can't set up image component, couldn't read " << filename << std::endl; |
|
|
|
@ -41,7 +29,6 @@ for (int py = 0; py < 1024; py++) {
@@ -41,7 +29,6 @@ for (int py = 0; py < 1024; py++) {
|
|
|
|
|
anime = nullptr; |
|
|
|
|
} |
|
|
|
|
std::cout << "loading " << filename << " at " << loadWidth << "," << loadHeight << std::endl; |
|
|
|
|
|
|
|
|
|
for (unsigned int py = 0; py < loadHeight; py++) { |
|
|
|
|
for (unsigned int px = 0; px < loadWidth; px++) { |
|
|
|
|
if (anime) { |
|
|
|
@ -54,7 +41,6 @@ for (int py = 0; py < 1024; py++) {
@@ -54,7 +41,6 @@ for (int py = 0; py < 1024; py++) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
float vx = rawX; |
|
|
|
|
float vy = rawY; |
|
|
|
@ -93,17 +79,11 @@ for (int py = 0; py < 1024; py++) {
@@ -93,17 +79,11 @@ for (int py = 0; py < 1024; py++) {
|
|
|
|
|
glGenTextures(1, &texture); |
|
|
|
|
glBindTexture(GL_TEXTURE_2D, texture); |
|
|
|
|
|
|
|
|
|
#ifndef __MINGW32__ |
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, static_cast<int>(loadWidth), static_cast<int>(loadHeight), 0, GL_RGBA, GL_UNSIGNED_BYTE, data); |
|
|
|
|
#else |
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); |
|
|
|
|
#endif |
|
|
|
|
glGenerateMipmap(GL_TEXTURE_2D); |
|
|
|
|
|
|
|
|
|
#ifndef __MINGW32__ |
|
|
|
|
if (anime) { |
|
|
|
|
tlsf_free(anime->m_Ptr); |
|
|
|
|
delete anime; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|