mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-17 21:23:48 +01:00
Delete deprecated video driver methods
This commit is contained in:
parent
a7dd075dec
commit
70b0b46d50
@ -13,7 +13,6 @@
|
||||
#include "dimension2d.h"
|
||||
#include "position2d.h"
|
||||
#include "IMeshBuffer.h"
|
||||
#include "triangle3d.h"
|
||||
#include "EDriverTypes.h"
|
||||
#include "EDriverFeatures.h"
|
||||
#include "SExposedVideoData.h"
|
||||
|
@ -128,7 +128,6 @@
|
||||
#include "SSkinMeshBuffer.h"
|
||||
#include "SVertexIndex.h"
|
||||
#include "SViewFrustum.h"
|
||||
#include "triangle3d.h"
|
||||
#include "vector2d.h"
|
||||
#include "vector3d.h"
|
||||
#include "IrrCompileConfig.h" // for IRRLICHT_API and IRRCALLCONV
|
||||
|
@ -1,276 +0,0 @@
|
||||
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "vector3d.h"
|
||||
#include "line3d.h"
|
||||
#include "plane3d.h"
|
||||
#include "aabbox3d.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace core
|
||||
{
|
||||
|
||||
//! 3d triangle template class for doing collision detection and other things.
|
||||
template <class T>
|
||||
class triangle3d
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor for an all 0 triangle
|
||||
triangle3d() {}
|
||||
//! Constructor for triangle with given three vertices
|
||||
triangle3d(const vector3d<T>& v1, const vector3d<T>& v2, const vector3d<T>& v3) : pointA(v1), pointB(v2), pointC(v3) {}
|
||||
|
||||
//! Equality operator
|
||||
bool operator==(const triangle3d<T>& other) const
|
||||
{
|
||||
return other.pointA==pointA && other.pointB==pointB && other.pointC==pointC;
|
||||
}
|
||||
|
||||
//! Inequality operator
|
||||
bool operator!=(const triangle3d<T>& other) const
|
||||
{
|
||||
return !(*this==other);
|
||||
}
|
||||
|
||||
//! Determines if the triangle is totally inside a bounding box.
|
||||
/** \param box Box to check.
|
||||
\return True if triangle is within the box, otherwise false. */
|
||||
bool isTotalInsideBox(const aabbox3d<T>& box) const
|
||||
{
|
||||
return (box.isPointInside(pointA) &&
|
||||
box.isPointInside(pointB) &&
|
||||
box.isPointInside(pointC));
|
||||
}
|
||||
|
||||
//! Determines if the triangle is totally outside a bounding box.
|
||||
/** \param box Box to check.
|
||||
\return True if triangle is outside the box, otherwise false. */
|
||||
bool isTotalOutsideBox(const aabbox3d<T>& box) const
|
||||
{
|
||||
return ((pointA.X > box.MaxEdge.X && pointB.X > box.MaxEdge.X && pointC.X > box.MaxEdge.X) ||
|
||||
|
||||
(pointA.Y > box.MaxEdge.Y && pointB.Y > box.MaxEdge.Y && pointC.Y > box.MaxEdge.Y) ||
|
||||
(pointA.Z > box.MaxEdge.Z && pointB.Z > box.MaxEdge.Z && pointC.Z > box.MaxEdge.Z) ||
|
||||
(pointA.X < box.MinEdge.X && pointB.X < box.MinEdge.X && pointC.X < box.MinEdge.X) ||
|
||||
(pointA.Y < box.MinEdge.Y && pointB.Y < box.MinEdge.Y && pointC.Y < box.MinEdge.Y) ||
|
||||
(pointA.Z < box.MinEdge.Z && pointB.Z < box.MinEdge.Z && pointC.Z < box.MinEdge.Z));
|
||||
}
|
||||
|
||||
//! Get the closest point on a triangle to a point on the same plane.
|
||||
/** \param p Point which must be on the same plane as the triangle.
|
||||
\return The closest point of the triangle */
|
||||
core::vector3d<T> closestPointOnTriangle(const core::vector3d<T>& p) const
|
||||
{
|
||||
const core::vector3d<T> rab = line3d<T>(pointA, pointB).getClosestPoint(p);
|
||||
const core::vector3d<T> rbc = line3d<T>(pointB, pointC).getClosestPoint(p);
|
||||
const core::vector3d<T> rca = line3d<T>(pointC, pointA).getClosestPoint(p);
|
||||
|
||||
const T d1 = rab.getDistanceFrom(p);
|
||||
const T d2 = rbc.getDistanceFrom(p);
|
||||
const T d3 = rca.getDistanceFrom(p);
|
||||
|
||||
if (d1 < d2)
|
||||
return d1 < d3 ? rab : rca;
|
||||
|
||||
return d2 < d3 ? rbc : rca;
|
||||
}
|
||||
|
||||
//! Check if a point is inside the triangle (border-points count also as inside)
|
||||
/*
|
||||
\param p Point to test. Assumes that this point is already
|
||||
on the plane of the triangle.
|
||||
\return True if the point is inside the triangle, otherwise false. */
|
||||
bool isPointInside(const vector3d<T>& p) const
|
||||
{
|
||||
vector3d<f64> af64((f64)pointA.X, (f64)pointA.Y, (f64)pointA.Z);
|
||||
vector3d<f64> bf64((f64)pointB.X, (f64)pointB.Y, (f64)pointB.Z);
|
||||
vector3d<f64> cf64((f64)pointC.X, (f64)pointC.Y, (f64)pointC.Z);
|
||||
vector3d<f64> pf64((f64)p.X, (f64)p.Y, (f64)p.Z);
|
||||
return (isOnSameSide(pf64, af64, bf64, cf64) &&
|
||||
isOnSameSide(pf64, bf64, af64, cf64) &&
|
||||
isOnSameSide(pf64, cf64, af64, bf64));
|
||||
}
|
||||
|
||||
//! Check if a point is inside the triangle (border-points count also as inside)
|
||||
/** This method uses a barycentric coordinate system.
|
||||
It is faster than isPointInside but is more susceptible to floating point rounding
|
||||
errors.
|
||||
\param p Point to test. Assumes that this point is already
|
||||
on the plane of the triangle.
|
||||
\return True if point is inside the triangle, otherwise false. */
|
||||
bool isPointInsideFast(const vector3d<T>& p) const
|
||||
{
|
||||
const vector3d<T> a = pointC - pointA;
|
||||
const vector3d<T> b = pointB - pointA;
|
||||
const vector3d<T> c = p - pointA;
|
||||
|
||||
const f64 dotAA = a.dotProduct( a);
|
||||
const f64 dotAB = a.dotProduct( b);
|
||||
const f64 dotAC = a.dotProduct( c);
|
||||
const f64 dotBB = b.dotProduct( b);
|
||||
const f64 dotBC = b.dotProduct( c);
|
||||
|
||||
// get coordinates in barycentric coordinate system
|
||||
const f64 invDenom = 1/(dotAA * dotBB - dotAB * dotAB);
|
||||
const f64 u = (dotBB * dotAC - dotAB * dotBC) * invDenom;
|
||||
const f64 v = (dotAA * dotBC - dotAB * dotAC ) * invDenom;
|
||||
|
||||
// We count border-points as inside to keep downward compatibility.
|
||||
// Rounding-error also needed for some test-cases.
|
||||
return (u > -ROUNDING_ERROR_f32) && (v >= 0) && (u + v < 1+ROUNDING_ERROR_f32);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//! Get an intersection with a 3d line.
|
||||
/** \param line Line to intersect with.
|
||||
\param outIntersection Place to store the intersection point, if there is one.
|
||||
\return True if there was an intersection, false if not. */
|
||||
bool getIntersectionWithLimitedLine(const line3d<T>& line,
|
||||
vector3d<T>& outIntersection) const
|
||||
{
|
||||
return getIntersectionWithLine(line.start,
|
||||
line.getVector(), outIntersection) &&
|
||||
outIntersection.isBetweenPoints(line.start, line.end);
|
||||
}
|
||||
|
||||
|
||||
//! Get an intersection with a 3d line.
|
||||
/** Please note that also points are returned as intersection which
|
||||
are on the line, but not between the start and end point of the line.
|
||||
If you want the returned point be between start and end
|
||||
use getIntersectionWithLimitedLine().
|
||||
\param linePoint Point of the line to intersect with.
|
||||
\param lineVect Vector of the line to intersect with.
|
||||
\param outIntersection Place to store the intersection point, if there is one.
|
||||
\return True if there was an intersection, false if there was not. */
|
||||
bool getIntersectionWithLine(const vector3d<T>& linePoint,
|
||||
const vector3d<T>& lineVect, vector3d<T>& outIntersection) const
|
||||
{
|
||||
if (getIntersectionOfPlaneWithLine(linePoint, lineVect, outIntersection))
|
||||
return isPointInside(outIntersection);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! Calculates the intersection between a 3d line and the plane the triangle is on.
|
||||
/** \param lineVect Vector of the line to intersect with.
|
||||
\param linePoint Point of the line to intersect with.
|
||||
\param outIntersection Place to store the intersection point, if there is one.
|
||||
\return True if there was an intersection, else false. */
|
||||
bool getIntersectionOfPlaneWithLine(const vector3d<T>& linePoint,
|
||||
const vector3d<T>& lineVect, vector3d<T>& outIntersection) const
|
||||
{
|
||||
// Work with f64 to get more precise results (makes enough difference to be worth the casts).
|
||||
const vector3d<f64> linePointf64(linePoint.X, linePoint.Y, linePoint.Z);
|
||||
const vector3d<f64> lineVectf64(lineVect.X, lineVect.Y, lineVect.Z);
|
||||
vector3d<f64> outIntersectionf64;
|
||||
|
||||
core::triangle3d<irr::f64> trianglef64(vector3d<f64>((f64)pointA.X, (f64)pointA.Y, (f64)pointA.Z)
|
||||
,vector3d<f64>((f64)pointB.X, (f64)pointB.Y, (f64)pointB.Z)
|
||||
, vector3d<f64>((f64)pointC.X, (f64)pointC.Y, (f64)pointC.Z));
|
||||
const vector3d<irr::f64> normalf64 = trianglef64.getNormal().normalize();
|
||||
f64 t2;
|
||||
|
||||
if ( core::iszero ( t2 = normalf64.dotProduct(lineVectf64) ) )
|
||||
return false;
|
||||
|
||||
f64 d = trianglef64.pointA.dotProduct(normalf64);
|
||||
f64 t = -(normalf64.dotProduct(linePointf64) - d) / t2;
|
||||
outIntersectionf64 = linePointf64 + (lineVectf64 * t);
|
||||
|
||||
outIntersection.X = (T)outIntersectionf64.X;
|
||||
outIntersection.Y = (T)outIntersectionf64.Y;
|
||||
outIntersection.Z = (T)outIntersectionf64.Z;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! Get the normal of the triangle.
|
||||
/** Please note: The normal is not always normalized. */
|
||||
vector3d<T> getNormal() const
|
||||
{
|
||||
return (pointB - pointA).crossProduct(pointC - pointA);
|
||||
}
|
||||
|
||||
//! Test if the triangle would be front or backfacing from any point.
|
||||
/** Thus, this method assumes a camera position from which the
|
||||
triangle is definitely visible when looking at the given direction.
|
||||
Do not use this method with points as it will give wrong results!
|
||||
\param lookDirection Look direction.
|
||||
\return True if the plane is front facing and false if it is backfacing. */
|
||||
bool isFrontFacing(const vector3d<T>& lookDirection) const
|
||||
{
|
||||
const vector3d<T> n = getNormal().normalize();
|
||||
const f32 d = (f32)n.dotProduct(lookDirection);
|
||||
return F32_LOWER_EQUAL_0(d);
|
||||
}
|
||||
|
||||
//! Get the plane of this triangle.
|
||||
plane3d<T> getPlane() const
|
||||
{
|
||||
return plane3d<T>(pointA, pointB, pointC);
|
||||
}
|
||||
|
||||
//! Get the area of the triangle
|
||||
T getArea() const
|
||||
{
|
||||
return (pointB - pointA).crossProduct(pointC - pointA).getLength() * 0.5f;
|
||||
|
||||
}
|
||||
|
||||
//! sets the triangle's points
|
||||
void set(const core::vector3d<T>& a, const core::vector3d<T>& b, const core::vector3d<T>& c)
|
||||
{
|
||||
pointA = a;
|
||||
pointB = b;
|
||||
pointC = c;
|
||||
}
|
||||
|
||||
//! the three points of the triangle
|
||||
vector3d<T> pointA;
|
||||
vector3d<T> pointB;
|
||||
vector3d<T> pointC;
|
||||
|
||||
private:
|
||||
// Using f64 instead of <T> to avoid integer overflows when T=int (maybe also less floating point troubles).
|
||||
bool isOnSameSide(const vector3d<f64>& p1, const vector3d<f64>& p2,
|
||||
const vector3d<f64>& a, const vector3d<f64>& b) const
|
||||
{
|
||||
vector3d<f64> bminusa = b - a;
|
||||
vector3d<f64> cp1 = bminusa.crossProduct(p1 - a);
|
||||
vector3d<f64> cp2 = bminusa.crossProduct(p2 - a);
|
||||
f64 res = cp1.dotProduct(cp2);
|
||||
if ( res < 0 )
|
||||
{
|
||||
// This catches some floating point troubles.
|
||||
// Unfortunately slightly expensive and we don't really know the best epsilon for iszero.
|
||||
vector3d<f64> cp1n = bminusa.normalize().crossProduct((p1 - a).normalize());
|
||||
if (core::iszero(cp1n.X, (f64)ROUNDING_ERROR_f32)
|
||||
&& core::iszero(cp1n.Y, (f64)ROUNDING_ERROR_f32)
|
||||
&& core::iszero(cp1n.Z, (f64)ROUNDING_ERROR_f32) )
|
||||
{
|
||||
res = 0.f;
|
||||
}
|
||||
}
|
||||
return (res >= 0.0f);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//! Typedef for a f32 3d triangle.
|
||||
typedef triangle3d<f32> triangle3df;
|
||||
|
||||
//! Typedef for an integer 3d triangle.
|
||||
typedef triangle3d<s32> triangle3di;
|
||||
|
||||
} // end namespace core
|
||||
} // end namespace irr
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "CMeshBuffer.h"
|
||||
#include "SAnimatedMesh.h"
|
||||
#include "os.h"
|
||||
#include "triangle3d.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
@ -1891,16 +1891,6 @@ void CNullDriver::enableClipPlane(u32 index, bool enable)
|
||||
}
|
||||
|
||||
|
||||
ITexture* CNullDriver::createRenderTargetTexture(const core::dimension2d<u32>& size,
|
||||
const c8* name)
|
||||
{
|
||||
os::Printer::log("createRenderTargetTexture is deprecated, use addRenderTargetTexture instead");
|
||||
ITexture* tex = addRenderTargetTexture(size, name);
|
||||
tex->grab();
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
||||
void CNullDriver::setMinHardwareBufferVertexCount(u32 count)
|
||||
{
|
||||
MinVertexCountForVBO = count;
|
||||
|
@ -119,9 +119,6 @@ namespace video
|
||||
virtual void draw3DLine(const core::vector3df& start,
|
||||
const core::vector3df& end, SColor color = SColor(255,255,255,255)) override;
|
||||
|
||||
[[deprecated]] virtual void draw3DTriangle(const core::triangle3df& triangle,
|
||||
SColor color = SColor(255,255,255,255)) {}
|
||||
|
||||
//! Draws a 3d axis aligned box.
|
||||
virtual void draw3DBox(const core::aabbox3d<f32>& box,
|
||||
SColor color = SColor(255,255,255,255)) override;
|
||||
@ -129,32 +126,6 @@ namespace video
|
||||
//! draws an 2d image
|
||||
void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, bool useAlphaChannelOfTexture) override;
|
||||
|
||||
//! draws a set of 2d images, using a color and the alpha
|
||||
/** channel of the texture if desired. The images are drawn
|
||||
beginning at pos and concatenated in one line. All drawings
|
||||
are clipped against clipRect (if != 0).
|
||||
The subtextures are defined by the array of sourceRects
|
||||
and are chosen by the indices given.
|
||||
\param texture: Texture to be drawn.
|
||||
\param pos: Upper left 2d destination position where the image will be drawn.
|
||||
\param sourceRects: Source rectangles of the image.
|
||||
\param indices: List of indices which choose the actual rectangle used each time.
|
||||
\param kerningWidth: offset on position
|
||||
\param clipRect: Pointer to rectangle on the screen where the image is clipped to.
|
||||
This pointer can be 0. Then the image is not clipped.
|
||||
\param color: Color with which the image is colored.
|
||||
Note that the alpha component is used: If alpha is other than 255, the image will be transparent.
|
||||
\param useAlphaChannelOfTexture: If true, the alpha channel of the texture is
|
||||
used to draw the image. */
|
||||
[[deprecated]] virtual void draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::position2d<s32>& pos,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::array<s32>& indices,
|
||||
s32 kerningWidth = 0,
|
||||
const core::rect<s32>* clipRect = 0,
|
||||
SColor color=SColor(255,255,255,255),
|
||||
bool useAlphaChannelOfTexture=false) {}
|
||||
|
||||
//! Draws a set of 2d images, using a color and the alpha channel of the texture.
|
||||
/** All drawings are clipped against clipRect (if != 0).
|
||||
The subtextures are defined by the array of sourceRects and are
|
||||
@ -196,21 +167,11 @@ namespace video
|
||||
SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
|
||||
const core::rect<s32>* clip = 0) override;
|
||||
|
||||
//! Draws the outline of a 2d rectangle
|
||||
[[deprecated]] virtual void draw2DRectangleOutline(const core::recti& pos, SColor color=SColor(255,255,255,255)) {}
|
||||
|
||||
//! Draws a 2d line.
|
||||
virtual void draw2DLine(const core::position2d<s32>& start,
|
||||
const core::position2d<s32>& end,
|
||||
SColor color=SColor(255,255,255,255)) override;
|
||||
|
||||
//! Draws a pixel
|
||||
[[deprecated]] virtual void drawPixel(u32 x, u32 y, const SColor & color) {}
|
||||
|
||||
//! Draws a non filled concyclic reqular 2d polygon.
|
||||
[[deprecated]] virtual void draw2DPolygon(core::position2d<s32> center,
|
||||
f32 radius, video::SColor Color, s32 vertexCount) {}
|
||||
|
||||
virtual void setFog(SColor color=SColor(0,255,255,255),
|
||||
E_FOG_TYPE fogType=EFT_FOG_LINEAR,
|
||||
f32 start=50.0f, f32 end=100.0f, f32 density=0.01f,
|
||||
@ -257,22 +218,6 @@ namespace video
|
||||
//! Adds an external image writer to the engine.
|
||||
void addExternalImageWriter(IImageWriter* writer) override;
|
||||
|
||||
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
|
||||
//! this: First, draw all geometry. Then use this method, to draw the shadow
|
||||
//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
|
||||
[[deprecated]] virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles,
|
||||
bool zfail=true, u32 debugDataVisible=0) {}
|
||||
|
||||
//! Fills the stencil shadow with color. After the shadow volume has been drawn
|
||||
//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this
|
||||
//! to draw the color of the shadow.
|
||||
[[deprecated]] virtual void drawStencilShadow(bool clearStencilBuffer=false,
|
||||
video::SColor leftUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor leftDownEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightDownEdge = video::SColor(0,0,0,0)) {}
|
||||
|
||||
|
||||
//! Removes a texture from the texture cache and deletes it, freeing lot of
|
||||
//! memory.
|
||||
void removeTexture(ITexture* texture) override;
|
||||
@ -605,10 +550,6 @@ namespace video
|
||||
virtual void convertColor(const void* sP, ECOLOR_FORMAT sF, s32 sN,
|
||||
void* dP, ECOLOR_FORMAT dF) const override;
|
||||
|
||||
//! deprecated method
|
||||
virtual ITexture* createRenderTargetTexture(const core::dimension2d<u32>& size,
|
||||
const c8* name=0);
|
||||
|
||||
bool checkDriverReset() override {return false;}
|
||||
protected:
|
||||
|
||||
|
@ -1021,84 +1021,6 @@ void COGLES1Driver::draw2DImage(const video::ITexture* texture, u32 layer, bool
|
||||
}
|
||||
|
||||
|
||||
//! draws a set of 2d images, using a color and the alpha channel
|
||||
void COGLES1Driver::draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::position2d<s32>& pos,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::array<s32>& indices, s32 kerningWidth,
|
||||
const core::rect<s32>* clipRect, SColor color,
|
||||
bool useAlphaChannelOfTexture)
|
||||
{
|
||||
if (!texture)
|
||||
return;
|
||||
|
||||
if (!CacheHandler->getTextureCache().set(0, texture))
|
||||
return;
|
||||
|
||||
setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture);
|
||||
|
||||
if (clipRect)
|
||||
{
|
||||
if (!clipRect->isValid())
|
||||
return;
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
|
||||
glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height-clipRect->LowerRightCorner.Y,
|
||||
clipRect->getWidth(),clipRect->getHeight());
|
||||
}
|
||||
|
||||
const core::dimension2du& ss = texture->getOriginalSize();
|
||||
core::position2d<s32> targetPos(pos);
|
||||
// texcoords need to be flipped horizontally for RTTs
|
||||
const bool isRTT = texture->isRenderTarget();
|
||||
const f32 invW = 1.f / static_cast<f32>(ss.Width);
|
||||
const f32 invH = 1.f / static_cast<f32>(ss.Height);
|
||||
|
||||
core::array<S3DVertex> vertices;
|
||||
core::array<u16> quadIndices;
|
||||
vertices.reallocate(indices.size()*4);
|
||||
quadIndices.reallocate(indices.size()*6);
|
||||
for (u32 i=0; i<indices.size(); ++i)
|
||||
{
|
||||
const s32 currentIndex = indices[i];
|
||||
if (!sourceRects[currentIndex].isValid())
|
||||
break;
|
||||
|
||||
const core::rect<f32> tcoords(
|
||||
sourceRects[currentIndex].UpperLeftCorner.X * invW,
|
||||
(isRTT?sourceRects[currentIndex].LowerRightCorner.Y:sourceRects[currentIndex].UpperLeftCorner.Y) * invH,
|
||||
sourceRects[currentIndex].LowerRightCorner.X * invW,
|
||||
(isRTT?sourceRects[currentIndex].UpperLeftCorner.Y:sourceRects[currentIndex].LowerRightCorner.Y) * invH);
|
||||
|
||||
const core::rect<s32> poss(targetPos, sourceRects[currentIndex].getSize());
|
||||
|
||||
const u32 vstart = vertices.size();
|
||||
|
||||
vertices.push_back(S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y, 0, 0,0,1, color, tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y));
|
||||
vertices.push_back(S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y, 0, 0,0,1, color, tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y));
|
||||
vertices.push_back(S3DVertex((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y, 0, 0,0,1, color, tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y));
|
||||
vertices.push_back(S3DVertex((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y, 0, 0,0,1, color, tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y));
|
||||
|
||||
quadIndices.push_back(vstart);
|
||||
quadIndices.push_back(vstart+1);
|
||||
quadIndices.push_back(vstart+2);
|
||||
quadIndices.push_back(vstart);
|
||||
quadIndices.push_back(vstart+2);
|
||||
quadIndices.push_back(vstart+3);
|
||||
|
||||
targetPos.X += sourceRects[currentIndex].getWidth();
|
||||
}
|
||||
if (vertices.size())
|
||||
drawVertexPrimitiveList2d3d(vertices.pointer(), vertices.size(),
|
||||
quadIndices.pointer(), vertices.size()/2,
|
||||
video::EVT_STANDARD, scene::EPT_TRIANGLES,
|
||||
EIT_16BIT, false);
|
||||
if (clipRect)
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
|
||||
//! draws a set of 2d images, using a color and the alpha channel of the texture if desired.
|
||||
void COGLES1Driver::draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::array<core::position2d<s32> >& positions,
|
||||
@ -1312,22 +1234,6 @@ void COGLES1Driver::draw2DLine(const core::position2d<s32>& start,
|
||||
}
|
||||
|
||||
|
||||
//! Draws a pixel
|
||||
void COGLES1Driver::drawPixel(u32 x, u32 y, const SColor &color)
|
||||
{
|
||||
const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
|
||||
if (x > (u32)renderTargetSize.Width || y > (u32)renderTargetSize.Height)
|
||||
return;
|
||||
|
||||
setRenderStates2DMode(color.getAlpha() < 255, false, false);
|
||||
|
||||
u16 indices[] = {0};
|
||||
S3DVertex vertices[1];
|
||||
vertices[0] = S3DVertex((f32)x, (f32)y, 0, 0, 0, 1, color, 0, 0);
|
||||
drawVertexPrimitiveList2d3d(vertices, 1, indices, 1, video::EVT_STANDARD, scene::EPT_POINTS, EIT_16BIT, false);
|
||||
}
|
||||
|
||||
|
||||
//! creates a matrix in supplied GLfloat array to pass to OGLES1
|
||||
inline void COGLES1Driver::getGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m)
|
||||
{
|
||||
@ -2077,182 +1983,6 @@ void COGLES1Driver::setViewPortRaw(u32 width, u32 height)
|
||||
}
|
||||
|
||||
|
||||
//! Draws a shadow volume into the stencil buffer.
|
||||
void COGLES1Driver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible)
|
||||
{
|
||||
const u32 count=triangles.size();
|
||||
if (!StencilBuffer || !count)
|
||||
return;
|
||||
|
||||
u8 colorMask = LastMaterial.ColorMask;
|
||||
const GLboolean lightingEnabled = glIsEnabled(GL_LIGHTING);
|
||||
const GLboolean fogEnabled = glIsEnabled(GL_FOG);
|
||||
const GLboolean cullFaceEnabled = glIsEnabled(GL_CULL_FACE);
|
||||
|
||||
GLint cullFaceMode = 0;
|
||||
glGetIntegerv(GL_CULL_FACE_MODE, &cullFaceMode);
|
||||
GLint depthFunc = 0;
|
||||
glGetIntegerv(GL_DEPTH_FUNC, &depthFunc);
|
||||
GLboolean depthMask = 0;
|
||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_FOG);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
if (!(debugDataVisible & (scene::EDS_SKELETON|scene::EDS_MESH_WIRE_OVERLAY)))
|
||||
{
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(core::vector3df), triangles.const_pointer());
|
||||
|
||||
glStencilMask(~0);
|
||||
glStencilFunc(GL_ALWAYS, 0, ~0);
|
||||
|
||||
GLenum decr = GL_DECR;
|
||||
GLenum incr = GL_INCR;
|
||||
|
||||
#if defined(GL_OES_stencil_wrap)
|
||||
if (FeatureAvailable[COGLESCoreExtensionHandler::IRR_GL_OES_stencil_wrap])
|
||||
{
|
||||
decr = GL_DECR_WRAP_OES;
|
||||
incr = GL_INCR_WRAP_OES;
|
||||
}
|
||||
#endif
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
if (zfail)
|
||||
{
|
||||
glCullFace(GL_FRONT);
|
||||
glStencilOp(GL_KEEP, incr, GL_KEEP);
|
||||
glDrawArrays(GL_TRIANGLES, 0, count);
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glStencilOp(GL_KEEP, decr, GL_KEEP);
|
||||
glDrawArrays(GL_TRIANGLES, 0, count);
|
||||
}
|
||||
else // zpass
|
||||
{
|
||||
glCullFace(GL_BACK);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, incr);
|
||||
glDrawArrays(GL_TRIANGLES, 0, count);
|
||||
|
||||
glCullFace(GL_FRONT);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, decr);
|
||||
glDrawArrays(GL_TRIANGLES, 0, count);
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glColorMask((colorMask & ECP_RED)?GL_TRUE:GL_FALSE,
|
||||
(colorMask & ECP_GREEN)?GL_TRUE:GL_FALSE,
|
||||
(colorMask & ECP_BLUE)?GL_TRUE:GL_FALSE,
|
||||
(colorMask & ECP_ALPHA)?GL_TRUE:GL_FALSE);
|
||||
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
|
||||
if (lightingEnabled)
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
if (fogEnabled)
|
||||
glEnable(GL_FOG);
|
||||
|
||||
if (cullFaceEnabled)
|
||||
glEnable(GL_CULL_FACE);
|
||||
else
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
glCullFace(cullFaceMode);
|
||||
glDepthFunc(depthFunc);
|
||||
glDepthMask(depthMask);
|
||||
}
|
||||
|
||||
|
||||
void COGLES1Driver::drawStencilShadow(bool clearStencilBuffer,
|
||||
video::SColor leftUpEdge, video::SColor rightUpEdge,
|
||||
video::SColor leftDownEdge, video::SColor rightDownEdge)
|
||||
{
|
||||
if (!StencilBuffer)
|
||||
return;
|
||||
|
||||
setTextureRenderStates(SMaterial(), false);
|
||||
|
||||
u8 colorMask = LastMaterial.ColorMask;
|
||||
const GLboolean lightingEnabled = glIsEnabled(GL_LIGHTING);
|
||||
const GLboolean fogEnabled = glIsEnabled(GL_FOG);
|
||||
const GLboolean blendEnabled = glIsEnabled(GL_BLEND);
|
||||
|
||||
GLboolean depthMask = 0;
|
||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask);
|
||||
GLint shadeModel = 0;
|
||||
glGetIntegerv(GL_SHADE_MODEL, &shadeModel);
|
||||
GLint blendSrc = 0, blendDst = 0;
|
||||
glGetIntegerv(GL_BLEND_SRC, &blendSrc);
|
||||
glGetIntegerv(GL_BLEND_DST, &blendDst);
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_FOG);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glStencilFunc(GL_NOTEQUAL, 0, ~0);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
u16 indices[] = {0, 1, 2, 3};
|
||||
S3DVertex vertices[4];
|
||||
vertices[0] = S3DVertex(-1.f, 1.f, 0.9f, 0, 0, 1, leftDownEdge, 0, 0);
|
||||
vertices[1] = S3DVertex(1.f, 1.f, 0.9f, 0, 0, 1, leftUpEdge, 0, 0);
|
||||
vertices[2] = S3DVertex(1.f, -1.f, 0.9f, 0, 0, 1, rightUpEdge, 0, 0);
|
||||
vertices[3] = S3DVertex(-1.f, -1.f, 0.9f, 0, 0, 1, rightDownEdge, 0, 0);
|
||||
drawVertexPrimitiveList2d3d(vertices, 4, indices, 2, EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT, false);
|
||||
|
||||
if (clearStencilBuffer)
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
glColorMask((colorMask & ECP_RED)?GL_TRUE:GL_FALSE,
|
||||
(colorMask & ECP_GREEN)?GL_TRUE:GL_FALSE,
|
||||
(colorMask & ECP_BLUE)?GL_TRUE:GL_FALSE,
|
||||
(colorMask & ECP_ALPHA)?GL_TRUE:GL_FALSE);
|
||||
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
|
||||
if (lightingEnabled)
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
if (fogEnabled)
|
||||
glEnable(GL_FOG);
|
||||
|
||||
if (!blendEnabled)
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
glDepthMask(depthMask);
|
||||
glShadeModel(shadeModel);
|
||||
glBlendFunc(blendSrc, blendDst);
|
||||
}
|
||||
|
||||
|
||||
//! Sets the fog mode.
|
||||
void COGLES1Driver::setFog(SColor c, E_FOG_TYPE fogType, f32 start,
|
||||
f32 end, f32 density, bool pixelFog, bool rangeFog)
|
||||
|
@ -96,15 +96,6 @@ namespace video
|
||||
|
||||
virtual void draw2DImage(const video::ITexture* texture, u32 layer, bool flip);
|
||||
|
||||
//! draws a set of 2d images
|
||||
virtual void draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::position2d<s32>& pos,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::array<s32>& indices, s32 kerningWidth = 0,
|
||||
const core::rect<s32>* clipRect=0,
|
||||
SColor color=SColor(255,255,255,255),
|
||||
bool useAlphaChannelOfTexture=false) override;
|
||||
|
||||
//! draws a set of 2d images, using a color and the alpha channel of the texture if desired.
|
||||
virtual void draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::array<core::position2d<s32> >& positions,
|
||||
@ -127,9 +118,6 @@ namespace video
|
||||
const core::position2d<s32>& end,
|
||||
SColor color=SColor(255,255,255,255)) override;
|
||||
|
||||
//! Draws a single pixel
|
||||
void drawPixel(u32 x, u32 y, const SColor & color) override;
|
||||
|
||||
//! Draws a 3d line.
|
||||
virtual void draw3DLine(const core::vector3df& start,
|
||||
const core::vector3df& end,
|
||||
@ -141,16 +129,6 @@ namespace video
|
||||
//! Sets the dynamic ambient light color.
|
||||
void setAmbientLight(const SColorf& color) override;
|
||||
|
||||
//! Draws a shadow volume into the stencil buffer.
|
||||
void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible=0) override;
|
||||
|
||||
//! Fills the stencil shadow with color.
|
||||
virtual void drawStencilShadow(bool clearStencilBuffer=false,
|
||||
video::SColor leftUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor leftDownEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightDownEdge = video::SColor(0,0,0,0)) override;
|
||||
|
||||
//! sets a viewport
|
||||
void setViewPort(const core::rect<s32>& area) override;
|
||||
|
||||
|
@ -1614,103 +1614,6 @@ void COpenGLDriver::draw2DImageBatch(const video::ITexture* texture,
|
||||
}
|
||||
|
||||
|
||||
//! draws a set of 2d images, using a color and the alpha channel of the
|
||||
//! texture if desired. The images are drawn beginning at pos and concatenated
|
||||
//! in one line. All drawings are clipped against clipRect (if != 0).
|
||||
//! The subtextures are defined by the array of sourceRects and are chosen
|
||||
//! by the indices given.
|
||||
void COpenGLDriver::draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::position2d<s32>& pos,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::array<s32>& indices,
|
||||
s32 kerningWidth,
|
||||
const core::rect<s32>* clipRect, SColor color,
|
||||
bool useAlphaChannelOfTexture)
|
||||
{
|
||||
if (!texture)
|
||||
return;
|
||||
|
||||
disableTextures(1);
|
||||
if (!CacheHandler->getTextureCache().set(0, texture))
|
||||
return;
|
||||
setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture);
|
||||
|
||||
if (clipRect)
|
||||
{
|
||||
if (!clipRect->isValid())
|
||||
return;
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
|
||||
glScissor(clipRect->UpperLeftCorner.X, renderTargetSize.Height-clipRect->LowerRightCorner.Y,
|
||||
clipRect->getWidth(),clipRect->getHeight());
|
||||
}
|
||||
|
||||
const core::dimension2d<u32>& ss = texture->getOriginalSize();
|
||||
core::position2d<s32> targetPos(pos);
|
||||
const f32 invW = 1.f / static_cast<f32>(ss.Width);
|
||||
const f32 invH = 1.f / static_cast<f32>(ss.Height);
|
||||
|
||||
Quad2DVertices[0].Color = color;
|
||||
Quad2DVertices[1].Color = color;
|
||||
Quad2DVertices[2].Color = color;
|
||||
Quad2DVertices[3].Color = color;
|
||||
|
||||
if (!FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra])
|
||||
getColorBuffer(Quad2DVertices, 4, EVT_STANDARD);
|
||||
|
||||
CacheHandler->setClientState(true, false, true, true);
|
||||
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(Quad2DVertices))[0].TCoords);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(Quad2DVertices))[0].Pos);
|
||||
|
||||
#ifdef GL_BGRA
|
||||
const GLint colorSize=(FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])?GL_BGRA:4;
|
||||
#else
|
||||
const GLint colorSize=4;
|
||||
#endif
|
||||
if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])
|
||||
glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(Quad2DVertices))[0].Color);
|
||||
else
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(ColorBuffer.size()==0);
|
||||
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
|
||||
}
|
||||
|
||||
for (u32 i=0; i<indices.size(); ++i)
|
||||
{
|
||||
const s32 currentIndex = indices[i];
|
||||
if (!sourceRects[currentIndex].isValid())
|
||||
break;
|
||||
|
||||
const core::rect<f32> tcoords(
|
||||
sourceRects[currentIndex].UpperLeftCorner.X * invW,
|
||||
sourceRects[currentIndex].UpperLeftCorner.Y * invH,
|
||||
sourceRects[currentIndex].LowerRightCorner.X * invW,
|
||||
sourceRects[currentIndex].LowerRightCorner.Y * invH);
|
||||
|
||||
const core::rect<s32> poss(targetPos, sourceRects[currentIndex].getSize());
|
||||
|
||||
Quad2DVertices[0].Pos = core::vector3df((f32)poss.UpperLeftCorner.X, (f32)poss.UpperLeftCorner.Y, 0.0f);
|
||||
Quad2DVertices[1].Pos = core::vector3df((f32)poss.LowerRightCorner.X, (f32)poss.UpperLeftCorner.Y, 0.0f);
|
||||
Quad2DVertices[2].Pos = core::vector3df((f32)poss.LowerRightCorner.X, (f32)poss.LowerRightCorner.Y, 0.0f);
|
||||
Quad2DVertices[3].Pos = core::vector3df((f32)poss.UpperLeftCorner.X, (f32)poss.LowerRightCorner.Y, 0.0f);
|
||||
|
||||
Quad2DVertices[0].TCoords = core::vector2df(tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y);
|
||||
Quad2DVertices[1].TCoords = core::vector2df(tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y);
|
||||
Quad2DVertices[2].TCoords = core::vector2df(tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y);
|
||||
Quad2DVertices[3].TCoords = core::vector2df(tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y);
|
||||
|
||||
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices);
|
||||
|
||||
targetPos.X += sourceRects[currentIndex].getWidth();
|
||||
}
|
||||
|
||||
if (clipRect)
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
|
||||
//! draw a 2d rectangle
|
||||
void COpenGLDriver::draw2DRectangle(SColor color, const core::rect<s32>& position,
|
||||
const core::rect<s32>* clip)
|
||||
@ -1790,9 +1693,6 @@ void COpenGLDriver::draw2DRectangle(const core::rect<s32>& position,
|
||||
void COpenGLDriver::draw2DLine(const core::position2d<s32>& start,
|
||||
const core::position2d<s32>& end, SColor color)
|
||||
{
|
||||
if (start==end)
|
||||
drawPixel(start.X, start.Y, color);
|
||||
else
|
||||
{
|
||||
disableTextures();
|
||||
setRenderStates2DMode(color.getAlpha() < 255, false, false);
|
||||
@ -1832,42 +1732,6 @@ void COpenGLDriver::draw2DLine(const core::position2d<s32>& start,
|
||||
}
|
||||
}
|
||||
|
||||
//! Draws a pixel
|
||||
void COpenGLDriver::drawPixel(u32 x, u32 y, const SColor &color)
|
||||
{
|
||||
const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
|
||||
if (x > (u32)renderTargetSize.Width || y > (u32)renderTargetSize.Height)
|
||||
return;
|
||||
|
||||
disableTextures();
|
||||
setRenderStates2DMode(color.getAlpha() < 255, false, false);
|
||||
|
||||
Quad2DVertices[0].Color = color;
|
||||
|
||||
Quad2DVertices[0].Pos = core::vector3df((f32)x, (f32)y, 0.0f);
|
||||
|
||||
if (!FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra])
|
||||
getColorBuffer(Quad2DVertices, 1, EVT_STANDARD);
|
||||
|
||||
CacheHandler->setClientState(true, false, true, false);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(Quad2DVertices))[0].Pos);
|
||||
|
||||
#ifdef GL_BGRA
|
||||
const GLint colorSize=(FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])?GL_BGRA:4;
|
||||
#else
|
||||
const GLint colorSize=4;
|
||||
#endif
|
||||
if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])
|
||||
glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(Quad2DVertices))[0].Color);
|
||||
else
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(ColorBuffer.size()==0);
|
||||
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
|
||||
}
|
||||
|
||||
glDrawArrays(GL_POINTS, 0, 1);
|
||||
}
|
||||
|
||||
//! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled.
|
||||
//! Returns whether disabling was successful or not.
|
||||
@ -2957,234 +2821,6 @@ void COpenGLDriver::setViewPortRaw(u32 width, u32 height)
|
||||
}
|
||||
|
||||
|
||||
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
|
||||
//! this: First, draw all geometry. Then use this method, to draw the shadow
|
||||
//! volume. Next use IVideoDriver::drawStencilShadow() to visualize the shadow.
|
||||
void COpenGLDriver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible)
|
||||
{
|
||||
const u32 count=triangles.size();
|
||||
if (!StencilBuffer || !count)
|
||||
return;
|
||||
|
||||
// unset last 3d material
|
||||
if (CurrentRenderMode == ERM_3D &&
|
||||
static_cast<u32>(Material.MaterialType) < MaterialRenderers.size())
|
||||
{
|
||||
MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial();
|
||||
ResetRenderStates = true;
|
||||
}
|
||||
|
||||
// store current OpenGL state
|
||||
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT |
|
||||
GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_FOG);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
if (debugDataVisible & scene::EDS_MESH_WIRE_OVERLAY)
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
if (!(debugDataVisible & (scene::EDS_SKELETON|scene::EDS_MESH_WIRE_OVERLAY)))
|
||||
{
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // no color buffer drawing
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
CacheHandler->setClientState(true, false, false, false);
|
||||
glVertexPointer(3,GL_FLOAT,sizeof(core::vector3df),triangles.const_pointer());
|
||||
glStencilMask(~0);
|
||||
glStencilFunc(GL_ALWAYS, 0, ~0);
|
||||
|
||||
GLenum incr = GL_INCR;
|
||||
GLenum decr = GL_DECR;
|
||||
#ifdef GL_EXT_stencil_wrap
|
||||
if (FeatureAvailable[IRR_EXT_stencil_wrap])
|
||||
{
|
||||
incr = GL_INCR_WRAP_EXT;
|
||||
decr = GL_DECR_WRAP_EXT;
|
||||
}
|
||||
#endif
|
||||
#ifdef GL_NV_depth_clamp
|
||||
if (FeatureAvailable[IRR_NV_depth_clamp])
|
||||
glEnable(GL_DEPTH_CLAMP_NV);
|
||||
#elif defined(GL_ARB_depth_clamp)
|
||||
if (FeatureAvailable[IRR_ARB_depth_clamp])
|
||||
{
|
||||
glEnable(GL_DEPTH_CLAMP);
|
||||
}
|
||||
#endif
|
||||
|
||||
// The first parts are not correctly working, yet.
|
||||
#if 0
|
||||
#ifdef GL_EXT_stencil_two_side
|
||||
if (FeatureAvailable[IRR_EXT_stencil_two_side])
|
||||
{
|
||||
glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
|
||||
glDisable(GL_CULL_FACE);
|
||||
if (zfail)
|
||||
{
|
||||
extGlActiveStencilFace(GL_BACK);
|
||||
glStencilOp(GL_KEEP, incr, GL_KEEP);
|
||||
glStencilMask(~0);
|
||||
glStencilFunc(GL_ALWAYS, 0, ~0);
|
||||
|
||||
extGlActiveStencilFace(GL_FRONT);
|
||||
glStencilOp(GL_KEEP, decr, GL_KEEP);
|
||||
}
|
||||
else // zpass
|
||||
{
|
||||
extGlActiveStencilFace(GL_BACK);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, decr);
|
||||
glStencilMask(~0);
|
||||
glStencilFunc(GL_ALWAYS, 0, ~0);
|
||||
|
||||
extGlActiveStencilFace(GL_FRONT);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, incr);
|
||||
}
|
||||
glStencilMask(~0);
|
||||
glStencilFunc(GL_ALWAYS, 0, ~0);
|
||||
glDrawArrays(GL_TRIANGLES,0,count);
|
||||
glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (FeatureAvailable[IRR_ATI_separate_stencil])
|
||||
{
|
||||
glDisable(GL_CULL_FACE);
|
||||
if (zfail)
|
||||
{
|
||||
extGlStencilOpSeparate(GL_BACK, GL_KEEP, incr, GL_KEEP);
|
||||
extGlStencilOpSeparate(GL_FRONT, GL_KEEP, decr, GL_KEEP);
|
||||
}
|
||||
else // zpass
|
||||
{
|
||||
extGlStencilOpSeparate(GL_BACK, GL_KEEP, GL_KEEP, decr);
|
||||
extGlStencilOpSeparate(GL_FRONT, GL_KEEP, GL_KEEP, incr);
|
||||
}
|
||||
extGlStencilFuncSeparate(GL_ALWAYS, GL_ALWAYS, 0, ~0);
|
||||
glStencilMask(~0);
|
||||
glDrawArrays(GL_TRIANGLES,0,count);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glEnable(GL_CULL_FACE);
|
||||
if (zfail)
|
||||
{
|
||||
glCullFace(GL_FRONT);
|
||||
glStencilOp(GL_KEEP, incr, GL_KEEP);
|
||||
glDrawArrays(GL_TRIANGLES,0,count);
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glStencilOp(GL_KEEP, decr, GL_KEEP);
|
||||
glDrawArrays(GL_TRIANGLES,0,count);
|
||||
}
|
||||
else // zpass
|
||||
{
|
||||
glCullFace(GL_BACK);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, incr);
|
||||
glDrawArrays(GL_TRIANGLES,0,count);
|
||||
|
||||
glCullFace(GL_FRONT);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, decr);
|
||||
glDrawArrays(GL_TRIANGLES,0,count);
|
||||
}
|
||||
}
|
||||
#ifdef GL_NV_depth_clamp
|
||||
if (FeatureAvailable[IRR_NV_depth_clamp])
|
||||
glDisable(GL_DEPTH_CLAMP_NV);
|
||||
#elif defined(GL_ARB_depth_clamp)
|
||||
if (FeatureAvailable[IRR_ARB_depth_clamp])
|
||||
{
|
||||
glDisable(GL_DEPTH_CLAMP);
|
||||
}
|
||||
#endif
|
||||
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
//! Fills the stencil shadow with color. After the shadow volume has been drawn
|
||||
//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this
|
||||
//! to draw the color of the shadow.
|
||||
void COpenGLDriver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge,
|
||||
video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge)
|
||||
{
|
||||
if (!StencilBuffer)
|
||||
return;
|
||||
|
||||
disableTextures();
|
||||
|
||||
// store attributes
|
||||
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT | GL_LIGHTING_BIT);
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_FOG);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glStencilFunc(GL_NOTEQUAL, 0, ~0);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
|
||||
// draw a shadow rectangle covering the entire screen using stencil buffer
|
||||
CacheHandler->setMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
CacheHandler->setMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
Quad2DVertices[0].Color = leftDownEdge;
|
||||
Quad2DVertices[1].Color = leftUpEdge;
|
||||
Quad2DVertices[2].Color = rightUpEdge;
|
||||
Quad2DVertices[3].Color = rightDownEdge;
|
||||
|
||||
Quad2DVertices[0].Pos = core::vector3df(-1.0f, -1.0f, -0.9f);
|
||||
Quad2DVertices[1].Pos = core::vector3df(-1.0f, 1.0f, -0.9f);
|
||||
Quad2DVertices[2].Pos = core::vector3df(1.0f, 1.0f, -0.9f);
|
||||
Quad2DVertices[3].Pos = core::vector3df(1.0f, -1.0f, -0.9f);
|
||||
|
||||
if (!FeatureAvailable[IRR_ARB_vertex_array_bgra] && !FeatureAvailable[IRR_EXT_vertex_array_bgra])
|
||||
getColorBuffer(Quad2DVertices, 4, EVT_STANDARD);
|
||||
|
||||
CacheHandler->setClientState(true, false, true, false);
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(Quad2DVertices))[0].Pos);
|
||||
|
||||
#ifdef GL_BGRA
|
||||
const GLint colorSize=(FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])?GL_BGRA:4;
|
||||
#else
|
||||
const GLint colorSize=4;
|
||||
#endif
|
||||
if (FeatureAvailable[IRR_ARB_vertex_array_bgra] || FeatureAvailable[IRR_EXT_vertex_array_bgra])
|
||||
glColorPointer(colorSize, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(static_cast<const S3DVertex*>(Quad2DVertices))[0].Color);
|
||||
else
|
||||
{
|
||||
_IRR_DEBUG_BREAK_IF(ColorBuffer.size()==0);
|
||||
glColorPointer(colorSize, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
|
||||
}
|
||||
|
||||
glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, Quad2DIndices);
|
||||
|
||||
if (clearStencilBuffer)
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
// restore settings
|
||||
glPopMatrix();
|
||||
CacheHandler->setMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
|
||||
//! Sets the fog mode.
|
||||
void COpenGLDriver::setFog(SColor c, E_FOG_TYPE fogType, f32 start,
|
||||
f32 end, f32 density, bool pixelFog, bool rangeFog)
|
||||
|
@ -153,31 +153,6 @@ namespace video
|
||||
SColor color,
|
||||
bool useAlphaChannelOfTexture) override;
|
||||
|
||||
//! draws a set of 2d images, using a color and the alpha
|
||||
/** channel of the texture if desired. The images are drawn
|
||||
beginning at pos and concatenated in one line. All drawings
|
||||
are clipped against clipRect (if != 0).
|
||||
The subtextures are defined by the array of sourceRects
|
||||
and are chosen by the indices given.
|
||||
\param texture: Texture to be drawn.
|
||||
\param pos: Upper left 2d destination position where the image will be drawn.
|
||||
\param sourceRects: Source rectangles of the image.
|
||||
\param indices: List of indices which choose the actual rectangle used each time.
|
||||
\param clipRect: Pointer to rectangle on the screen where the image is clipped to.
|
||||
This pointer can be 0. Then the image is not clipped.
|
||||
\param color: Color with which the image is colored.
|
||||
Note that the alpha component is used: If alpha is other than 255, the image will be transparent.
|
||||
\param useAlphaChannelOfTexture: If true, the alpha channel of the texture is
|
||||
used to draw the image. */
|
||||
virtual void draw2DImageBatch(const video::ITexture* texture,
|
||||
const core::position2d<s32>& pos,
|
||||
const core::array<core::rect<s32> >& sourceRects,
|
||||
const core::array<s32>& indices,
|
||||
s32 kerningWidth=0,
|
||||
const core::rect<s32>* clipRect=0,
|
||||
SColor color=SColor(255,255,255,255),
|
||||
bool useAlphaChannelOfTexture=false) override;
|
||||
|
||||
//! draw an 2d rectangle
|
||||
virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
|
||||
const core::rect<s32>* clip = 0) override;
|
||||
@ -192,9 +167,6 @@ namespace video
|
||||
const core::position2d<s32>& end,
|
||||
SColor color=SColor(255,255,255,255)) override;
|
||||
|
||||
//! Draws a single pixel
|
||||
void drawPixel(u32 x, u32 y, const SColor & color) override;
|
||||
|
||||
//! Draws a 3d box
|
||||
void draw3DBox( const core::aabbox3d<f32>& box, SColor color = SColor(255,255,255,255 ) ) override;
|
||||
|
||||
@ -212,20 +184,6 @@ namespace video
|
||||
//! \param color: New color of the ambient light.
|
||||
void setAmbientLight(const SColorf& color) override;
|
||||
|
||||
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
|
||||
//! this: First, draw all geometry. Then use this method, to draw the shadow
|
||||
//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
|
||||
void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible=0) override;
|
||||
|
||||
//! Fills the stencil shadow with color. After the shadow volume has been drawn
|
||||
//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this
|
||||
//! to draw the color of the shadow.
|
||||
virtual void drawStencilShadow(bool clearStencilBuffer=false,
|
||||
video::SColor leftUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightUpEdge = video::SColor(0,0,0,0),
|
||||
video::SColor leftDownEdge = video::SColor(0,0,0,0),
|
||||
video::SColor rightDownEdge = video::SColor(0,0,0,0)) override;
|
||||
|
||||
//! sets a viewport
|
||||
void setViewPort(const core::rect<s32>& area) override;
|
||||
|
||||
|
@ -8,18 +8,9 @@
|
||||
#include "SColor.h"
|
||||
#include "vector3d.h"
|
||||
#include "vector2d.h"
|
||||
#include "line2d.h"
|
||||
#include "line3d.h"
|
||||
#include "triangle3d.h"
|
||||
#include "position2d.h"
|
||||
#include "rect.h"
|
||||
#include "dimension2d.h"
|
||||
#include "matrix4.h"
|
||||
#include "quaternion.h"
|
||||
#include "plane3d.h"
|
||||
#include "triangle3d.h"
|
||||
#include "line2d.h"
|
||||
#include "line3d.h"
|
||||
#include "irrString.h"
|
||||
#include "irrArray.h"
|
||||
#include "EAttributes.h"
|
||||
|
@ -1068,9 +1068,6 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
void COpenGL3DriverBase::draw2DLine(const core::position2d<s32>& start,
|
||||
const core::position2d<s32>& end, SColor color)
|
||||
{
|
||||
if (start==end)
|
||||
drawPixel(start.X, start.Y, color);
|
||||
else
|
||||
{
|
||||
chooseMaterial2D();
|
||||
setMaterialTexture(0, 0);
|
||||
@ -1092,28 +1089,6 @@ COpenGL3DriverBase::~COpenGL3DriverBase()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! Draws a pixel
|
||||
void COpenGL3DriverBase::drawPixel(u32 x, u32 y, const SColor &color)
|
||||
{
|
||||
const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
|
||||
if (x > (u32)renderTargetSize.Width || y > (u32)renderTargetSize.Height)
|
||||
return;
|
||||
|
||||
chooseMaterial2D();
|
||||
setMaterialTexture(0, 0);
|
||||
|
||||
setRenderStates2DMode(color.getAlpha() < 255, false, false);
|
||||
|
||||
f32 X = (f32)x / (f32)renderTargetSize.Width * 2.f - 1.f;
|
||||
f32 Y = 2.f - (f32)y / (f32)renderTargetSize.Height * 2.f - 1.f;
|
||||
|
||||
S3DVertex vertices[1];
|
||||
vertices[0] = S3DVertex(X, Y, 0, 0, 0, 1, color, 0, 0);
|
||||
|
||||
drawArrays(GL_POINTS, vtPrimitive, vertices, 1);
|
||||
}
|
||||
|
||||
void COpenGL3DriverBase::drawQuad(const VertexType &vertexType, const S3DVertex (&vertices)[4])
|
||||
{
|
||||
drawArrays(GL_TRIANGLE_FAN, vertexType, vertices, 4);
|
||||
|
@ -124,17 +124,11 @@ namespace video
|
||||
const core::position2d<s32>& end,
|
||||
SColor color = SColor(255, 255, 255, 255)) override;
|
||||
|
||||
//! Draws a single pixel
|
||||
void drawPixel(u32 x, u32 y, const SColor & color) override;
|
||||
|
||||
//! Draws a 3d line.
|
||||
virtual void draw3DLine(const core::vector3df& start,
|
||||
const core::vector3df& end,
|
||||
SColor color = SColor(255, 255, 255, 255)) override;
|
||||
|
||||
//! Draws a pixel
|
||||
// virtual void drawPixel(u32 x, u32 y, const SColor & color);
|
||||
|
||||
//! Returns the name of the video driver.
|
||||
const char* getName() const override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user