Quellcode durchsuchen

Texture/Image Update

Textures can now be updated instead of recreated for better performance.
Image will no longer crash when creating an IMAGE_RGB format image.
NiDragon vor 11 Jahren
Ursprung
Commit
960f62767b
2 geänderte Dateien mit 16 neuen und 10 gelöschten Zeilen
  1. 3 6
      Core/Contents/Source/PolyGLTexture.cpp
  2. 13 4
      Core/Contents/Source/PolyImage.cpp

+ 3 - 6
Core/Contents/Source/PolyGLTexture.cpp

@@ -122,13 +122,10 @@ void OpenGLTexture::setGLInfo(GLuint textureID, GLuint frameBufferID) {
 }
 }
 
 
 void OpenGLTexture::setTextureData(char *data) {
 void OpenGLTexture::setTextureData(char *data) {
-/*
+	memcpy(textureData, data, width * height * pixelSize);
+
 	glBindTexture(GL_TEXTURE_2D, textureID);
 	glBindTexture(GL_TEXTURE_2D, textureID);
-	glDrawBuffer(GL_AUX0);
-	glDrawPixels(width, height, glTextureType, pixelType, data);
-	glReadBuffer(GL_AUX0);
-//	glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 128, 128, 0);
-*/
+	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, glTextureType, pixelType, textureData);	
 }
 }
 
 
 OpenGLTexture::~OpenGLTexture() {
 OpenGLTexture::~OpenGLTexture() {

+ 13 - 4
Core/Contents/Source/PolyImage.cpp

@@ -392,10 +392,19 @@ void Image::drawLine(int x0, int y0, int x1, int y1, Color col) {
 }
 }
 
 
 void Image::fill(Color color) {
 void Image::fill(Color color) {
-	unsigned int val = color.getUint();
-	unsigned int *imageData32 = (unsigned int*) imageData;
-	for(int i=0; i< width*height; i++) {
-		imageData32[i] = val;
+	if(imageType == Image::IMAGE_RGB) {
+		for(int i = 0; i < width*height*pixelSize; i+=3) {
+			imageData[i] = color.r;
+			imageData[i+1] = color.g;
+			imageData[i+2] = color.b;
+		}
+	} else {
+		unsigned int val = color.getUint();
+		unsigned int *imageData32 = (unsigned int*) imageData;
+
+		for(int i=0; i< width*height; i++) {
+			imageData32[i] = val;
+		}
 	}
 	}
 }
 }