Changeset 186
- Timestamp:
- 06/01/10 13:21:18 (2 years ago)
- Files:
-
- trunk/build/buildyage.d (modified) (1 diff)
- trunk/src/demo1/main.d (modified) (1 diff)
- trunk/src/tests/integration/main.d (modified) (3 diffs)
- trunk/src/yage/core/object2.d (modified) (1 diff)
- trunk/src/yage/gui/style.d (modified) (2 diffs)
- trunk/src/yage/gui/surface.d (modified) (2 diffs)
- trunk/src/yage/gui/surfacegeometry.d (modified) (2 diffs)
- trunk/src/yage/resource/collada.d (modified) (9 diffs)
- trunk/src/yage/resource/manager.d (modified) (5 diffs)
- trunk/src/yage/resource/material.d (modified) (3 diffs)
- trunk/src/yage/resource/texture.d (modified) (7 diffs)
- trunk/src/yage/scene/camera.d (modified) (1 diff)
- trunk/src/yage/scene/terrain.d (modified) (5 diffs)
- trunk/src/yage/system/graphics/api/api.d (modified) (1 diff)
- trunk/src/yage/system/graphics/api/opengl.d (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/buildyage.d
r183 r186 10 10 */ 11 11 12 const char[] app = "demo1"; // set which program to build against yage.13 //const char[] app = "tests/integration/main.d";12 //const char[] app = "demo1"; // set which program to build against yage. 13 const char[] app = "tests/integration/main.d"; 14 14 15 15 /** trunk/src/demo1/main.d
r183 r186 94 94 pass.ambient = "#fff"; 95 95 pass.textures = [ 96 Texture (ResourceManager.texture("space/rocky2.jpg")),97 Texture (ResourceManager.texture("space/rocky2-normal.jpg", GPUTexture.Format.AUTO_UNCOMPRESSED))96 TextureInstance(ResourceManager.texture("space/rocky2.jpg")), 97 TextureInstance(ResourceManager.texture("space/rocky2-normal.jpg", Texture.Format.AUTO_UNCOMPRESSED)) 98 98 ]; 99 99 pass.autoShader = MaterialPass.AutoShader.PHONG; trunk/src/tests/integration/main.d
r184 r186 155 155 // Create a textured plane 156 156 Geometry geometry = Geometry.createPlane(4, 4); 157 Texture texture = Texture(ResourceManager.texture("space/rocky2.jpg"));158 Texture normal = Texture(ResourceManager.texture("space/rocky2-normal.jpg"));157 auto texture = TextureInstance(ResourceManager.texture("space/rocky2.jpg")); 158 auto normal = TextureInstance(ResourceManager.texture("space/rocky2-normal.jpg")); 159 159 texture.transform = Matrix().scale(Vec3f(8)); 160 160 … … 272 272 // Create a textured plane 273 273 Geometry geometry = Geometry.createPlane(1, 1); 274 Texture texture = Texture(ResourceManager.texture("misc/reference2.png"));274 auto texture = TextureInstance(ResourceManager.texture("misc/reference2.png")); 275 275 276 276 pass = geometry.getMeshes()[0].getMaterial().getPass(); … … 282 282 283 283 Geometry geometry2 = Geometry.createPlane(1, 1); 284 Texture texture2 = Texture(ResourceManager.texture("fx/smoke.png"));284 auto texture2 = TextureInstance(ResourceManager.texture("fx/smoke.png")); 285 285 286 286 MaterialPass pass2 = geometry2.getMeshes()[0].getMaterial().getPass(); trunk/src/yage/core/object2.d
r180 r186 195 195 196 196 /* 197 // Itemporal willbe implemented by:197 // Itemporal may be implemented by: 198 198 Timer 199 199 Repeater (loop makes no sense) trunk/src/yage/gui/style.d
r175 r186 233 233 union { 234 234 struct { 235 GPUTexture borderTopImage; /// Border Images (TODO: support border-style and border-image-widths?)236 GPUTexture borderRightImage; /// ditto237 GPUTexture borderBottomImage; /// ditto238 GPUTexture borderLeftImage; /// ditto239 } 240 GPUTexture[4] borderImage; /// Set the four top/right/bottom/left border images in one array.241 } 242 GPUTexture borderCenterImage; /// Border center image (not a part of CSS3, this image is stretched to fit within the borders).235 Texture borderTopImage; /// Border Images (TODO: support border-style and border-image-widths?) 236 Texture borderRightImage; /// ditto 237 Texture borderBottomImage; /// ditto 238 Texture borderLeftImage; /// ditto 239 } 240 Texture[4] borderImage; /// Set the four top/right/bottom/left border images in one array. 241 } 242 Texture borderCenterImage; /// Border center image (not a part of CSS3, this image is stretched to fit within the borders). 243 243 244 244 union { 245 245 struct { 246 GPUTexture borderTopLeftImage; /// Border corner images247 GPUTexture borderTopRightImage; /// ditto248 GPUTexture borderBottomLeftImage; /// ditto249 GPUTexture borderBottomRightImage; /// ditto250 } 251 GPUTexture[4] borderCornerImage; /// Set the four border corner images images in one array.246 Texture borderTopLeftImage; /// Border corner images 247 Texture borderTopRightImage; /// ditto 248 Texture borderBottomLeftImage; /// ditto 249 Texture borderBottomRightImage; /// ditto 250 } 251 Texture[4] borderCornerImage; /// Set the four border corner images images in one array. 252 252 } 253 253 … … 263 263 264 264 /// Background image and color. backgroundColor is drawn first, with backgroundImage second, then borderImage on top. 265 GPUTexture backgroundImage; // just streteched for now.265 Texture backgroundImage; // just streteched for now. 266 266 Color backgroundColor; /// ditto 267 267 trunk/src/yage/gui/surface.d
r176 r186 41 41 42 42 protected char[] oldText; 43 protected GPUTexture textTexture;43 protected Texture textTexture; 44 44 45 45 /// Callback functions … … 343 343 344 344 if (!textTexture) // create texture on first go 345 textTexture = new GPUTexture(textImage, GPUTexture.Format.AUTO, false, "Surface Text", true);345 textTexture = new Texture(textImage, Texture.Format.AUTO, false, "Surface Text", true); 346 346 else 347 347 // textTexture.commit(textImage, false, false, text, true); trunk/src/yage/gui/surfacegeometry.d
r183 r186 224 224 225 225 // TODO: Convert this to accept materials as well as textures, 226 // or maybe just allow instantiation of a Material from a GPUTexture or Texture227 void setMaterials( GPUTexture backgroundImage, GPUTexture centerImage,228 GPUTexture[] borderImage, GPUTexture[] borderCornerImage, GPUTexture text, float opacity)226 // or maybe just allow instantiation of a Material from a Texture or TextureInstance 227 void setMaterials(Texture backgroundImage, Texture centerImage, 228 Texture[] borderImage, Texture[] borderCornerImage, Texture text, float opacity) 229 229 { 230 MaterialPass createPass( GPUTexture texture, bool clamp=false)230 MaterialPass createPass(Texture texture, bool clamp=false) 231 231 { auto result = new MaterialPass(); 232 result.textures ~= Texture (texture, clamp, Texture.Filter.BILINEAR);232 result.textures ~= TextureInstance(texture, clamp, TextureInstance.Filter.BILINEAR); 233 233 result.diffuse = Color(1f, 1f, 1f, opacity); 234 234 result.blend = MaterialPass.Blend.AVERAGE; … … 270 270 { this.text.setMaterial(new Material()); 271 271 this.text.getMaterial().setPass(createPass(text, true)); 272 this.text.getMaterial().getPass().textures[0].filter = Texture .Filter.NONE;272 this.text.getMaterial().getPass().textures[0].filter = TextureInstance.Filter.NONE; 273 273 274 274 // Text bottom vertices depend on text texture size. trunk/src/yage/resource/collada.d
r185 r186 54 54 private Material[char[]] materials; 55 55 private Image[char[]] images; 56 private GPUTexture[char[]] textures;56 private Texture[char[]] textures; 57 57 58 58 /** … … 320 320 321 321 // Helper function for loading material data. 322 void getColorOrTexture(Node n, inout Color color, inout GPUTexture texture)322 void getColorOrTexture(Node n, inout Color color, inout Texture texture) 323 323 { char[] name = n.name(); 324 324 switch (name) … … 331 331 break; 332 332 case "texture": 333 texture = getTextureById(n.getAttribute("texture")); // TODO getImageByTexture333 texture = getTextureById(n.getAttribute("texture")); 334 334 break; 335 335 default: … … 345 345 346 346 Node child = param.getChild(); 347 GPUTexture texture;347 Texture texture; 348 348 switch(param.name()) 349 349 { … … 353 353 case "diffuse": 354 354 getColorOrTexture(child, pass.diffuse, texture); 355 pass.setDiffuseTexture(Texture (texture)); // may be null355 pass.setDiffuseTexture(TextureInstance(texture)); // may be null 356 356 break; 357 357 case "bump": // Bump map extension used by Okino, http://www.okino.com/conv/exp_collada_extensions.htm 358 358 getColorOrTexture(child, pass.diffuse, texture); 359 pass.setNormalSpecularTexture(Texture (texture)); // may be null359 pass.setNormalSpecularTexture(TextureInstance(texture)); // may be null 360 360 break; 361 361 case "specular": … … 391 391 { Node extraTechnique = extra.getChild("technique"); 392 392 if (extraTechnique.hasChild("bump")) 393 { GPUTexture texture;393 { Texture texture; 394 394 getColorOrTexture(extraTechnique.getChild("bump").getChild("texture"), pass.diffuse, texture); 395 pass.setNormalSpecularTexture(Texture (texture)); // may be null395 pass.setNormalSpecularTexture(TextureInstance(texture)); // may be null 396 396 } } } 397 397 … … 542 542 543 543 /** 544 * Get a yage GPUTexture from the Collada file by its id.545 * This uses ResourceManager.texture internally, so subsequent calls will return an already loaded GPUTexture.544 * Get a yage Texture from the Collada file by its id. 545 * This uses ResourceManager.texture internally, so subsequent calls will return an already loaded Texture. 546 546 * 547 547 * These are Yage-specific notes for loading Collada textures: … … 551 551 * HIGH: 16 bit float (not supported yet) 552 552 * MAX: 32 bit float (not supported yet)</li> */ 553 GPUTexture getTextureById(char[] id)553 Texture getTextureById(char[] id) 554 554 { id = Xml.makeId(id); 555 555 if (id in textures) … … 577 577 578 578 // Load texture 579 GPUTexture.Format format = GPUTexture.Format.AUTO;579 Texture.Format format = Texture.Format.AUTO; 580 580 if (precision=="MID") 581 format = GPUTexture.Format.AUTO_UNCOMPRESSED;582 GPUTexture result = ResourceManager.texture(imagePath, format);581 format = Texture.Format.AUTO_UNCOMPRESSED; 582 Texture result = ResourceManager.texture(imagePath, format); 583 583 584 584 textures[id] = result; trunk/src/yage/resource/manager.d
r179 r186 40 40 private struct TextureKey 41 41 { char[] source; 42 GPUTexture.Format format;42 Texture.Format format; 43 43 bool mipmap; 44 44 } … … 51 51 private static Shader[char[]] shaders; 52 52 private static Sound[char[]] sounds; 53 private static GPUTexture[TextureKey] textures;53 private static Texture[TextureKey] textures; 54 54 55 55 … … 255 255 * If not, it will be loaded, uploaded to video memory, and stored in the resource pool. 256 256 * This function is called automatically for each of a material's textures when loading a material. 257 * Keep in mind that multiple requested textures may use the same GPUTexture.257 * Keep in mind that multiple requested textures may use the same Texture. 258 258 * Params: filename = The Texture image file that will be loaded. */ 259 static GPUTexture texture(char[] filename, GPUTexture.Format format=GPUTexture.Format.AUTO, bool mipmap=true)259 static Texture texture(char[] filename, Texture.Format format=Texture.Format.AUTO, bool mipmap=true) 260 260 { filename = resolvePath(filename); 261 261 TextureKey key; … … 264 264 265 265 // Search for matching format 266 int minFormat = GPUTexture.Format.AUTO ? 0 : format;267 int maxFormat = GPUTexture.Format.AUTO ? GPUTexture.Format.max : format;266 int minFormat = Texture.Format.AUTO ? 0 : format; 267 int maxFormat = Texture.Format.AUTO ? Texture.Format.max : format; 268 268 for (int i=minFormat; i<maxFormat+1; i++) 269 { key.format = cast( GPUTexture.Format)i;269 { key.format = cast(Texture.Format)i; 270 270 auto result = key in textures; 271 271 if (result) … … 275 275 // Create new texture 276 276 Timer t = new Timer(true); 277 GPUTexture result = new GPUTexture(filename, format, mipmap);277 Texture result = new Texture(filename, format, mipmap); 278 278 Log.info("Texture '%s' loaded in %s seconds.", filename, t); 279 279 textures[key] = result; trunk/src/yage/resource/material.d
r183 r186 126 126 bool flat = false; /// If true, use flat shading 127 127 float lineWidth = 1; /// Thickness in pixels of lines and points. 128 Texture [] textures;128 TextureInstance[] textures; 129 129 130 130 Blend blend = Blend.NONE; /// Loaded from Collada's transparent property. … … 157 157 } 158 158 159 void setDiffuseTexture(Texture texture)159 void setDiffuseTexture(TextureInstance texture) 160 160 { if (textures.length < 1) 161 161 textures.length = 1; … … 163 163 } 164 164 165 void setNormalSpecularTexture(Texture texture)165 void setNormalSpecularTexture(TextureInstance texture) 166 166 { if (textures.length < 2) 167 167 textures.length = 2; trunk/src/yage/resource/texture.d
r183 r186 19 19 20 20 /** 21 * An instance of a GPUTexture.22 * This allows many options to be set per instance of a GPUTexture instead of23 * creating multiple copies of the GPUTexture (and consuming valuable memory)21 * An instance of a Texture. 22 * This allows many options to be set per instance of a Texture instead of 23 * creating multiple copies of the Texture (and consuming valuable memory) 24 24 * just to change filtering, clamping, or relative scale. */ 25 struct Texture 25 struct TextureInstance 26 26 { 27 27 enum Filter /// … … 64 64 65 65 /// Property to set the type of filtering used for the textures of this layer. 66 int filter = Texture .Filter.DEFAULT;66 int filter = TextureInstance.Filter.DEFAULT; 67 67 68 68 /// … … 70 70 71 71 /// 72 GPUTexture texture;72 Texture texture; 73 73 74 74 protected static int[int] translate; 75 75 76 76 /// Create a new TextureInstance with the parameters specified. 77 static Texture opCall(GPUTexture texture, bool clamp=false, int filter=Texture.Filter.DEFAULT)78 79 { 80 Texture result;77 static TextureInstance opCall(Texture texture, bool clamp=false, int filter=TextureInstance.Filter.DEFAULT) 78 79 { 80 TextureInstance result; 81 81 result.texture = texture; 82 82 result.clamp = clamp; … … 86 86 87 87 char[] toString() 88 { return swritef(`Texture {source: "%s"}`, texture ? texture.source : "null");88 { return swritef(`TextureInstance {source: "%s"}`, texture ? texture.source : "null"); 89 89 } 90 90 } … … 92 92 93 93 /** 94 * A GPUTexture represents image data in video memory.94 * A Texture represents image data in video memory. 95 95 * 96 * Also, there's no need to be concerned about making96 * There's no need to be concerned about making 97 97 * texture dimensions a power of two, as they're automatically resized up to 98 98 * the next highest supported size if the non_power_of_two OpenGL extension 99 99 * isn't supported in hardware. */ 100 class GPUTexture : IRenderTarget100 class Texture : IRenderTarget 101 101 { 102 102 … … 149 149 150 150 /** 151 * Create a GPUTexture from an image.152 * The image will be uploaded to memory when the GPUTexture is first bound. */153 this(char[] filename, Format format= GPUTexture.Format.AUTO, bool mipmap=true)151 * Create a Texture from an image. 152 * The image will be uploaded to memory when the Texture is first bound. */ 153 this(char[] filename, Format format=Texture.Format.AUTO, bool mipmap=true) 154 154 { source = ResourceManager.resolvePath(filename); 155 155 this.format = format; … … 158 158 } 159 159 160 this(Image image, Format format= GPUTexture.Format.AUTO, bool mipmap=true, char[] source="", bool padding=false)160 this(Image image, Format format=Texture.Format.AUTO, bool mipmap=true, char[] source="", bool padding=false) 161 161 { this.format = format; 162 162 this.mipmap = mipmap; trunk/src/yage/scene/camera.d
r183 r186 25 25 26 26 /** 27 * A CameraNode renders everything it sees to a Texture. 28 * Currently, several constraints are used that allow for render-to-texture 29 * on hardware that only supports power-of-two sized textures. In the future, 30 * this will be dropped for a more robust but less backward-compatible solution. 31 * Node that two Cameras cannot render concurrently since OpenGL itself 32 * isn't threadsafe.*/ 27 * TODO: Document me. */ 33 28 class CameraNode : MovableNode 34 29 { trunk/src/yage/scene/terrain.d
r182 r186 35 35 * resolution = The number of points (grid resolution) in the x and y directions passed 36 36 * to generator's getPoint() function. */ 37 this(TerrainGenerator generator, Texture [] textures, Vec2f min=Vec2f(-128), Vec2f max=Vec2f(127), Vec2f resolution=Vec2f(256))37 this(TerrainGenerator generator, TextureInstance[] textures, Vec2f min=Vec2f(-128), Vec2f max=Vec2f(127), Vec2f resolution=Vec2f(256)) 38 38 { 39 39 /// TODO … … 75 75 Vec2f textureCoordinate; /// Texture coordinates for this point on the terrain 76 76 float[] textureBlend; /// Normalized vector of arbitrary length specifying the amount of each texture to 77 /// use at this point. TerrainNode.setTextures() specifies the textures themselves.77 /// use at this point. 78 78 } 79 79 … … 84 84 /** 85 85 * Get a lightmap Texture to use across the range of coordinates. 86 * If no lightmap is desired, this function can return a Texture without a GPUTexture.86 * If no lightmap is desired, this function can return a Texture without a Texture. 87 87 * The same GPU Texture can be reused across multiple calls with different values, 88 88 * if the Textures' texture matrix adjusted as needed. … … 91 91 * max = Maximum xy coordinate of the rectangle needing a lightmap. 92 92 * Returns: An RGB texture to use as a baked light-map. It's color values will be modulated with the terrain. */ 93 Texture getLightmap(Vec2f min, Vec2f max);93 TextureInstance getLightmap(Vec2f min, Vec2f max); 94 94 } 95 95 … … 133 133 } 134 134 135 Texture getLightmap(Vec2f min, Vec2f max)136 { Texture texture;135 TextureInstance getLightmap(Vec2f min, Vec2f max) 136 { TextureInstance texture; 137 137 return texture; // return no lightmap for now. 138 138 } trunk/src/yage/system/graphics/api/api.d
r183 r186 34 34 static LightNode[8] lights; 35 35 static MaterialPass pass; /// 36 static ArrayBuilder!(Texture ) textures;36 static ArrayBuilder!(TextureInstance) textures; 37 37 38 38 static ArrayBuilder!(Matrix) projectionMatrixStack; trunk/src/yage/system/graphics/api/opengl.d
r183 r186 325 325 { 326 326 // If target is a texture to render to 327 GPUTexture texture = cast(GPUTexture)target;327 Texture texture = cast(Texture)target; 328 328 if (texture) 329 329 { … … 353 353 { 354 354 355 GPUTexture texture = cast(GPUTexture)current.renderTarget;355 Texture texture = cast(Texture)current.renderTarget; 356 356 if (texture) 357 357 { … … 382 382 glBindTexture(GL_TEXTURE_2D, textures[texture.toHash()].id); 383 383 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, texture.width, texture.height, 0); 384 texture.format = GPUTexture.Format.RGB8;384 texture.format = Texture.Format.RGB8; 385 385 texture.flipped = true; 386 386 } … … 591 591 * textures = Textures to be bound. Texture units beyond the array length will be disabled. 592 592 * Returns: True if all of the textures were bound. Otherwise as many as possible will be bound. */ 593 bool bindTextures(Texture [] textures)593 bool bindTextures(TextureInstance[] textures) 594 594 { 595 595 bool result = true; … … 620 620 glEnable(GL_TEXTURE_2D); // does this need to be done for all textures or just once? 621 621 622 GPUTexture gpuTexture = texture.texture;622 Texture gpuTexture = texture.texture; 623 623 assert(gpuTexture); 624 624 ResourceInfo info = ResourceInfo.getOrCreate(gpuTexture, this.textures); … … 650 650 651 651 // Convert auto format to a real format based on the image given. 652 GPUTexture.Format format;653 if (gpuTexture.getFormat() == GPUTexture.Format.AUTO)652 Texture.Format format; 653 if (gpuTexture.getFormat() == Texture.Format.AUTO) 654 654 switch(image.getChannels()) // This will support float formats when we switch to using Image2. 655 { case 1: format = GPUTexture.Format.COMPRESSED_LUMINANCE; break;656 case 2: format = GPUTexture.Format.COMPRESSED_LUMINANCE_ALPHA; break;657 case 3: format = GPUTexture.Format.COMPRESSED_RGB; break;658 case 4: format = GPUTexture.Format.COMPRESSED_RGBA; break;655 { case 1: format = Texture.Format.COMPRESSED_LUMINANCE; break; 656 case 2: format = Texture.Format.COMPRESSED_LUMINANCE_ALPHA; break; 657 case 3: format = Texture.Format.COMPRESSED_RGB; break; 658 case 4: format = Texture.Format.COMPRESSED_RGBA; break; 659 659 default: throw new ResourceException("Images with more than 4 channels are not supported."); 660 660 } 661 else if (gpuTexture.getFormat() == GPUTexture.Format.AUTO_UNCOMPRESSED)661 else if (gpuTexture.getFormat() == Texture.Format.AUTO_UNCOMPRESSED) 662 662 switch(image.getChannels()) // This will support float formats when we switch to using Image2. 663 { case 1: format = GPUTexture.Format.LUMINANCE8; break;664 case 2: format = GPUTexture.Format.LUMINANCE8_ALPHA8; break;665 case 3: format = GPUTexture.Format.RGB8; break;666 case 4: format = GPUTexture.Format.RGBA8; break;663 { case 1: format = Texture.Format.LUMINANCE8; break; 664 case 2: format = Texture.Format.LUMINANCE8_ALPHA8; break; 665 case 3: format = Texture.Format.RGB8; break; 666 case 4: format = Texture.Format.RGBA8; break; 667 667 default: throw new ResourceException("Images with more than 4 channels are not supported."); 668 668 } 669 669 670 // Convert from GPUTexture.Format to OpenGL format constants.671 uint[ GPUTexture.Format] glFormatMap = [672 GPUTexture.Format.COMPRESSED_LUMINANCE : GL_LUMINANCE,673 GPUTexture.Format.COMPRESSED_LUMINANCE_ALPHA : GL_LUMINANCE_ALPHA,674 GPUTexture.Format.COMPRESSED_RGB : GL_RGB,675 GPUTexture.Format.COMPRESSED_RGBA : GL_RGBA,676 GPUTexture.Format.LUMINANCE8 : GL_LUMINANCE,677 GPUTexture.Format.LUMINANCE8_ALPHA8 : GL_LUMINANCE_ALPHA,678 GPUTexture.Format.RGB8 : GL_RGB,679 GPUTexture.Format.RGBA8 : GL_RGBA,670 // Convert from Texture.Format to OpenGL format constants. 671 uint[Texture.Format] glFormatMap = [ 672 Texture.Format.COMPRESSED_LUMINANCE : GL_LUMINANCE, 673 Texture.Format.COMPRESSED_LUMINANCE_ALPHA : GL_LUMINANCE_ALPHA, 674 Texture.Format.COMPRESSED_RGB : GL_RGB, 675 Texture.Format.COMPRESSED_RGBA : GL_RGBA, 676 Texture.Format.LUMINANCE8 : GL_LUMINANCE, 677 Texture.Format.LUMINANCE8_ALPHA8 : GL_LUMINANCE_ALPHA, 678 Texture.Format.RGB8 : GL_RGB, 679 Texture.Format.RGBA8 : GL_RGBA, 680 680 ]; 681 uint[ GPUTexture.Format] glInternalFormatMap = [682 GPUTexture.Format.COMPRESSED_LUMINANCE : GL_COMPRESSED_LUMINANCE,683 GPUTexture.Format.COMPRESSED_LUMINANCE_ALPHA : GL_COMPRESSED_LUMINANCE_ALPHA,684 GPUTexture.Format.COMPRESSED_RGB : GL_COMPRESSED_RGB,685 GPUTexture.Format.COMPRESSED_RGBA : GL_COMPRESSED_RGBA,686 GPUTexture.Format.LUMINANCE8 : GL_LUMINANCE,687 GPUTexture.Format.LUMINANCE8_ALPHA8 : GL_LUMINANCE_ALPHA,688 GPUTexture.Format.RGB8 : GL_RGB,689 GPUTexture.Format.RGBA8 : GL_RGBA,681 uint[Texture.Format] glInternalFormatMap = [ 682 Texture.Format.COMPRESSED_LUMINANCE : GL_COMPRESSED_LUMINANCE, 683 Texture.Format.COMPRESSED_LUMINANCE_ALPHA : GL_COMPRESSED_LUMINANCE_ALPHA, 684 Texture.Format.COMPRESSED_RGB : GL_COMPRESSED_RGB, 685 Texture.Format.COMPRESSED_RGBA : GL_COMPRESSED_RGBA, 686 Texture.Format.LUMINANCE8 : GL_LUMINANCE, 687 Texture.Format.LUMINANCE8_ALPHA8 : GL_LUMINANCE_ALPHA, 688 Texture.Format.RGB8 : GL_RGB, 689 Texture.Format.RGBA8 : GL_RGBA, 690 690 ]; 691 691 uint glFormat = glFormatMap[format]; … … 738 738 739 739 // Filtering 740 if (texture.filter == Texture .Filter.DEFAULT)741 texture.filter = Texture .Filter.TRILINEAR; // Create option to set this later740 if (texture.filter == TextureInstance.Filter.DEFAULT) 741 texture.filter = TextureInstance.Filter.TRILINEAR; // Create option to set this later 742 742 switch(texture.filter) 743 { case Texture .Filter.NONE:743 { case TextureInstance.Filter.NONE: 744 744 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpuTexture.mipmap ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST); 745 745 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 746 746 break; 747 case Texture .Filter.BILINEAR:747 case TextureInstance.Filter.BILINEAR: 748 748 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpuTexture.mipmap ? GL_LINEAR_MIPMAP_NEAREST : GL_NEAREST); 749 749 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 750 750 break; 751 751 default: 752 case Texture .Filter.TRILINEAR:752 case TextureInstance.Filter.TRILINEAR: 753 753 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpuTexture.mipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR); 754 754 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); … … 796 796 uint blendTranslated; 797 797 switch (texture.blend) 798 { case Texture .Blend.ADD: blendTranslated = GL_ADD; break;799 case Texture .Blend.AVERAGE: blendTranslated = GL_DECAL; break;800 case Texture .Blend.NONE:801 case Texture .Blend.MULTIPLY:798 { case TextureInstance.Blend.ADD: blendTranslated = GL_ADD; break; 799 case TextureInstance.Blend.AVERAGE: blendTranslated = GL_DECAL; break; 800 case TextureInstance.Blend.NONE: 801 case TextureInstance.Blend.MULTIPLY: 802 802 default: blendTranslated = GL_MODULATE; break; 803 803 }
