Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GL cleanup #1751

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions rts/Game/UI/MiniMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "Rendering/GL/glExtra.h"
#include "Rendering/GL/RenderBuffers.h"
#include "Rendering/GL/SubState.h"
#include "Rendering/GL/TexBind.h"
#include "Rendering/Textures/Bitmap.h"
#include "Sim/Units/CommandAI/CommandAI.h"
#include "Sim/Units/Unit.h"
Expand Down Expand Up @@ -140,21 +141,15 @@ CMiniMap::CMiniMap()
if ((bitmap.ysize == buttonSize) && (bitmap.xsize == (buttonSize * 4))) {
unfiltered = true;
}
glGenTextures(1, &buttonsTextureID);

TextureCreationParams tcp;
tcp.linearTextureFilter = !unfiltered;
buttonsTextureID = bitmap.CreateTexture(tcp);

auto bind = GL::TexBind(GL_TEXTURE_2D, buttonsTextureID);
glBindTexture(GL_TEXTURE_2D, buttonsTextureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,
bitmap.xsize, bitmap.ysize, 0,
GL_RGBA, GL_UNSIGNED_BYTE, bitmap.GetRawMem());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
if (unfiltered) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
glBindTexture(GL_TEXTURE_2D, 0);
}
const float xshift = unfiltered ? 0.0f : (0.5f / bitmap.xsize);
const float yshift = unfiltered ? 0.0f : (0.5f / bitmap.ysize);
Expand Down Expand Up @@ -1093,7 +1088,8 @@ void CMiniMap::ResizeTextureCache()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, minimapTexSize.x, minimapTexSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
RecoilTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, minimapTexSize.x, minimapTexSize.y);
glBindTexture(GL_TEXTURE_2D, 0);

if (multisampledFBO) {
// resolve FBO with attached final texture target
Expand Down
5 changes: 2 additions & 3 deletions rts/Map/HeightMapTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ void HeightMapTexture::Init()
constexpr GLint swizzleMask[] = { GL_RED, GL_RED, GL_RED, GL_RED };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);

glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F,
xSize, ySize, 0,
GL_RED, GL_FLOAT, readMap->GetCornerHeightMapUnsynced());
RecoilTexStorage2D(GL_TEXTURE_2D, 1, GL_R32F, xSize, ySize);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, xSize, ySize, GL_RED, GL_FLOAT, readMap->GetCornerHeightMapUnsynced());

glBindTexture(GL_TEXTURE_2D, 0);
}
Expand Down
15 changes: 12 additions & 3 deletions rts/Map/SMF/SMFReadMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void CSMFReadMap::CreateShadingTex()
if (texAnisotropyLevels[false] != 0.0f)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, texAnisotropyLevels[false]);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, mapDims.pwr2mapx, mapDims.pwr2mapy, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
RecoilTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, mapDims.pwr2mapx, mapDims.pwr2mapy);

shadingTexBuffer.clear();
shadingTexBuffer.resize(mapDims.mapx * mapDims.mapy * 4, 0);
Expand All @@ -379,13 +379,20 @@ void CSMFReadMap::CreateNormalTex()
normalsTex.SetRawSize(int2(mapDims.mapxp1, mapDims.mapyp1));

glGenTextures(1, normalsTex.GetIDPtr());

glBindTexture(GL_TEXTURE_2D, normalsTex.GetID());

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA16F_ARB, (normalsTex.GetSize()).x, (normalsTex.GetSize()).y, 0, GL_LUMINANCE_ALPHA, GL_FLOAT, nullptr);
constexpr GLint swizzleMask[] = { GL_RED, GL_GREEN, GL_RED, GL_GREEN };
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);

RecoilTexStorage2D(GL_TEXTURE_2D, 1, GL_RG16, (normalsTex.GetSize()).x, (normalsTex.GetSize()).y);

glBindTexture(GL_TEXTURE_2D, 0);
}


