feat: implement multi-layer texture binding
This commit is contained in:
@@ -428,7 +428,7 @@ void Textures::bindTextureLayers(ResourceLocation *resource)
|
||||
|
||||
for( int i = 0; i < layers; i++ )
|
||||
{
|
||||
RenderManager.TextureBind(loadTexture(resource->getTexture(i)));
|
||||
RenderManager.TextureBind(i, loadTexture(resource->getTexture(i)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1520,3 +1520,4 @@ bool Textures::IsOriginalImage(TEXTURE_NAME texId, const wstring& name)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -145,6 +145,7 @@ public:
|
||||
int TextureCreate();
|
||||
void TextureFree(int idx);
|
||||
void TextureBind(int idx);
|
||||
void TextureBind(int layer, int idx);
|
||||
void TextureBindVertex(int idx);
|
||||
void TextureSetTextureLevels(int levels);
|
||||
int TextureGetTextureLevels();
|
||||
@@ -300,3 +301,4 @@ const int GL_TRIANGLE_STRIP = C4JRender::PRIMITIVE_TYPE_TRIANGLE_STRIP;
|
||||
extern C4JRender RenderManager;
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,6 +3,17 @@
|
||||
#include "..\Minecraft.World\IntBuffer.h"
|
||||
#include "..\Minecraft.World\ByteBuffer.h"
|
||||
|
||||
static int g_activeTextureLayer = 0;
|
||||
|
||||
static int getTextureLayer(int textureUnit)
|
||||
{
|
||||
if (textureUnit == GL_TEXTURE1)
|
||||
return 1;
|
||||
if (textureUnit >= GL_TEXTURE0)
|
||||
return textureUnit - GL_TEXTURE0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void glViewport(int x, int y, int w, int h)
|
||||
{
|
||||
// We don't really need anything here because minecraft doesn't current do anything other than the default viewport
|
||||
@@ -139,7 +150,7 @@ void Display::swapBuffers()
|
||||
|
||||
void glBindTexture(int target,int texture)
|
||||
{
|
||||
RenderManager.TextureBind(texture);
|
||||
RenderManager.TextureBind(g_activeTextureLayer, texture);
|
||||
}
|
||||
|
||||
void glTexImage2D(int target,int level,int internalformat,int width,int height,int border,int format,int type, ByteBuffer *data)
|
||||
@@ -190,7 +201,7 @@ void glDisable(int state)
|
||||
switch(state)
|
||||
{
|
||||
case GL_TEXTURE_2D:
|
||||
RenderManager.TextureBind(-1);
|
||||
RenderManager.TextureBind(g_activeTextureLayer, -1);
|
||||
break;
|
||||
case GL_BLEND:
|
||||
RenderManager.StateSetBlendEnable(false);
|
||||
@@ -390,4 +401,23 @@ void glTexGen(int coord, int mode, FloatBuffer *vec)
|
||||
void glCullFace(int dir)
|
||||
{
|
||||
RenderManager.StateSetFaceCullCW( dir == GL_BACK);
|
||||
}
|
||||
}
|
||||
void glClientActiveTexture(int texture)
|
||||
{
|
||||
glActiveTexture(texture);
|
||||
}
|
||||
|
||||
void glActiveTexture(int texture)
|
||||
{
|
||||
int layer = getTextureLayer(texture);
|
||||
if (layer < 0)
|
||||
{
|
||||
layer = 0;
|
||||
}
|
||||
else if (layer > 3)
|
||||
{
|
||||
layer = 3;
|
||||
}
|
||||
g_activeTextureLayer = layer;
|
||||
}
|
||||
|
||||
|
||||
@@ -122,13 +122,6 @@ void glColorMaterial(int,int)
|
||||
}
|
||||
|
||||
//1.8.2
|
||||
void glClientActiveTexture(int)
|
||||
{
|
||||
}
|
||||
|
||||
void glActiveTexture(int)
|
||||
{
|
||||
}
|
||||
|
||||
void glFlush()
|
||||
{
|
||||
@@ -157,4 +150,4 @@ DWORD XCamSetView(
|
||||
) { return 0; }
|
||||
|
||||
XCAMDEVICESTATE XCamGetStatus() { return XCAMDEVICESTATE_DISCONNECTED; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user