Skip to content

Commit 722d977

Browse files
committed
Merge pull request #531 from NiDragon/setTextureData-Update
Texture/Image Update
2 parents 871d761 + 960f627 commit 722d977

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

Core/Contents/Source/PolyGLTexture.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,10 @@ void OpenGLTexture::setGLInfo(GLuint textureID, GLuint frameBufferID) {
122122
}
123123

124124
void OpenGLTexture::setTextureData(char *data) {
125-
/*
125+
memcpy(textureData, data, width * height * pixelSize);
126+
126127
glBindTexture(GL_TEXTURE_2D, textureID);
127-
glDrawBuffer(GL_AUX0);
128-
glDrawPixels(width, height, glTextureType, pixelType, data);
129-
glReadBuffer(GL_AUX0);
130-
// glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 128, 128, 0);
131-
*/
128+
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, glTextureType, pixelType, textureData);
132129
}
133130

134131
OpenGLTexture::~OpenGLTexture() {

Core/Contents/Source/PolyImage.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,19 @@ void Image::drawLine(int x0, int y0, int x1, int y1, Color col) {
393393
}
394394

395395
void Image::fill(Color color) {
396-
unsigned int val = color.getUint();
397-
unsigned int *imageData32 = (unsigned int*) imageData;
398-
for(int i=0; i< width*height; i++) {
399-
imageData32[i] = val;
396+
if(imageType == Image::IMAGE_RGB) {
397+
for(int i = 0; i < width*height*pixelSize; i+=3) {
398+
imageData[i] = color.r;
399+
imageData[i+1] = color.g;
400+
imageData[i+2] = color.b;
401+
}
402+
} else {
403+
unsigned int val = color.getUint();
404+
unsigned int *imageData32 = (unsigned int*) imageData;
405+
406+
for(int i=0; i< width*height; i++) {
407+
imageData32[i] = val;
408+
}
400409
}
401410
}
402411

0 commit comments

Comments
 (0)