Expand Down Expand Up @@ -690,7 +697,8 @@ void CSMFReadMap::UpdateNormalTexture(const SRectangle& update)
}

glBindTexture(GL_TEXTURE_2D, normalsTex.GetID());
glTexSubImage2D(GL_TEXTURE_2D, 0, minx, minz, xsize, zsize, GL_LUMINANCE_ALPHA, GL_FLOAT, &normalPixels[0]);
glTexSubImage2D(GL_TEXTURE_2D, 0, minx, minz, xsize, zsize, GL_RG, GL_FLOAT, &normalPixels[0]);
glBindTexture(GL_TEXTURE_2D, 0);
}


Expand Down Expand Up @@ -735,6 +743,7 @@ void CSMFReadMap::UpdateShadingTexture(const SRectangle& update)
// redefine the texture subregion
glBindTexture(GL_TEXTURE_2D, shadingTex.GetID());
glTexSubImage2D(GL_TEXTURE_2D, 0, x1, y1, xsize, ysize, GL_RGBA, GL_UNSIGNED_BYTE, &shadingPixels[0]);
glBindTexture(GL_TEXTURE_2D, 0);
}
}

Expand Down
3 changes: 2 additions & 1 deletion rts/Rendering/DebugDrawerAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ DebugDrawerAI::TexSet::Texture::Texture(int w, int h, const float* data):
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, intFormat, w, h, 0, extFormat, dataType, data);
RecoilTexStorage2D(GL_TEXTURE_2D, 1, intFormat, w, h);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, extFormat, dataType, data);
glBindTexture(GL_TEXTURE_2D, 0);
}

