Commit cc6f569b authored by nadro's avatar nadro

- Fixed issue with 2D line rendering in OpenGL.

- Fixed issue with example no. 3 (other driver also need similar improvements -> move texture parameters update from OnSetMaterial/setBasicRenderStates to OnRender, because SMaterial compare operator doesn't check SMaterialLayer values).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4416 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 45c26940
......@@ -104,6 +104,8 @@ void COpenGLCgMaterialRenderer::OnSetMaterial(const SMaterial& material, const S
bool COpenGLCgMaterialRenderer::OnRender(IMaterialRendererServices* services, E_VERTEX_TYPE vtxtype)
{
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false, false);
if (CallBack && (VertexProgram || FragmentProgram || GeometryProgram))
CallBack->OnSetConstants(this, UserData);
......
This diff is collapsed.
......@@ -280,11 +280,15 @@ namespace video
bool resetAllRenderstates)
{
setBasicRenderStates(material, lastmaterial, resetAllRenderstates, true);
setTextureRenderStates(material, resetAllRenderstates, true);
}
//! Can be called by an IMaterialRenderer to make its work easier.
virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
bool resetAllRenderstates, bool fixedPipeline);
//! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call.
virtual void setTextureRenderStates(const SMaterial& material, bool resetAllRenderstates, bool fixedPipeline);
//! Get a vertex shader constant index.
virtual s32 getVertexShaderConstantID(const c8* name);
......@@ -414,6 +418,9 @@ namespace video
//! Get ZBuffer bits.
GLenum getZBufferBits() const;
//! Get current material.
const SMaterial& getCurrentMaterial() const;
//! Get bridge calls.
COpenGLCallBridge* getBridgeCalls() const;
......@@ -595,6 +602,7 @@ namespace video
//! Built-in 2D quad for 2D rendering.
S3DVertex Quad2DVertices[4];
u16 Quad2DIndices[6];
u16 Line2DIndices[2];
#ifdef _IRR_WINDOWS_API_
HDC HDc; // Private GDI Device Context
......
......@@ -35,6 +35,13 @@ public:
virtual void OnUnsetBaseMaterial()
{
}
virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype)
{
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false, true);
return true;
}
protected:
......@@ -54,7 +61,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(1);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
if (resetAllRenderstates || (material.MaterialType != lastMaterial.MaterialType))
{
......@@ -78,7 +85,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(1);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
// if (material.MaterialType != lastMaterial.MaterialType ||
// material.MaterialTypeParam != lastMaterial.MaterialTypeParam ||
......@@ -263,7 +270,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
......@@ -322,7 +329,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(1);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
if ((material.MaterialType != lastMaterial.MaterialType) || resetAllRenderstates)
{
......@@ -368,7 +375,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(1);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
......@@ -553,7 +560,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(1);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
......@@ -599,7 +606,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
......@@ -715,7 +722,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
......@@ -768,7 +775,7 @@ public:
core::matrix4 tmp = Driver->getTransform(ETS_TEXTURE_0);
tmp[5]*=-1;
Driver->setTransform(ETS_TEXTURE_0, tmp);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
......@@ -800,7 +807,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
......@@ -855,7 +862,7 @@ public:
bool resetAllRenderstates, IMaterialRendererServices* services)
{
Driver->disableTextures(2);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates, true);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
......
......@@ -199,6 +199,8 @@ void COpenGLSLMaterialRenderer::init(s32& outMaterialTypeNr,
bool COpenGLSLMaterialRenderer::OnRender(IMaterialRendererServices* service,
E_VERTEX_TYPE vtxtype)
{
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false, false);
// call callback to set shader constants
if (CallBack && (Program||Program2))
CallBack->OnSetConstants(this, UserData);
......
......@@ -120,6 +120,8 @@ void COpenGLShaderMaterialRenderer::init(s32& outMaterialTypeNr,
bool COpenGLShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype)
{
Driver->setTextureRenderStates(Driver->getCurrentMaterial(), false, false);
// call callback to set shader constants
if (CallBack && (VertexShader || PixelShader[0]))
CallBack->OnSetConstants(service, UserData);
......
......@@ -315,11 +315,9 @@ void COpenGLTexture::uploadTexture(bool newTexture, void* mipmapData, u32 level)
// make sure we don't change the internal format of existing images
if (!newTexture)
InternalFormat=oldInternalFormat;
Driver->getBridgeCalls()->setActiveTexture(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, TextureName);
Driver->setActiveTexture(0, this);
Driver->getBridgeCalls()->setTexture(0, true);
if (Driver->testGLError())
os::Printer::log("Could not bind Texture", ELL_ERROR);
......@@ -654,10 +652,8 @@ void COpenGLTexture::bindRTT()
//! Unbind Render Target Texture
void COpenGLTexture::unbindRTT()
{
Driver->getBridgeCalls()->setActiveTexture(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, TextureName);
Driver->setActiveTexture(0, this);
Driver->getBridgeCalls()->setTexture(0, true);
// Copy Our ViewPort To The Texture
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, getSize().Width, getSize().Height);
......@@ -707,11 +703,10 @@ COpenGLFBOTexture::COpenGLFBOTexture(const core::dimension2d<u32>& size,
// generate color texture
glGenTextures(1, &TextureName);
Driver->getBridgeCalls()->setActiveTexture(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, TextureName);
Driver->setActiveTexture(0, this);
Driver->getBridgeCalls()->setTexture(0, true);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, FilteringType);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
......
......@@ -55,8 +55,8 @@ public:
//! Cache structure.
struct SStatesCache
{
SStatesCache() : WrapU(ETC_REPEAT), WrapV(ETC_REPEAT), BilinearFilter(true),
TrilinearFilter(false), AnisotropicFilter(0), MipMapStatus(true), IsCached(false), LODBias(0)
SStatesCache() : WrapU(ETC_REPEAT), WrapV(ETC_REPEAT), BilinearFilter(false),
TrilinearFilter(false), AnisotropicFilter(0), MipMapStatus(false), IsCached(false), LODBias(0)
{
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment