Merging r6468 through r6476 from trunk to ogl-es branch

Note: Not yet using latest changes to IMaterialRendererServices in ES2 driver


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6477 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2023-04-27 19:51:22 +00:00
parent dd16d578d8
commit 23ebdbe978
22 changed files with 195 additions and 124 deletions

View File

@ -622,7 +622,7 @@ void CAnimatedMeshHalfLife::renderModel(u32 param, IVideoDriver * driver, const
}
}
// attachements
// attachments
const SHalflifeAttachment *attach = (SHalflifeAttachment *) ((u8*) Header + Header->attachmentindex);
core::vector3df v[8];
for (u32 i = 0; i < Header->numattachments; i++)

View File

@ -31,7 +31,7 @@ struct SMD3Frame
//! An attachment point for another MD3 model.
struct SMD3Tag
{
c8 Name[64]; //name of 'tag' as it's usually called in the md3 files try to see it as a sub-mesh/seperate mesh-part.
c8 Name[64]; //name of 'tag' as it's usually called in the md3 files try to see it as a sub-mesh/separate mesh-part.
f32 position[3]; //relative position of tag
f32 rotationMatrix[9]; //3x3 rotation direction of tag
} PACK_STRUCT;

View File

@ -76,14 +76,26 @@ void CCubeSceneNode::render()
if (Shadow)
Shadow->updateShadowVolumes();
// for debug purposes only:
video::SMaterial mat = Mesh->getMeshBuffer(0)->getMaterial();
// overwrite half transparency
if (DebugDataVisible & scene::EDS_HALF_TRANSPARENCY)
mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
driver->setMaterial(mat);
driver->drawMeshBuffer(Mesh->getMeshBuffer(0));
for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i)
{
const scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
{
// for debug purposes only:
if (DebugDataVisible & scene::EDS_HALF_TRANSPARENCY)
{
// overwrite half transparency
video::SMaterial mat = mb->getMaterial();
mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
driver->setMaterial(mat);
}
else
{
const video::SMaterial& mat = mb->getMaterial();
driver->setMaterial(mat);
}
driver->drawMeshBuffer(mb);
}
}
// for debug purposes only:
if (DebugDataVisible)
@ -95,21 +107,18 @@ void CCubeSceneNode::render()
if (DebugDataVisible & scene::EDS_BBOX)
{
driver->draw3DBox(Mesh->getMeshBuffer(0)->getBoundingBox(), video::SColor(255,255,255,255));
driver->draw3DBox(Mesh->getBoundingBox(), video::SColor(255,255,255,255));
}
if (DebugDataVisible & scene::EDS_BBOX_BUFFERS)
{
driver->draw3DBox(Mesh->getMeshBuffer(0)->getBoundingBox(),
video::SColor(255,190,128,128));
driver->draw3DBox(Mesh->getBoundingBox(), video::SColor(255,190,128,128));
}
if (DebugDataVisible & scene::EDS_NORMALS)
{
// draw normals
const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);
const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);
const u32 count = Mesh->getMeshBufferCount();
for (u32 i=0; i != count; ++i)
for (u32 i=0; i < Mesh->getMeshBufferCount(); ++i)
{
driver->drawMeshBufferNormals(Mesh->getMeshBuffer(i), debugNormalLength, debugNormalColor);
}
@ -121,7 +130,10 @@ void CCubeSceneNode::render()
m.Wireframe = true;
driver->setMaterial(m);
driver->drawMeshBuffer(Mesh->getMeshBuffer(0));
for (u32 i=0; i < Mesh->getMeshBufferCount(); ++i)
{
driver->drawMeshBuffer(Mesh->getMeshBuffer(i));
}
}
}
}
@ -130,7 +142,7 @@ void CCubeSceneNode::render()
//! returns the axis aligned bounding box of this node
const core::aabbox3d<f32>& CCubeSceneNode::getBoundingBox() const
{
return Mesh->getMeshBuffer(0)->getBoundingBox();
return Mesh->getBoundingBox();
}
@ -183,14 +195,16 @@ void CCubeSceneNode::OnRegisterSceneNode()
//! returns the material based on the zero based index i.
video::SMaterial& CCubeSceneNode::getMaterial(u32 i)
{
return Mesh->getMeshBuffer(0)->getMaterial();
return Mesh->getMeshBuffer(i)->getMaterial();
}
//! returns amount of materials used by this scene node.
u32 CCubeSceneNode::getMaterialCount() const
{
return 1;
if ( Mesh )
return Mesh->getMeshBufferCount();
return 0;
}
@ -233,7 +247,8 @@ ISceneNode* CCubeSceneNode::clone(ISceneNode* newParent, ISceneManager* newManag
newManager, ID, RelativeTranslation, RelativeRotation, RelativeScale, MeshType);
nb->cloneMembers(this, newManager);
nb->getMaterial(0) = getMaterial(0);
for ( irr::u32 i=0; i < getMaterialCount(); ++i )
nb->getMaterial(i) = getMaterial(i);
nb->Shadow = Shadow;
if ( nb->Shadow )
nb->Shadow->grab();