Expand Down
67 changes: 31 additions & 36 deletions rts/Rendering/Env/BumpWater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static GLuint LoadTexture(const string& filename, const float anisotropy = 0.0f,
if (!bm.Load(filename))
throw content_error("[" LOG_SECTION_BUMP_WATER "] Could not load texture from file " + filename);

const unsigned int texID = bm.CreateMipMapTexture(anisotropy);
const auto texID = bm.CreateMipMapTexture(anisotropy);

if (sizeY != nullptr) {
*sizeX = bm.xsize;
Expand Down Expand Up @@ -177,7 +177,6 @@ static TypedRenderBuffer<VA_TYPE_0> GenWaterPlaneBuffer(bool radial)
CBumpWater::CBumpWater()

: CEventClient("[CBumpWater]", 271923, false)
, target(GL_TEXTURE_2D)
, screenTextureX(globalRendering->viewSizeX)
, screenTextureY(globalRendering->viewSizeY)
, refractTexture(0)
Expand Down Expand Up @@ -254,14 +253,10 @@ void CBumpWater::InitResources(bool loadShader)
glBindTexture(GL_TEXTURE_2D, coastTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, mapDims.mapx, mapDims.mapy, 0, GL_RGBA, GL_FLOAT, NULL);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5, mapDims.mapx, mapDims.mapy, 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
//glGenerateMipmapEXT(GL_TEXTURE_2D);

RecoilTexStorage2D(GL_TEXTURE_2D, 0, GL_RGB5, mapDims.mapx, mapDims.mapy);

{
blurShader = shaderHandler->CreateProgramObject("[BumpWater]", "CoastBlurShader");
Expand Down Expand Up @@ -322,14 +317,14 @@ void CBumpWater::InitResources(bool loadShader)
if (refraction > 0) {
// CREATE REFRACTION TEXTURE
glGenTextures(1, &refractTexture);
glBindTexture(target, refractTexture);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glBindTexture(GL_TEXTURE_2D, refractTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glTexImage2D(target, 0, GL_RGBA8, screenTextureX, screenTextureY, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
RecoilTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, screenTextureX, screenTextureY);
}

if (reflection > 0) {
Expand All @@ -345,17 +340,18 @@ void CBumpWater::InitResources(bool loadShader)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

RecoilTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, reflTexSize, reflTexSize);
}

if (depthCopy) {
// CREATE DEPTH TEXTURE
glGenTextures(1, &depthTexture);
glBindTexture(target, depthTexture);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glBindTexture(GL_TEXTURE_2D, depthTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
GLuint depthFormat = CGlobalRendering::DepthBitsToFormat(globalRendering->supportDepthBufferBitDepth);
glTexImage2D(target, 0, depthFormat, screenTextureX, screenTextureY, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
RecoilTexStorage2D(GL_TEXTURE_2D, 1, depthFormat, screenTextureX, screenTextureY);
}

if (dynWaves) {
Expand All @@ -374,8 +370,8 @@ void CBumpWater::InitResources(bool loadShader)
if (anisotropy > 0.0f) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, normalTextureX, normalTextureY, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glGenerateMipmapEXT(GL_TEXTURE_2D);

RecoilTexStorage2D(GL_TEXTURE_2D, 0, GL_RGBA8, normalTextureX, normalTextureY);
}

// CREATE FBOs
Expand All @@ -394,7 +390,7 @@ void CBumpWater::InitResources(bool loadShader)
if (refraction > 0) {
refractFBO.Bind();
refractFBO.CreateRenderBuffer(GL_DEPTH_ATTACHMENT_EXT, depthRBOFormat, screenTextureX, screenTextureY);
refractFBO.AttachTexture(refractTexture,target);
refractFBO.AttachTexture(refractTexture, GL_TEXTURE_2D);
if (!refractFBO.CheckStatus("BUMPWATER(refraction)")) {
refraction = 0;
}
Expand Down Expand Up @@ -706,10 +702,9 @@ void CBumpWater::UpdateCoastmap(const bool initialize)
glBindTexture(GL_TEXTURE_2D, coastUpdateTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, coastTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
Expand Down Expand Up @@ -794,18 +789,18 @@ void CBumpWater::UpdateCoastmap(const bool initialize)
// generate mipmaps
//glActiveTexture(GL_TEXTURE0);
//glBindTexture(GL_TEXTURE_2D, coastTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glGenerateMipmapEXT(GL_TEXTURE_2D);
glGenerateMipmap(GL_TEXTURE_2D);

// delete UpdateAtlas
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
glDeleteTextures(1, &coastUpdateTexture);
coastmapAtlasRects.clear();

globalRendering->LoadViewport();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);

globalRendering->LoadViewport();
}


Expand Down Expand Up @@ -889,7 +884,7 @@ void CBumpWater::UpdateDynWaves(const bool initialize)
dynWavesFBO.Unbind();

glBindTexture(GL_TEXTURE_2D, normalTexture);
glGenerateMipmapEXT(GL_TEXTURE_2D);
glGenerateMipmap(GL_TEXTURE_2D);
}


Expand All @@ -905,14 +900,14 @@ void CBumpWater::Draw()

if (refraction == 1) {
// _SCREENCOPY_ REFRACT TEXTURE
glBindTexture(target, refractTexture);
glCopyTexSubImage2D(target, 0, 0, 0, globalRendering->viewPosX, globalRendering->viewPosY, globalRendering->viewSizeX, globalRendering->viewSizeY);
glBindTexture(GL_TEXTURE_2D, refractTexture);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, globalRendering->viewPosX, globalRendering->viewPosY, globalRendering->viewSizeX, globalRendering->viewSizeY);
}

if (depthCopy) {
// _SCREENCOPY_ DEPTH TEXTURE
glBindTexture(target, depthTexture);
glCopyTexSubImage2D(target, 0, 0, 0, globalRendering->viewPosX, globalRendering->viewPosY, globalRendering->viewSizeX, globalRendering->viewSizeY);
glBindTexture(GL_TEXTURE_2D, depthTexture);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, globalRendering->viewPosX, globalRendering->viewPosY, globalRendering->viewSizeX, globalRendering->viewSizeY);
}

glDisable(GL_ALPHA_TEST);
Expand Down Expand Up @@ -947,9 +942,9 @@ void CBumpWater::Draw()
glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, caustTextures[causticTexNum]);
glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, foamTexture);
glActiveTexture(GL_TEXTURE4); glBindTexture(GL_TEXTURE_2D, reflectTexture);
glActiveTexture(GL_TEXTURE5); glBindTexture(target, refractTexture);
glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_2D, refractTexture);
glActiveTexture(GL_TEXTURE6); glBindTexture(GL_TEXTURE_2D, coastTexture);
glActiveTexture(GL_TEXTURE7); glBindTexture(target, depthTexture);
glActiveTexture(GL_TEXTURE7); glBindTexture(GL_TEXTURE_2D, depthTexture);
glActiveTexture(GL_TEXTURE8); glBindTexture(GL_TEXTURE_2D, waveRandTexture);
//glActiveTexture(GL_TEXTURE9); see above
glActiveTexture(GL_TEXTURE10); glBindTexture(GL_TEXTURE_2D, infoTextureHandler->GetCurrentInfoTexture());
Expand Down
1 change: 0 additions & 1 deletion rts/Rendering/Env/BumpWater.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class CBumpWater : public IWater, public CEventClient
int normalTextureX; ///< needed for dynamic waves
int normalTextureY;

