diff --git a/assets/textures.go b/assets/textures.go index 5a68ac0..ad3431e 100755 --- a/assets/textures.go +++ b/assets/textures.go @@ -45,7 +45,7 @@ type TextureLoadOptions struct { WriteToCache bool GenMipMaps bool KeepPixelsInMem bool - TextureIsSrgba bool + NoSrgba bool } type Cubemap struct { @@ -103,9 +103,9 @@ func LoadTexturePNG(file string, loadOptions *TextureLoadOptions) (Texture, erro gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR) // load and generate the texture - internalFormat := int32(gl.RGBA8) - if loadOptions.TextureIsSrgba { - internalFormat = gl.SRGB_ALPHA + internalFormat := int32(gl.SRGB_ALPHA) + if loadOptions.NoSrgba { + internalFormat = gl.RGBA8 } gl.TexImage2D(gl.TEXTURE_2D, 0, internalFormat, tex.Width, tex.Height, 0, gl.RGBA, gl.UNSIGNED_BYTE, unsafe.Pointer(&tex.Pixels[0])) @@ -151,9 +151,9 @@ func LoadTextureInMemPngImg(img image.Image, loadOptions *TextureLoadOptions) (T gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR) // load and generate the texture - internalFormat := int32(gl.RGBA8) - if loadOptions.TextureIsSrgba { - internalFormat = gl.SRGB_ALPHA + internalFormat := int32(gl.SRGB_ALPHA) + if loadOptions.NoSrgba { + internalFormat = gl.RGBA8 } gl.TexImage2D(gl.TEXTURE_2D, 0, internalFormat, tex.Width, tex.Height, 0, gl.RGBA, gl.UNSIGNED_BYTE, unsafe.Pointer(&tex.Pixels[0])) @@ -216,9 +216,9 @@ func LoadTextureJpeg(file string, loadOptions *TextureLoadOptions) (Texture, err gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR) // load and generate the texture - internalFormat := int32(gl.RGBA8) - if loadOptions.TextureIsSrgba { - internalFormat = gl.SRGB_ALPHA + internalFormat := int32(gl.SRGB_ALPHA) + if loadOptions.NoSrgba { + internalFormat = gl.RGBA8 } gl.TexImage2D(gl.TEXTURE_2D, 0, internalFormat, tex.Width, tex.Height, 0, gl.RGBA, gl.UNSIGNED_BYTE, unsafe.Pointer(&tex.Pixels[0])) @@ -288,9 +288,9 @@ func LoadCubemapTextures(rightTex, leftTex, topTex, botTex, frontTex, backTex st height := int32(nrgbaImg.Bounds().Dy()) width := int32(nrgbaImg.Bounds().Dx()) - internalFormat := int32(gl.RGBA8) - if loadOptions.TextureIsSrgba { - internalFormat = gl.SRGB_ALPHA + internalFormat := int32(gl.SRGB_ALPHA) + if loadOptions.NoSrgba { + internalFormat = gl.RGBA8 } gl.TexImage2D(uint32(gl.TEXTURE_CUBE_MAP_POSITIVE_X)+i, 0, internalFormat, int32(width), int32(height), 0, gl.RGBA, gl.UNSIGNED_BYTE, unsafe.Pointer(&nrgbaImg.Pix[0])) diff --git a/main.go b/main.go index 0292369..b005a5c 100755 --- a/main.go +++ b/main.go @@ -26,7 +26,7 @@ import ( /* @TODO: - Rendering: - - Phong lighting model ✅ + - Blinn-Phong lighting model ✅ - Directional lights ✅ - Point lights ✅ - Spotlights ✅ @@ -350,27 +350,27 @@ func (g *Game) Init() { } //Load textures - whiteTex, err := assets.LoadTexturePNG("./res/textures/white.png", &assets.TextureLoadOptions{TextureIsSrgba: true}) + whiteTex, err := assets.LoadTexturePNG("./res/textures/white.png", &assets.TextureLoadOptions{}) if err != nil { logging.ErrLog.Fatalln("Failed to load texture. Err: ", err) } - blackTex, err := assets.LoadTexturePNG("./res/textures/black.png", &assets.TextureLoadOptions{TextureIsSrgba: true}) + blackTex, err := assets.LoadTexturePNG("./res/textures/black.png", &assets.TextureLoadOptions{}) if err != nil { logging.ErrLog.Fatalln("Failed to load texture. Err: ", err) } - containerDiffuseTex, err := assets.LoadTexturePNG("./res/textures/container-diffuse.png", &assets.TextureLoadOptions{TextureIsSrgba: true}) + containerDiffuseTex, err := assets.LoadTexturePNG("./res/textures/container-diffuse.png", &assets.TextureLoadOptions{}) if err != nil { logging.ErrLog.Fatalln("Failed to load texture. Err: ", err) } - containerSpecularTex, err := assets.LoadTexturePNG("./res/textures/container-specular.png", &assets.TextureLoadOptions{TextureIsSrgba: true}) + containerSpecularTex, err := assets.LoadTexturePNG("./res/textures/container-specular.png", &assets.TextureLoadOptions{}) if err != nil { logging.ErrLog.Fatalln("Failed to load texture. Err: ", err) } - palleteTex, err := assets.LoadTexturePNG("./res/textures/pallete-endesga-64-1x.png", &assets.TextureLoadOptions{TextureIsSrgba: true}) + palleteTex, err := assets.LoadTexturePNG("./res/textures/pallete-endesga-64-1x.png", &assets.TextureLoadOptions{}) if err != nil { logging.ErrLog.Fatalln("Failed to load texture. Err: ", err) } @@ -379,7 +379,7 @@ func (g *Game) Init() { "./res/textures/sb-right.jpg", "./res/textures/sb-left.jpg", "./res/textures/sb-top.jpg", "./res/textures/sb-bottom.jpg", "./res/textures/sb-front.jpg", "./res/textures/sb-back.jpg", - &assets.TextureLoadOptions{TextureIsSrgba: true}, + &assets.TextureLoadOptions{}, ) if err != nil { logging.ErrLog.Fatalln("Failed to load cubemap. Err: ", err)