View File

@ -18,7 +18,7 @@ namespace scene
class ISceneNodeAnimator;
class ISceneManager;
//! Interface making it possible to dynamicly create scene nodes animators
//! Interface making it possible to dynamically create scene nodes animators
class CDefaultSceneNodeAnimatorFactory : public ISceneNodeAnimatorFactory
{
public:

View File

@ -533,7 +533,6 @@ void CGUIContextMenu::draw()
// loop through all menu items
rect = AbsoluteRect;
s32 y = AbsoluteRect.UpperLeftCorner.Y;
for (s32 i=0; i<(s32)Items.size(); ++i)
{
@ -550,8 +549,6 @@ void CGUIContextMenu::draw()
rect.LowerRightCorner.Y += 1;
rect.UpperLeftCorner.Y += 1;
skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
y += 10;
}
else
{
@ -673,19 +670,22 @@ void CGUIContextMenu::recalculateSize()
if ( root )
{
core::rect<s32> rectRoot( root->getAbsolutePosition() );
core::rect<s32> absRect( getAbsolutePosition() );
// if it would be drawn beyond the right border, then add it to the left side
if ( getAbsolutePosition().UpperLeftCorner.X+subRect.LowerRightCorner.X > rectRoot.LowerRightCorner.X )
// if it would be drawn beyond the right border, then add it to the left side - if there is more space
irr::s32 beyondRight = absRect.UpperLeftCorner.X+subRect.LowerRightCorner.X-rectRoot.LowerRightCorner.X;
irr::s32 beyondLeft = -(absRect.UpperLeftCorner.X - w - rectRoot.UpperLeftCorner.X);
if ( beyondRight > 0 && beyondRight > beyondLeft )
{
subRect.UpperLeftCorner.X = -w;
subRect.LowerRightCorner.X = 0;
}
// if it would be drawn below bottom border, move it up, but not further than to top.
irr::s32 belowBottom = getAbsolutePosition().UpperLeftCorner.Y+subRect.LowerRightCorner.Y - rectRoot.LowerRightCorner.Y;
irr::s32 belowBottom = absRect.UpperLeftCorner.Y+subRect.LowerRightCorner.Y - rectRoot.LowerRightCorner.Y;
if ( belowBottom > 0 )
{
irr::s32 belowTop = getAbsolutePosition().UpperLeftCorner.Y+subRect.UpperLeftCorner.Y;
irr::s32 belowTop = absRect.UpperLeftCorner.Y+subRect.UpperLeftCorner.Y;
irr::s32 moveUp = belowBottom < belowTop ? belowBottom : belowTop;
subRect.UpperLeftCorner.Y -= moveUp;
subRect.LowerRightCorner.Y -= moveUp;

View File

@ -3730,7 +3730,9 @@ s32 COpenGLDriver::addShaderMaterial(const c8* vertexShaderProgram,
r->drop();
if (callback && nr >= 0)
{
callback->OnCreate(this, userData);
}
return nr;
}
@ -3767,7 +3769,11 @@ s32 COpenGLDriver::addHighLevelShaderMaterial(
r->drop();
if (callback && nr >= 0)
{
r->startUseProgram();
callback->OnCreate(r, userData);
r->stopUseProgram();
}
return nr;
}

View File

@ -416,6 +416,12 @@ namespace video
//! Get current material.
const SMaterial& getCurrentMaterial() const;
//! Rest renderstates forcing stuff like OnSetMaterial to be called
void DoResetRenderStates()
{
ResetRenderStates = true;
}
COpenGLCacheHandler* getCacheHandler() const;
private:

View File

@ -237,7 +237,7 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(const video::SMaterial& material,
COpenGLCacheHandler* cacheHandler = Driver->getCacheHandler();
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) // each program has it's own type
{
if (Program2)
Driver->irrGlUseProgram(Program2);
@ -572,6 +572,23 @@ void COpenGLSLMaterialRenderer::setBasicRenderStates(const SMaterial& material,
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
void COpenGLSLMaterialRenderer::startUseProgram()
{
if (Program2)
Driver->irrGlUseProgram(Program2);
else if (Program)
Driver->extGlUseProgramObject(Program);
}
void COpenGLSLMaterialRenderer::stopUseProgram()
{
// Not going to reset irrGlUseProgram/extGlUseProgramObject as it shouldn't really matter
// Force reset of material to ensure OnSetMaterial will be called or we can miss
// the next UseProgram call
Driver->DoResetRenderStates();
}
s32 COpenGLSLMaterialRenderer::getVertexShaderConstantID(const c8* name)
{
return getPixelShaderConstantID(name);

View File

@ -73,6 +73,8 @@ public:
// implementations for IMaterialRendererServices
virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates) IRR_OVERRIDE;
virtual void startUseProgram() IRR_OVERRIDE;
virtual void stopUseProgram() IRR_OVERRIDE;
virtual s32 getVertexShaderConstantID(const c8* name) IRR_OVERRIDE;
virtual s32 getPixelShaderConstantID(const c8* name) IRR_OVERRIDE;
virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) IRR_OVERRIDE;

View File

@ -952,7 +952,7 @@ scene::SMesh** CQ3LevelMesh::buildMesh(s32 num)
item[g].index != E_Q3_MESH_FOG ? material : material2 );
}
// create a seperate mesh buffer
// create a separate mesh buffer
if ( 0 == buffer )
{
buffer = new scene::SMeshBufferLightMap();

View File

@ -427,7 +427,7 @@ CSceneManager::~CSceneManager()
}
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
//! gets an animatable mesh. loads it if needed. returned pointer must not be dropped.
IAnimatedMesh* CSceneManager::getMesh(const io::path& filename, const io::path& alternativeCacheName)
{
io::path cacheName = alternativeCacheName.empty() ? filename : alternativeCacheName;
@ -450,7 +450,7 @@ IAnimatedMesh* CSceneManager::getMesh(const io::path& filename, const io::path&
}
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
//! gets an animatable mesh. loads it if needed. returned pointer must not be dropped.
IAnimatedMesh* CSceneManager::getMesh(io::IReadFile* file)
{
if (!file)

View File

@ -40,10 +40,10 @@ namespace scene
//! destructor
virtual ~CSceneManager();
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
//! gets an animatable mesh. loads it if needed. returned pointer must not be dropped.
virtual IAnimatedMesh* getMesh(const io::path& filename, const io::path& alternativeCacheName) IRR_OVERRIDE;
//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped.
//! gets an animatable mesh. loads it if needed. returned pointer must not be dropped.
virtual IAnimatedMesh* getMesh(io::IReadFile* file) IRR_OVERRIDE;
//! Returns an interface to the mesh cache which is shared between all existing scene managers.
@ -124,7 +124,7 @@ namespace scene
virtual IOctreeSceneNode* addOctreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0,
s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false) IRR_OVERRIDE;
//! Adss a scene node for rendering using a octree. This a good method for rendering
//! Adds a scene node for rendering using a octree. This a good method for rendering
//! scenes with lots of geometry. The Octree is built on the fly from the mesh, much
//! faster then a bsp tree.
virtual IOctreeSceneNode* addOctreeSceneNode(IMesh* mesh, ISceneNode* parent=0,
@ -141,7 +141,7 @@ namespace scene
const core::vector3df& lookat = core::vector3df(0,0,100),
s32 id=-1, bool makeActive=true) IRR_OVERRIDE;
//! Adds a camera scene node which is able to be controlle with the mouse similar
//! Adds a camera scene node which is able to be controlled with the mouse similar
//! like in the 3D Software Maya by Alias Wavefront.
//! The returned pointer must not be dropped.
virtual ICameraSceneNode* addCameraSceneNodeMaya(ISceneNode* parent=0,
@ -151,7 +151,7 @@ namespace scene
, f32 rotX = 0.f, f32 rotY = 0.f
) IRR_OVERRIDE;
//! Adds a camera scene node which is able to be controled with the mouse and keys
//! Adds a camera scene node which is able to be controlled with the mouse and keys
//! like in most first person shooters (FPS):
virtual ICameraSceneNode* addCameraSceneNodeFPS(ISceneNode* parent = 0,
f32 rotateSpeed = 100.0f, f32 moveSpeed = .5f, s32 id=-1,
@ -641,7 +641,7 @@ namespace scene
//! file system
io::IFileSystem* FileSystem;
//! GUI Enviroment ( Debug Purpose )
//! GUI Environment (debug purpose)
gui::IGUIEnvironment* GUIEnvironment;
//! cursor control

View File

@ -3337,7 +3337,7 @@ void CBurningVideoDriver::setMaterial(const SMaterial& material)
//if (maxTex < 4) texture3 = 0;
//todo: seperate depth test from depth write
//todo: separate depth test from depth write
Material.depth_write = getWriteZBuffer(in);
Material.depth_test = in.ZBuffer != ECFN_DISABLED && Material.depth_write;

View File

@ -332,7 +332,7 @@ struct ALIGN(16) sVec4
out.z = (z * l) + ofs;
}
//shader suppport
//shader support
sVec4(const sVec4& a, double _w)
{
x = a.x;