GLuint target; ///< for screen copies (color/depth), can be GL_TEXTURE_RECTANGLE (nvidia) or GL_TEXTURE_2D (others)
int screenTextureX;
int screenTextureY;

Expand Down
30 changes: 14 additions & 16 deletions rts/Rendering/Env/CubeMapHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ bool CubeMapHandler::Init() {
CreateSpecularFace(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, specTexSize, float3(-1, -1, 1), float3( 2, 0, 0), float3(0, 0, -2));
CreateSpecularFace(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, specTexSize, float3(-1, 1, 1), float3( 2, 0, 0), float3(0, -2, 0));
CreateSpecularFace(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, specTexSize, float3( 1, 1, -1), float3(-2, 0, 0), float3(0, -2, 0));

glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL , 0);
}


const auto numLevels = generateMipMaps ? 0 : 1;
{
glGenTextures(1, &envReflectionTexID);
glBindTexture(GL_TEXTURE_CUBE_MAP, envReflectionTexID);
Expand All @@ -69,33 +74,26 @@ bool CubeMapHandler::Init() {
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
RecoilTexStorageCubeMap(numLevels, GL_RGBA8, reflTexSize, reflTexSize);
}

if (generateMipMaps)
glGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP);
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);

if (mapSkyReflections) {
glGenTextures(1, &skyReflectionTexID);
glBindTexture(GL_TEXTURE_CUBE_MAP, skyReflectionTexID);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, generateMipMaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // magnification doesn't use mips
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, reflTexSize, reflTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
RecoilTexStorageCubeMap(numLevels, GL_RGBA8, reflTexSize, reflTexSize);
}

if (generateMipMaps)
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);

glBindTexture(GL_TEXTURE_CUBE_MAP, 0);

// reflectionCubeFBO is no-op constructed, has to be initialized manually
Expand Down Expand Up @@ -178,7 +176,7 @@ void CubeMapHandler::UpdateReflectionTexture()

if (generateMipMaps && currReflectionFace == 0) {
glBindTexture(GL_TEXTURE_CUBE_MAP, envReflectionTexID);
glGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP);
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
}
}
Expand Down
2 changes: 1 addition & 1 deletion rts/Rendering/Env/Particles/ProjectileDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void CProjectileDrawer::Init() {
glBindTexture(GL_TEXTURE_2D, perlinBlendTex[a]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, perlinBlendTexSize, perlinBlendTexSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
RecoilTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, perlinBlendTexSize, perlinBlendTexSize);
}
}

Expand Down
Loading