mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Changed BlendMode pre-loaded modes. Now they are a function, since they could be used before the memory initialization provoking errors in emscripten.
GLES2 is now the default renderer for emscripten. Fixed several rendering issues with GLES2 as WebGL (point sprites, bad states). Fixed chipmunk in emscripten. Improved debugging for emscripten debug builds.
This commit is contained in:
@@ -1,60 +1,60 @@
|
||||
uniform sampler2D textureUnit0;
|
||||
uniform vec2 textureRes;
|
||||
uniform float radius;
|
||||
uniform int dir;
|
||||
const float radius = 16.;
|
||||
|
||||
float SCurve (float x) {
|
||||
x = x * 2.0 - 1.0;
|
||||
return -x * abs(x) * 0.5 + x + 0.5;
|
||||
}
|
||||
|
||||
vec4 BlurH(sampler2D source, vec2 size, vec2 uv, float radius) {
|
||||
vec4 BlurH(sampler2D source, vec2 size, vec2 uv) {
|
||||
if (radius >= 1.0) {
|
||||
vec4 A = vec4(0.0);
|
||||
vec4 C = vec4(0.0);
|
||||
float width = 1.0 / size.x;
|
||||
float divisor = 0.0;
|
||||
float divisor = 0.0;
|
||||
float weight = 0.0;
|
||||
float radiusMultiplier = 1.0 / radius;
|
||||
|
||||
|
||||
for (float x = -radius; x <= radius; x++) {
|
||||
A = texture2D(source, uv + vec2(x * width, 0.0));
|
||||
weight = SCurve(1.0 - (abs(x) * radiusMultiplier));
|
||||
C += A * weight;
|
||||
divisor += weight;
|
||||
divisor += weight;
|
||||
}
|
||||
|
||||
return vec4(C.r / divisor, C.g / divisor, C.b / divisor, 1.0);
|
||||
}
|
||||
|
||||
|
||||
return texture2D(source, uv);
|
||||
}
|
||||
|
||||
vec4 BlurV(sampler2D source, vec2 size, vec2 uv, float radius) {
|
||||
vec4 BlurV(sampler2D source, vec2 size, vec2 uv) {
|
||||
if (radius >= 1.0) {
|
||||
vec4 A = vec4(0.0);
|
||||
vec4 C = vec4(0.0);
|
||||
vec4 A = vec4(0.0);
|
||||
vec4 C = vec4(0.0);
|
||||
float height = 1.0 / size.y;
|
||||
float divisor = 0.0;
|
||||
float divisor = 0.0;
|
||||
float weight = 0.0;
|
||||
float radiusMultiplier = 1.0 / radius;
|
||||
|
||||
|
||||
for (float y = -radius; y <= radius; y++) {
|
||||
A = texture2D(source, uv + vec2(0.0, y * height));
|
||||
weight = SCurve(1.0 - (abs(y) * radiusMultiplier));
|
||||
C += A * weight;
|
||||
divisor += weight;
|
||||
divisor += weight;
|
||||
}
|
||||
|
||||
|
||||
return vec4(C.r / divisor, C.g / divisor, C.b / divisor, 1.0);
|
||||
}
|
||||
|
||||
|
||||
return texture2D(source, uv);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = dir != 0 ?
|
||||
BlurV(textureUnit0, textureRes.xy, gl_TexCoord[0].xy, radius) :
|
||||
BlurH(textureUnit0, textureRes.xy, gl_TexCoord[0].xy, radius);
|
||||
BlurV(textureUnit0, textureRes.xy, gl_TexCoord[0].xy) :
|
||||
BlurH(textureUnit0, textureRes.xy, gl_TexCoord[0].xy);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class EE_API BatchRenderer {
|
||||
Texture::CoordinateType coordinateType = Texture::CoordinateType::Normalized );
|
||||
|
||||
/** Set the predefined blending function to use on the batch */
|
||||
void setBlendMode( const BlendMode& Blend );
|
||||
void setBlendMode( const BlendMode& blend );
|
||||
|
||||
/** Set if every batch call have to be immediately rendered */
|
||||
void setBatchForceRendering( const bool& force ) { mForceRendering = force; }
|
||||
@@ -303,28 +303,28 @@ class EE_API BatchRenderer {
|
||||
const bool& getForceBlendModeChange() const;
|
||||
|
||||
protected:
|
||||
VertexData* mVertex;
|
||||
unsigned int mVertexSize;
|
||||
VertexData* mTVertex;
|
||||
unsigned int mNumVertex;
|
||||
VertexData* mVertex{ nullptr };
|
||||
unsigned int mVertexSize{ 0 };
|
||||
VertexData* mTVertex{ nullptr };
|
||||
unsigned int mNumVertex{ 0 };
|
||||
|
||||
const Texture* mTexture;
|
||||
BlendMode mBlend;
|
||||
const Texture* mTexture{ nullptr };
|
||||
BlendMode mBlend{ BlendMode::Alpha() };
|
||||
|
||||
Vector2f mTexCoord[4];
|
||||
Color mVerColor[4];
|
||||
Vector2f mTexCoord[4]{ Vector2f::Zero, Vector2f::Zero, Vector2f::Zero, Vector2f::Zero };
|
||||
Color mVerColor[4]{ Color::White, Color::White, Color::White, Color::White };
|
||||
|
||||
PrimitiveType mCurrentMode;
|
||||
PrimitiveType mCurrentMode{ PRIMITIVE_QUADS };
|
||||
|
||||
Float mRotation;
|
||||
Vector2f mScale;
|
||||
Vector2f mPosition;
|
||||
Vector2f mCenter;
|
||||
Float mRotation{ 0.f };
|
||||
Vector2f mScale{ 1.f, 1.f };
|
||||
Vector2f mPosition{ 0.f, 0.f };
|
||||
Vector2f mCenter{ 0.f, 0.f };
|
||||
|
||||
Texture::CoordinateType mCoordinateType;
|
||||
Texture::CoordinateType mCoordinateType{ Texture::CoordinateType::Normalized };
|
||||
|
||||
bool mForceRendering;
|
||||
bool mForceBlendMode;
|
||||
bool mForceRendering{ false };
|
||||
bool mForceBlendMode{ true };
|
||||
|
||||
void flush();
|
||||
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
#define EE_GRAPHICS_BLENDMODE_HPP
|
||||
|
||||
#include <eepp/config.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
class EE_API BlendMode {
|
||||
public:
|
||||
enum Factor {
|
||||
enum class Factor {
|
||||
Zero, /// (0, 0, 0, 0)
|
||||
One, /// (1, 1, 1, 1)
|
||||
SrcColor, /// (src.r, src.g, src.b, src.a)
|
||||
@@ -20,15 +21,24 @@ class EE_API BlendMode {
|
||||
OneMinusDstAlpha /// (1, 1, 1, 1) - (dst.a, dst.a, dst.a, dst.a)
|
||||
};
|
||||
|
||||
enum Equation {
|
||||
enum class Equation {
|
||||
Add, /// Pixel = Src * SrcFactor + Dst * DstFactor
|
||||
Subtract, /// Pixel = Src * SrcFactor - Dst * DstFactor
|
||||
ReverseSubtract /// Pixel = Dst * DstFactor - Src * SrcFactor
|
||||
};
|
||||
|
||||
static BlendMode Alpha(); /// Blend source and dest according to dest alpha
|
||||
static BlendMode Add(); /// Add source to dest
|
||||
static BlendMode Multiply(); /// Multiply source and dest
|
||||
static BlendMode None(); /// Overwrite dest with source
|
||||
|
||||
static std::string equationToString( const Equation& eq );
|
||||
|
||||
static std::string factorToString( const Factor& fc );
|
||||
|
||||
BlendMode();
|
||||
|
||||
BlendMode( Factor sourceFactor, Factor destinationFactor, Equation blendEquation = Add );
|
||||
BlendMode( Factor sourceFactor, Factor destinationFactor, Equation blendEquation = BlendMode::Equation::Add );
|
||||
|
||||
BlendMode( Factor colorSourceFactor, Factor colorDestinationFactor, Equation colorBlendEquation,
|
||||
Factor alphaSourceFactor, Factor alphaDestinationFactor,
|
||||
@@ -50,6 +60,8 @@ class EE_API BlendMode {
|
||||
Factor alphaDstFactor; /// Destination blending factor for the alpha channel
|
||||
Equation alphaEquation; /// Blending equation for the alpha channel
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
protected:
|
||||
static BlendMode sLastBlend;
|
||||
};
|
||||
@@ -57,11 +69,6 @@ class EE_API BlendMode {
|
||||
EE_API bool operator==( const BlendMode& left, const BlendMode& right );
|
||||
EE_API bool operator!=( const BlendMode& left, const BlendMode& right );
|
||||
|
||||
EE_API extern const BlendMode BlendAlpha; /// Blend source and dest according to dest alpha
|
||||
EE_API extern const BlendMode BlendAdd; /// Add source to dest
|
||||
EE_API extern const BlendMode BlendMultiply; /// Multiply source and dest
|
||||
EE_API extern const BlendMode BlendNone; /// Overwrite dest with source
|
||||
|
||||
}} // namespace EE::Graphics
|
||||
|
||||
#endif
|
||||
|
||||
@@ -82,6 +82,7 @@ class EE_API RendererGLES2 : public RendererGLShader {
|
||||
Int32 mTexActive;
|
||||
int mTexActiveLoc;
|
||||
int mClippingEnabledLoc;
|
||||
int mPointSizeLoc;
|
||||
float mPointSize;
|
||||
int mTextureUnits[EE_MAX_TEXTURE_UNITS];
|
||||
int mTextureUnitsStates[EE_MAX_TEXTURE_UNITS];
|
||||
|
||||
@@ -28,10 +28,11 @@ class EE_API ScrollParallax {
|
||||
* @param size The size of the parallax
|
||||
* @param speed Speed of movement ( in Pixels Per Second )
|
||||
* @param color The Texture Color
|
||||
* @param Blend The Blend Mode ( default BlendAlpha ) */
|
||||
* @param Blend The Blend Mode ( default BlendMode::Alpha() ) */
|
||||
ScrollParallax( TextureRegion* textureRegion, const Vector2f& position = Vector2f(),
|
||||
const Sizef& size = Sizef(), const Vector2f& speed = Vector2f(),
|
||||
const Color& color = Color::White, const BlendMode& Blend = BlendAlpha );
|
||||
const Color& color = Color::White,
|
||||
const BlendMode& Blend = BlendMode::Alpha() );
|
||||
|
||||
/** Create's the Scroll Parallax
|
||||
* @param textureRegion The TextureRegion to Draw
|
||||
@@ -39,12 +40,12 @@ class EE_API ScrollParallax {
|
||||
* @param size The size of the parallax
|
||||
* @param speed Speed of movement ( in Pixels Per Second )
|
||||
* @param color The Texture Color
|
||||
* @param Blend The Blend Mode ( default BlendAlpha )
|
||||
* @param Blend The Blend Mode ( default BlendMode::Alpha() )
|
||||
* @return True if success
|
||||
*/
|
||||
bool create( TextureRegion* textureRegion, const Vector2f& position = Vector2f(),
|
||||
const Sizef& size = Sizef(), const Vector2f& speed = Vector2f(),
|
||||
const Color& color = Color::White, const BlendMode& Blend = BlendAlpha );
|
||||
const Color& color = Color::White, const BlendMode& Blend = BlendMode::Alpha() );
|
||||
|
||||
/** Set the parallax texture color. */
|
||||
void setColor( const Color& Color ) { mColor = Color; }
|
||||
|
||||
@@ -356,27 +356,28 @@ class EE_API Sprite : public Drawable {
|
||||
SPRITE_FLAG_EVENTS_ENABLED = ( 1 << 4 )
|
||||
};
|
||||
|
||||
Uint32 mFlags;
|
||||
OriginPoint mOrigin;
|
||||
Float mRotation;
|
||||
Vector2f mScale;
|
||||
Float mAnimSpeed;
|
||||
Uint32 mFlags{ SPRITE_FLAG_AUTO_ANIM | SPRITE_FLAG_EVENTS_ENABLED };
|
||||
OriginPoint mOrigin{ OriginPoint::OriginCenter };
|
||||
Float mRotation{ 0.f };
|
||||
Vector2f mScale{ 1.f, 1.f };
|
||||
Float mAnimSpeed{ 16.f };
|
||||
|
||||
Color* mVertexColors;
|
||||
Color* mVertexColors{ nullptr };
|
||||
|
||||
int mRepetitions; //!< Number of repetions of the animation, default -1 that equals to loop.
|
||||
int mRepetitions{
|
||||
-1 }; //!< Number of repetions of the animation, default -1 that equals to loop.
|
||||
|
||||
BlendMode mBlend;
|
||||
RenderMode mEffect;
|
||||
BlendMode mBlend{ BlendMode::Alpha() };
|
||||
RenderMode mEffect{ RENDER_NORMAL };
|
||||
|
||||
unsigned int mCurrentFrame;
|
||||
Float mfCurrentFrame;
|
||||
unsigned int mCurrentSubFrame;
|
||||
unsigned int mSubFrames;
|
||||
unsigned int mAnimTo;
|
||||
unsigned int mCurrentFrame{ 0 };
|
||||
Float mfCurrentFrame{ 0 };
|
||||
unsigned int mCurrentSubFrame{ 0 };
|
||||
unsigned int mSubFrames{ 1 };
|
||||
unsigned int mAnimTo{ 0 };
|
||||
|
||||
SpriteCallback mCb;
|
||||
void* mUserData;
|
||||
void* mUserData{ nullptr };
|
||||
|
||||
class Frame {
|
||||
public:
|
||||
|
||||
@@ -96,7 +96,7 @@ class EE_API Text {
|
||||
|
||||
/** Draw the cached text on screen */
|
||||
void draw( const Float& X, const Float& Y, const Vector2f& scale = Vector2f::One,
|
||||
const Float& rotation = 0, BlendMode effect = BlendAlpha,
|
||||
const Float& rotation = 0, BlendMode effect = BlendMode::Alpha(),
|
||||
const OriginPoint& rotationCenter = OriginPoint::OriginCenter,
|
||||
const OriginPoint& scaleCenter = OriginPoint::OriginCenter );
|
||||
|
||||
|
||||
@@ -179,13 +179,13 @@ class EE_API Texture : public DrawableResource, public Image, private NonCopyabl
|
||||
* @param Angle The Angle of the texture rendered
|
||||
* @param scale The Scale factor of the rendered texture
|
||||
* @param color The texture color
|
||||
* @param Blend Set the Blend Mode ( default BlendAlpha )
|
||||
* @param Blend Set the Blend Mode ( default BlendMode::Alpha() )
|
||||
* @param width The width of the texture rendered
|
||||
* @param height The height of the texture rendered
|
||||
*/
|
||||
void drawFast( const Float& x, const Float& y, const Float& Angle = 0.0f,
|
||||
const Vector2f& scale = Vector2f::One, const Color& color = Color::White,
|
||||
const BlendMode& Blend = BlendAlpha, const Float& width = 0,
|
||||
const BlendMode& Blend = BlendMode::Alpha(), const Float& width = 0,
|
||||
const Float& height = 0 );
|
||||
|
||||
/** Render the texture on screen
|
||||
@@ -194,7 +194,7 @@ class EE_API Texture : public DrawableResource, public Image, private NonCopyabl
|
||||
* @param Angle The Angle of the texture rendered
|
||||
* @param scale The Scale factor of the rendered texture
|
||||
* @param color The texture color
|
||||
* @param Blend Set the Blend Mode ( default BlendAlpha )
|
||||
* @param Blend Set the Blend Mode ( default BlendMode::Alpha() )
|
||||
* @param Effect Set the Render Effect ( default RN_NORMAL, no effect )
|
||||
* @param Center The rotation and scaling center. The center point is relative to the top-left
|
||||
* corner of the object.
|
||||
@@ -203,7 +203,7 @@ class EE_API Texture : public DrawableResource, public Image, private NonCopyabl
|
||||
*/
|
||||
void draw( const Float& x, const Float& y, const Float& Angle = 0,
|
||||
const Vector2f& scale = Vector2f::One, const Color& color = Color::White,
|
||||
const BlendMode& Blend = BlendAlpha, const RenderMode& Effect = RENDER_NORMAL,
|
||||
const BlendMode& Blend = BlendMode::Alpha(), const RenderMode& Effect = RENDER_NORMAL,
|
||||
OriginPoint Center = OriginPoint( OriginPoint::OriginCenter ),
|
||||
const Rect& texSector = Rect( 0, 0, 0, 0 ) );
|
||||
|
||||
@@ -220,7 +220,7 @@ class EE_API Texture : public DrawableResource, public Image, private NonCopyabl
|
||||
* @param Color1 The Left - Bottom vertex color
|
||||
* @param Color2 The Right - Bottom vertex color
|
||||
* @param Color3 The Right - Top vertex color
|
||||
* @param Blend Set the Blend Mode ( default BlendAlpha )
|
||||
* @param Blend Set the Blend Mode ( default BlendMode::Alpha() )
|
||||
* @param Effect Set the Render Effect ( default RN_NORMAL, no effect )
|
||||
* @param Center The rotation and scaling center. The center point is relative to the top-left
|
||||
* corner of the object.
|
||||
@@ -232,7 +232,7 @@ class EE_API Texture : public DrawableResource, public Image, private NonCopyabl
|
||||
const Color& Color1 = Color( 255, 255, 255, 255 ),
|
||||
const Color& Color2 = Color( 255, 255, 255, 255 ),
|
||||
const Color& Color3 = Color( 255, 255, 255, 255 ),
|
||||
const BlendMode& Blend = BlendAlpha, const RenderMode& Effect = RENDER_NORMAL,
|
||||
const BlendMode& Blend = BlendMode::Alpha(), const RenderMode& Effect = RENDER_NORMAL,
|
||||
OriginPoint Center = OriginPoint( OriginPoint::OriginCenter ),
|
||||
const Rect& texSector = Rect( 0, 0, 0, 0 ) );
|
||||
|
||||
@@ -242,13 +242,13 @@ class EE_API Texture : public DrawableResource, public Image, private NonCopyabl
|
||||
* @param Angle The Angle of the Quad2f rendered
|
||||
* @param scale The Scale of the Quad2f rendered
|
||||
* @param color The Quad2f color
|
||||
* @param Blend Set the Blend Mode ( default BlendAlpha )
|
||||
* @param Blend Set the Blend Mode ( default BlendMode::Alpha() )
|
||||
* @param texSector The texture sector to render. You can render only a part of the texture. (
|
||||
* default render all the texture )
|
||||
*/
|
||||
void drawQuad( const Quad2f& Q, const Vector2f& Offset = Vector2f(), const Float& Angle = 0.0f,
|
||||
const Vector2f& scale = Vector2f::One, const Color& color = Color::White,
|
||||
const BlendMode& Blend = BlendAlpha,
|
||||
const BlendMode& Blend = BlendMode::Alpha(),
|
||||
const Rect& texSector = Rect( 0, 0, 0, 0 ) );
|
||||
|
||||
/** Render a quad on Screen
|
||||
@@ -260,7 +260,7 @@ class EE_API Texture : public DrawableResource, public Image, private NonCopyabl
|
||||
* @param Color1 The Left - Bottom vertex color
|
||||
* @param Color2 The Right - Bottom vertex color
|
||||
* @param Color3 The Right - Top vertex color
|
||||
* @param Blend Set the Blend Mode ( default BlendAlpha )
|
||||
* @param Blend Set the Blend Mode ( default BlendMode::Alpha() )
|
||||
* @param texSector The texture sector to render. You can render only a part of the texture. (
|
||||
* default render all the texture )
|
||||
*/
|
||||
@@ -269,7 +269,7 @@ class EE_API Texture : public DrawableResource, public Image, private NonCopyabl
|
||||
const Color& Color1 = Color( 255, 255, 255, 255 ),
|
||||
const Color& Color2 = Color( 255, 255, 255, 255 ),
|
||||
const Color& Color3 = Color( 255, 255, 255, 255 ),
|
||||
const BlendMode& Blend = BlendAlpha, Rect texSector = Rect( 0, 0, 0, 0 ) );
|
||||
const BlendMode& Blend = BlendMode::Alpha(), Rect texSector = Rect( 0, 0, 0, 0 ) );
|
||||
|
||||
Sizef getSize();
|
||||
|
||||
|
||||
@@ -92,19 +92,19 @@ class EE_API TextureRegion : public DrawableResource {
|
||||
|
||||
void draw( const Float& X, const Float& Y, const Color& color = Color::White,
|
||||
const Float& Angle = 0.f, const Vector2f& Scale = Vector2f::One,
|
||||
const BlendMode& Blend = BlendAlpha, const RenderMode& Effect = RENDER_NORMAL,
|
||||
const BlendMode& Blend = BlendMode::Alpha(), const RenderMode& Effect = RENDER_NORMAL,
|
||||
OriginPoint Center = OriginPoint( OriginPoint::OriginCenter ) );
|
||||
|
||||
void draw( const Float& X, const Float& Y, const Float& Angle, const Vector2f& Scale,
|
||||
const Color& Color0 = Color::White, const Color& Color1 = Color::White,
|
||||
const Color& Color2 = Color::White, const Color& Color3 = Color::White,
|
||||
const BlendMode& Blend = BlendAlpha, const RenderMode& Effect = RENDER_NORMAL,
|
||||
const BlendMode& Blend = BlendMode::Alpha(), const RenderMode& Effect = RENDER_NORMAL,
|
||||
OriginPoint Center = OriginPoint( OriginPoint::OriginCenter ) );
|
||||
|
||||
void draw( const Quad2f Q, const Vector2f& offset = Vector2f(), const Float& Angle = 0.f,
|
||||
const Vector2f& Scale = Vector2f::One, const Color& Color0 = Color::White,
|
||||
const Color& Color1 = Color::White, const Color& Color2 = Color::White,
|
||||
const Color& Color3 = Color::White, const BlendMode& Blend = BlendAlpha );
|
||||
const Color& Color3 = Color::White, const BlendMode& Blend = BlendMode::Alpha() );
|
||||
|
||||
virtual void draw();
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class EE_API GameObjectTextureRegionEx : public GameObjectTextureRegion {
|
||||
public:
|
||||
GameObjectTextureRegionEx( const Uint32& Flags, MapLayer* Layer,
|
||||
Graphics::TextureRegion* TextureRegion = NULL,
|
||||
const Vector2f& Pos = Vector2f(), BlendMode Blend = BlendAlpha,
|
||||
const Vector2f& Pos = Vector2f(), BlendMode Blend = BlendMode::Alpha(),
|
||||
RenderMode Render = RENDER_NORMAL, Float Angle = 0.f,
|
||||
Vector2f Scale = Vector2f::One, Color color = Color::White );
|
||||
|
||||
|
||||
24
premake4.lua
24
premake4.lua
@@ -317,6 +317,9 @@ function build_base_configuration( package_name )
|
||||
buildoptions{ "-Wall", "-std=gnu99" }
|
||||
end
|
||||
targetname ( package_name .. "-debug" )
|
||||
if os.is_real("emscripten") then
|
||||
buildoptions{ "-g3" }
|
||||
end
|
||||
|
||||
configuration "release"
|
||||
defines { "NDEBUG" }
|
||||
@@ -324,10 +327,13 @@ function build_base_configuration( package_name )
|
||||
if not is_vs() then
|
||||
buildoptions{ "-Wall", "-std=gnu99" }
|
||||
end
|
||||
if os.is_real("emscripten") then
|
||||
buildoptions{ "-O3" }
|
||||
end
|
||||
targetname ( package_name )
|
||||
|
||||
configuration "emscripten"
|
||||
buildoptions { "-O3 -s USE_SDL=2 -s PRECISE_F32=1 -s ENVIRONMENT=worker,web" }
|
||||
buildoptions { "-s USE_SDL=2" }
|
||||
if _OPTIONS["with-emscripten-pthreads"] then
|
||||
buildoptions { "-s USE_PTHREADS=1" }
|
||||
end
|
||||
@@ -347,6 +353,9 @@ function build_base_cpp_configuration( package_name )
|
||||
if not is_vs() then
|
||||
buildoptions{ "-Wall" }
|
||||
end
|
||||
if os.is_real("emscripten") then
|
||||
buildoptions{ "-g3" }
|
||||
end
|
||||
targetname ( package_name .. "-debug" )
|
||||
|
||||
configuration "release"
|
||||
@@ -355,10 +364,13 @@ function build_base_cpp_configuration( package_name )
|
||||
if not is_vs() then
|
||||
buildoptions{ "-Wall" }
|
||||
end
|
||||
if os.is_real("emscripten") then
|
||||
buildoptions{ "-O3" }
|
||||
end
|
||||
targetname ( package_name )
|
||||
|
||||
configuration "emscripten"
|
||||
buildoptions { "-O3 -s USE_SDL=2 -s PRECISE_F32=1 -s ENVIRONMENT=worker,web" }
|
||||
buildoptions { "-s USE_SDL=2" }
|
||||
if _OPTIONS["with-emscripten-pthreads"] then
|
||||
buildoptions { "-s USE_PTHREADS=1" }
|
||||
end
|
||||
@@ -494,6 +506,10 @@ function build_link_configuration( package_name, use_ee_icon )
|
||||
buildoptions{ "-Wall -Wno-long-long" }
|
||||
end
|
||||
|
||||
if os.is_real("emscripten") then
|
||||
linkoptions{ "--profiling --profiling-funcs -s DEMANGLE_SUPPORT=1" }
|
||||
end
|
||||
|
||||
fix_shared_lib_linking_path( package_name, "libeepp-debug" )
|
||||
|
||||
if not os.is_real("emscripten") then
|
||||
@@ -522,9 +538,9 @@ function build_link_configuration( package_name, use_ee_icon )
|
||||
add_cross_config_links()
|
||||
|
||||
configuration "emscripten"
|
||||
linkoptions { "-O3 -s TOTAL_MEMORY=67108864" }
|
||||
linkoptions { "-s TOTAL_MEMORY=67108864 -sALLOW_MEMORY_GROWTH" }
|
||||
linkoptions { "-s USE_SDL=2" }
|
||||
buildoptions { "-O3 -s USE_SDL=2 -s PRECISE_F32=1 -s ENVIRONMENT=worker,web" }
|
||||
buildoptions { "-s USE_SDL=2" }
|
||||
defines { "NO_POSIX_SPAWN" }
|
||||
|
||||
if _OPTIONS["with-emscripten-pthreads"] then
|
||||
|
||||
@@ -14,40 +14,12 @@ BatchRenderer* BatchRenderer::New( const unsigned int& Prealloc ) {
|
||||
return eeNew( BatchRenderer, ( Prealloc ) );
|
||||
}
|
||||
|
||||
BatchRenderer::BatchRenderer() :
|
||||
mVertex( NULL ),
|
||||
mVertexSize( 0 ),
|
||||
mTVertex( NULL ),
|
||||
mNumVertex( 0 ),
|
||||
mTexture( NULL ),
|
||||
mBlend( BlendAlpha ),
|
||||
mCurrentMode( PRIMITIVE_QUADS ),
|
||||
mRotation( 0.0f ),
|
||||
mScale( 1.0f, 1.0f ),
|
||||
mPosition( 0.0f, 0.0f ),
|
||||
mCenter( 0.0f, 0.0f ),
|
||||
mCoordinateType( Texture::CoordinateType::Normalized ),
|
||||
mForceRendering( false ),
|
||||
mForceBlendMode( true ) {
|
||||
BatchRenderer::BatchRenderer() {
|
||||
allocVertexs( 4096 );
|
||||
init();
|
||||
}
|
||||
|
||||
BatchRenderer::BatchRenderer( const unsigned int& Prealloc ) :
|
||||
mVertex( NULL ),
|
||||
mVertexSize( 0 ),
|
||||
mTVertex( NULL ),
|
||||
mNumVertex( 0 ),
|
||||
mTexture( NULL ),
|
||||
mBlend( BlendAlpha ),
|
||||
mCurrentMode( PRIMITIVE_QUADS ),
|
||||
mRotation( 0.0f ),
|
||||
mScale( 1.0f, 1.0f ),
|
||||
mPosition( 0.0f, 0.0f ),
|
||||
mCenter( 0.0f, 0.0f ),
|
||||
mCoordinateType( Texture::CoordinateType::Normalized ),
|
||||
mForceRendering( false ),
|
||||
mForceBlendMode( true ) {
|
||||
BatchRenderer::BatchRenderer( const unsigned int& Prealloc ) {
|
||||
allocVertexs( Prealloc );
|
||||
init();
|
||||
}
|
||||
@@ -84,11 +56,12 @@ void BatchRenderer::setTexture( const Texture* texture, Texture::CoordinateType
|
||||
mCoordinateType = coordinateType;
|
||||
}
|
||||
|
||||
void BatchRenderer::setBlendMode( const BlendMode& Blend ) {
|
||||
if ( Blend != mBlend )
|
||||
void BatchRenderer::setBlendMode( const BlendMode& blend ) {
|
||||
if ( blend != mBlend )
|
||||
flush();
|
||||
|
||||
mBlend = Blend;
|
||||
if ( mBlend != blend )
|
||||
mBlend = blend;
|
||||
}
|
||||
|
||||
void BatchRenderer::addVertexs( const unsigned int& num ) {
|
||||
|
||||
@@ -7,25 +7,25 @@ namespace EE { namespace Graphics {
|
||||
|
||||
Uint32 factorToGlConstant( BlendMode::Factor blendFactor ) {
|
||||
switch ( blendFactor ) {
|
||||
case BlendMode::Zero:
|
||||
case BlendMode::Factor::Zero:
|
||||
return GL_ZERO;
|
||||
case BlendMode::One:
|
||||
case BlendMode::Factor::One:
|
||||
return GL_ONE;
|
||||
case BlendMode::SrcColor:
|
||||
case BlendMode::Factor::SrcColor:
|
||||
return GL_SRC_COLOR;
|
||||
case BlendMode::OneMinusSrcColor:
|
||||
case BlendMode::Factor::OneMinusSrcColor:
|
||||
return GL_ONE_MINUS_SRC_COLOR;
|
||||
case BlendMode::DstColor:
|
||||
case BlendMode::Factor::DstColor:
|
||||
return GL_DST_COLOR;
|
||||
case BlendMode::OneMinusDstColor:
|
||||
case BlendMode::Factor::OneMinusDstColor:
|
||||
return GL_ONE_MINUS_DST_COLOR;
|
||||
case BlendMode::SrcAlpha:
|
||||
case BlendMode::Factor::SrcAlpha:
|
||||
return GL_SRC_ALPHA;
|
||||
case BlendMode::OneMinusSrcAlpha:
|
||||
case BlendMode::Factor::OneMinusSrcAlpha:
|
||||
return GL_ONE_MINUS_SRC_ALPHA;
|
||||
case BlendMode::DstAlpha:
|
||||
case BlendMode::Factor::DstAlpha:
|
||||
return GL_DST_ALPHA;
|
||||
case BlendMode::OneMinusDstAlpha:
|
||||
case BlendMode::Factor::OneMinusDstAlpha:
|
||||
return GL_ONE_MINUS_DST_ALPHA;
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ Uint32 factorToGlConstant( BlendMode::Factor blendFactor ) {
|
||||
|
||||
Uint32 equationToGlConstant( BlendMode::Equation blendEquation ) {
|
||||
switch ( blendEquation ) {
|
||||
case BlendMode::Add:
|
||||
case BlendMode::Equation::Add:
|
||||
return GL_FUNC_ADD;
|
||||
case BlendMode::Subtract:
|
||||
case BlendMode::Equation::Subtract:
|
||||
return GL_FUNC_SUBTRACT;
|
||||
case BlendMode::ReverseSubtract:
|
||||
case BlendMode::Equation::ReverseSubtract:
|
||||
return GL_FUNC_REVERSE_SUBTRACT;
|
||||
}
|
||||
|
||||
@@ -49,22 +49,80 @@ Uint32 equationToGlConstant( BlendMode::Equation blendEquation ) {
|
||||
return GL_FUNC_ADD;
|
||||
}
|
||||
|
||||
const BlendMode BlendAlpha( BlendMode::SrcAlpha, BlendMode::OneMinusSrcAlpha, BlendMode::Add,
|
||||
BlendMode::One, BlendMode::OneMinusSrcAlpha, BlendMode::Add );
|
||||
const BlendMode BlendAdd( BlendMode::SrcAlpha, BlendMode::One, BlendMode::Add, BlendMode::One,
|
||||
BlendMode::One, BlendMode::Add );
|
||||
const BlendMode BlendMultiply( BlendMode::DstColor, BlendMode::Zero );
|
||||
const BlendMode BlendNone( BlendMode::One, BlendMode::Zero );
|
||||
BlendMode BlendMode::Alpha() {
|
||||
static const BlendMode BlendAlpha{ BlendMode::Factor::SrcAlpha,
|
||||
BlendMode::Factor::OneMinusSrcAlpha,
|
||||
BlendMode::Equation::Add,
|
||||
BlendMode::Factor::One,
|
||||
BlendMode::Factor::OneMinusSrcAlpha,
|
||||
BlendMode::Equation::Add };
|
||||
return BlendAlpha;
|
||||
}
|
||||
|
||||
BlendMode BlendMode::sLastBlend = BlendAlpha;
|
||||
BlendMode BlendMode::Add() {
|
||||
static const BlendMode BlendAdd{ BlendMode::Factor::SrcAlpha, BlendMode::Factor::One,
|
||||
BlendMode::Equation::Add, BlendMode::Factor::One,
|
||||
BlendMode::Factor::One, BlendMode::Equation::Add };
|
||||
return BlendAdd;
|
||||
}
|
||||
|
||||
BlendMode BlendMode::Multiply() {
|
||||
static const BlendMode BlendMultiply{ BlendMode::Factor::DstColor, BlendMode::Factor::Zero };
|
||||
return BlendMultiply;
|
||||
}
|
||||
|
||||
BlendMode BlendMode::None() {
|
||||
static const BlendMode BlendNone{ BlendMode::Factor::One, BlendMode::Factor::Zero };
|
||||
return BlendNone;
|
||||
}
|
||||
|
||||
BlendMode BlendMode::sLastBlend = BlendMode::Add();
|
||||
|
||||
std::string BlendMode::equationToString( const Equation& eq ) {
|
||||
switch ( eq ) {
|
||||
case BlendMode::Equation::Add:
|
||||
return "Add";
|
||||
case BlendMode::Equation::Subtract:
|
||||
return "Substract";
|
||||
case BlendMode::Equation::ReverseSubtract:
|
||||
return "ReverseSubtract";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string BlendMode::factorToString( const Factor& fc ) {
|
||||
switch ( fc ) {
|
||||
case BlendMode::Factor::Zero:
|
||||
return "Zero";
|
||||
case BlendMode::Factor::One:
|
||||
return "One";
|
||||
case BlendMode::Factor::SrcColor:
|
||||
return "SrcColor";
|
||||
case BlendMode::Factor::OneMinusSrcColor:
|
||||
return "OneMinusSrcColor";
|
||||
case BlendMode::Factor::DstColor:
|
||||
return "DstColor";
|
||||
case BlendMode::Factor::OneMinusDstColor:
|
||||
return "OneMinusDstColor";
|
||||
case BlendMode::Factor::SrcAlpha:
|
||||
return "SrcAlpha";
|
||||
case BlendMode::Factor::OneMinusSrcAlpha:
|
||||
return "OneMinusSrcAlpha";
|
||||
case BlendMode::Factor::DstAlpha:
|
||||
return "DstAlpha";
|
||||
case BlendMode::Factor::OneMinusDstAlpha:
|
||||
return "OneMinusDstAlpha";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
BlendMode::BlendMode() :
|
||||
colorSrcFactor( BlendMode::SrcAlpha ),
|
||||
colorDstFactor( BlendMode::OneMinusSrcAlpha ),
|
||||
colorEquation( BlendMode::Add ),
|
||||
alphaSrcFactor( BlendMode::One ),
|
||||
alphaDstFactor( BlendMode::OneMinusSrcAlpha ),
|
||||
alphaEquation( BlendMode::Add ) {}
|
||||
colorSrcFactor( BlendMode::Factor::SrcAlpha ),
|
||||
colorDstFactor( BlendMode::Factor::OneMinusSrcAlpha ),
|
||||
colorEquation( BlendMode::Equation::Add ),
|
||||
alphaSrcFactor( BlendMode::Factor::One ),
|
||||
alphaDstFactor( BlendMode::Factor::OneMinusSrcAlpha ),
|
||||
alphaEquation( BlendMode::Equation::Add ) {}
|
||||
|
||||
BlendMode::BlendMode( Factor sourceFactor, Factor destinationFactor, Equation blendEquation ) :
|
||||
colorSrcFactor( sourceFactor ),
|
||||
@@ -125,4 +183,10 @@ BlendMode BlendMode::getPreBlendFunc() {
|
||||
return sLastBlend;
|
||||
}
|
||||
|
||||
std::string BlendMode::toString() const {
|
||||
return factorToString( colorSrcFactor ) + " " + factorToString( colorDstFactor ) + " " +
|
||||
equationToString( colorEquation ) + " " + factorToString( alphaSrcFactor ) + " " +
|
||||
factorToString( alphaDstFactor ) + " " + equationToString( alphaEquation );
|
||||
}
|
||||
|
||||
}} // namespace EE::Graphics
|
||||
|
||||
@@ -31,7 +31,7 @@ void GlyphDrawable::draw( const Vector2f& position, const Sizef& size ) {
|
||||
|
||||
BatchRenderer* BR = GlobalBatchRenderer::instance();
|
||||
BR->setTexture( mTexture, mTexture->getCoordinateType() );
|
||||
BR->setBlendMode( BlendAlpha );
|
||||
BR->setBlendMode( BlendMode::Alpha() );
|
||||
BR->quadsBegin();
|
||||
BR->quadsSetColor( mColor );
|
||||
BR->quadsSetTexCoord( mSrcRect.Left, mSrcRect.Top, mSrcRect.Left + mSrcRect.Right,
|
||||
|
||||
@@ -18,7 +18,7 @@ ParticleSystem::ParticleSystem() :
|
||||
mPLeft( 0 ),
|
||||
mLoops( 0 ),
|
||||
mEffect( ParticleEffect::Nofx ),
|
||||
mBlend( BlendAdd ),
|
||||
mBlend( BlendMode::Add() ),
|
||||
mColor(),
|
||||
mProgression( 0 ),
|
||||
mDirection( 0 ),
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace EE { namespace Graphics {
|
||||
PrimitiveDrawable::PrimitiveDrawable( Type drawableType ) :
|
||||
Drawable( drawableType ),
|
||||
mFillMode( DRAW_FILL ),
|
||||
mBlendMode( BlendAlpha ),
|
||||
mBlendMode( BlendMode::Alpha() ),
|
||||
mLineWidth( 1.f ),
|
||||
mNeedsUpdate( true ),
|
||||
mRecreateVertexBuffer( true ),
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace EE { namespace Graphics {
|
||||
static GlobalBatchRenderer* sBR = NULL;
|
||||
|
||||
Primitives::Primitives() :
|
||||
mFillMode( DRAW_FILL ), mBlendMode( BlendAlpha ), mLineWidth( 1.f ), mForceDraw( true ) {
|
||||
mFillMode( DRAW_FILL ), mBlendMode( BlendMode::Alpha() ), mLineWidth( 1.f ), mForceDraw( true ) {
|
||||
if ( NULL == sBR ) {
|
||||
sBR = GlobalBatchRenderer::instance();
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ Renderer* Renderer::createSingleton( GraphicsLibraryVersion ver ) {
|
||||
if ( GLv_default == ver )
|
||||
#ifndef EE_GLES1_DEFAULT
|
||||
#ifdef EE_GLES2
|
||||
ver = GLv_3CP;
|
||||
ver = GLv_ES2;
|
||||
#else
|
||||
ver = GLv_ES1;
|
||||
#endif
|
||||
|
||||
@@ -7,18 +7,18 @@
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
const char* EEGLES2_STATES_NAME[] = {"dgl_Vertex", "dgl_Normal", "dgl_FrontColor"};
|
||||
const char* EEGLES2_STATES_NAME[] = { "dgl_Vertex", "dgl_Normal", "dgl_FrontColor" };
|
||||
|
||||
const char* EEGLES2_TEXTUREUNIT_NAMES[] = {"dgl_MultiTexCoord0", "dgl_MultiTexCoord1",
|
||||
"dgl_MultiTexCoord2", "dgl_MultiTexCoord3"};
|
||||
const char* EEGLES2_TEXTUREUNIT_NAMES[] = { "dgl_MultiTexCoord0", "dgl_MultiTexCoord1",
|
||||
"dgl_MultiTexCoord2", "dgl_MultiTexCoord3" };
|
||||
|
||||
const char* EEGLES2_PLANES_ENABLED_NAME[] = {"dgl_ClipEnabled[0]", "dgl_ClipEnabled[1]",
|
||||
"dgl_ClipEnabled[2]", "dgl_ClipEnabled[3]",
|
||||
"dgl_ClipEnabled[4]", "dgl_ClipEnabled[5]"};
|
||||
const char* EEGLES2_PLANES_ENABLED_NAME[] = { "dgl_ClipEnabled[0]", "dgl_ClipEnabled[1]",
|
||||
"dgl_ClipEnabled[2]", "dgl_ClipEnabled[3]",
|
||||
"dgl_ClipEnabled[4]", "dgl_ClipEnabled[5]" };
|
||||
|
||||
const char* EEGLES2_PLANES_NAMENABLED_NAME[] = {"dgl_ClipPlane[0]", "dgl_ClipPlane[1]",
|
||||
"dgl_ClipPlane[2]", "dgl_ClipPlane[3]",
|
||||
"dgl_ClipPlane[4]", "dgl_ClipPlane[5]"};
|
||||
const char* EEGLES2_PLANES_NAMENABLED_NAME[] = { "dgl_ClipPlane[0]", "dgl_ClipPlane[1]",
|
||||
"dgl_ClipPlane[2]", "dgl_ClipPlane[3]",
|
||||
"dgl_ClipPlane[4]", "dgl_ClipPlane[5]" };
|
||||
|
||||
#ifdef EE_GLES2
|
||||
const GLchar* GLES2_SHADER_HEAD = "precision mediump float;\nprecision lowp int;\n";
|
||||
@@ -51,6 +51,9 @@ RendererGLES2::RendererGLES2() :
|
||||
mCurShaderLocal( true ) {
|
||||
mQuadsSupported = false;
|
||||
mQuadVertexs = 6;
|
||||
#if !defined( EE_GLES2 )
|
||||
Renderer::enable( GL_VERTEX_PROGRAM_POINT_SIZE );
|
||||
#endif
|
||||
}
|
||||
|
||||
RendererGLES2::~RendererGLES2() {}
|
||||
@@ -189,11 +192,15 @@ void RendererGLES2::setShader( ShaderProgram* Shader ) {
|
||||
|
||||
checkLocalShader();
|
||||
|
||||
if ( !mCurShader )
|
||||
return;
|
||||
|
||||
mProjectionMatrix_id = mCurShader->getUniformLocation( "dgl_ProjectionMatrix" );
|
||||
mModelViewMatrix_id = mCurShader->getUniformLocation( "dgl_ModelViewMatrix" );
|
||||
mTextureMatrix_id = mCurShader->getUniformLocation( "dgl_TextureMatrix" );
|
||||
mTexActiveLoc = mCurShader->getUniformLocation( "dgl_TexActive" );
|
||||
mClippingEnabledLoc = mCurShader->getUniformLocation( "dgl_ClippingEnabled" );
|
||||
mPointSizeLoc = mCurShader->getUniformLocation( "dgl_PointSize" );
|
||||
mCurActiveTex = 0;
|
||||
|
||||
Uint32 i;
|
||||
@@ -243,6 +250,10 @@ void RendererGLES2::setShader( ShaderProgram* Shader ) {
|
||||
mCurShader->setUniform( mClippingEnabledLoc, 0 );
|
||||
}
|
||||
|
||||
if ( -1 != mPointSizeLoc ) {
|
||||
mCurShader->setUniform( mPointSizeLoc, mPointSize );
|
||||
}
|
||||
|
||||
for ( i = 0; i < EE_MAX_PLANES; i++ ) {
|
||||
if ( -1 != mPlanes[i] ) {
|
||||
mCurShader->setUniform( EEGLES2_PLANES_ENABLED_NAME[i], 0 );
|
||||
@@ -286,8 +297,6 @@ void RendererGLES2::enable( unsigned int cap ) {
|
||||
case GL_POINT_SPRITE: {
|
||||
mPointSpriteEnabled = 1;
|
||||
|
||||
// Renderer::Enable( GL_VERTEX_PROGRAM_POINT_SIZE );
|
||||
|
||||
setShader( EEGLES2_SHADER_POINTSPRITE );
|
||||
|
||||
return;
|
||||
@@ -304,6 +313,7 @@ void RendererGLES2::disable( unsigned int cap ) {
|
||||
mTexActive = 0;
|
||||
|
||||
if ( !mClippingEnabled ) {
|
||||
disableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
setShader( EEGLES2_SHADER_PRIMITIVE );
|
||||
} else if ( -1 != mTexActiveLoc ) {
|
||||
mCurShader->setUniform( mTexActiveLoc, mTexActive );
|
||||
@@ -335,8 +345,6 @@ void RendererGLES2::disable( unsigned int cap ) {
|
||||
case GL_POINT_SPRITE: {
|
||||
mPointSpriteEnabled = 0;
|
||||
|
||||
// Renderer::Disable( GL_VERTEX_PROGRAM_POINT_SIZE );
|
||||
|
||||
setShader( EEGLES2_SHADER_BASE );
|
||||
|
||||
return;
|
||||
@@ -387,7 +395,7 @@ void RendererGLES2::disableClientState( unsigned int array ) {
|
||||
}
|
||||
|
||||
void RendererGLES2::vertexPointer( int size, unsigned int type, int stride, const void* pointer,
|
||||
unsigned int allocate ) {
|
||||
unsigned int /*allocate*/ ) {
|
||||
const int index = mAttribsLoc[EEGL_VERTEX_ARRAY];
|
||||
|
||||
if ( -1 != index ) {
|
||||
@@ -402,7 +410,7 @@ void RendererGLES2::vertexPointer( int size, unsigned int type, int stride, cons
|
||||
}
|
||||
|
||||
void RendererGLES2::colorPointer( int size, unsigned int type, int stride, const void* pointer,
|
||||
unsigned int allocate ) {
|
||||
unsigned int /*allocate*/ ) {
|
||||
const int index = mAttribsLoc[EEGL_COLOR_ARRAY];
|
||||
|
||||
if ( -1 != index ) {
|
||||
@@ -421,7 +429,7 @@ void RendererGLES2::colorPointer( int size, unsigned int type, int stride, const
|
||||
}
|
||||
|
||||
void RendererGLES2::texCoordPointer( int size, unsigned int type, int stride, const void* pointer,
|
||||
unsigned int allocate ) {
|
||||
unsigned int /*allocate*/ ) {
|
||||
if ( mCurShaderLocal ) {
|
||||
if ( 1 == mTexActive ) {
|
||||
if ( mCurShader == mShaders[EEGLES2_SHADER_PRIMITIVE] ) {
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
const GLchar * EEGLES2_SHADER_PRIMITIVE_VS = R"(
|
||||
uniform mat4 dgl_ProjectionMatrix;
|
||||
uniform mat4 dgl_ModelViewMatrix;
|
||||
uniform float dgl_PointSize;
|
||||
attribute vec4 dgl_Vertex;
|
||||
attribute vec4 dgl_FrontColor;
|
||||
varying vec4 dgl_Color;
|
||||
void main(void)
|
||||
{
|
||||
gl_PointSize = dgl_PointSize;
|
||||
dgl_Color = dgl_FrontColor;
|
||||
gl_Position = dgl_ProjectionMatrix * ( dgl_ModelViewMatrix * dgl_Vertex );
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
ScrollParallax::ScrollParallax() :
|
||||
mTextureRegion( NULL ), mBlend( BlendAlpha ), mColor( 255, 255, 255, 255 ) {}
|
||||
mTextureRegion( NULL ), mBlend( BlendMode::Alpha() ), mColor( 255, 255, 255, 255 ) {}
|
||||
|
||||
ScrollParallax::~ScrollParallax() {}
|
||||
|
||||
|
||||
@@ -28,79 +28,21 @@ Sprite* Sprite::New( const Uint32& TexId, const Sizef& DestSize, const Vector2i&
|
||||
return eeNew( Sprite, ( TexId, DestSize, offset, TexSector ) );
|
||||
}
|
||||
|
||||
Sprite::Sprite() :
|
||||
Drawable( Drawable::SPRITE ),
|
||||
mFlags( SPRITE_FLAG_AUTO_ANIM | SPRITE_FLAG_EVENTS_ENABLED ),
|
||||
mRotation( 0.f ),
|
||||
mScale( 1.f, 1.f ),
|
||||
mAnimSpeed( 16.f ),
|
||||
mVertexColors( NULL ),
|
||||
mRepetitions( -1 ),
|
||||
mBlend( BlendAlpha ),
|
||||
mEffect( RENDER_NORMAL ),
|
||||
mCurrentFrame( 0 ),
|
||||
mfCurrentFrame( 0.f ),
|
||||
mCurrentSubFrame( 0 ),
|
||||
mSubFrames( 1 ),
|
||||
mAnimTo( 0 ),
|
||||
mUserData( NULL ) {}
|
||||
Sprite::Sprite() : Drawable( Drawable::SPRITE ) {}
|
||||
|
||||
Sprite::Sprite( const std::string& name, const std::string& extension,
|
||||
TextureAtlas* SearchInTextureAtlas ) :
|
||||
Drawable( Drawable::SPRITE ),
|
||||
mFlags( SPRITE_FLAG_AUTO_ANIM | SPRITE_FLAG_EVENTS_ENABLED ),
|
||||
mRotation( 0.f ),
|
||||
mScale( 1.f, 1.f ),
|
||||
mAnimSpeed( 16.f ),
|
||||
mVertexColors( NULL ),
|
||||
mRepetitions( -1 ),
|
||||
mBlend( BlendAlpha ),
|
||||
mEffect( RENDER_NORMAL ),
|
||||
mCurrentFrame( 0 ),
|
||||
mfCurrentFrame( 0.f ),
|
||||
mCurrentSubFrame( 0 ),
|
||||
mSubFrames( 1 ),
|
||||
mAnimTo( 0 ),
|
||||
mUserData( NULL ) {
|
||||
Drawable( Drawable::SPRITE ) {
|
||||
addFramesByPattern( name, extension, SearchInTextureAtlas );
|
||||
}
|
||||
|
||||
Sprite::Sprite( TextureRegion* TextureRegion ) :
|
||||
Drawable( Drawable::SPRITE ),
|
||||
mFlags( SPRITE_FLAG_AUTO_ANIM | SPRITE_FLAG_EVENTS_ENABLED ),
|
||||
mRotation( 0.f ),
|
||||
mScale( 1.f, 1.f ),
|
||||
mAnimSpeed( 16.f ),
|
||||
mVertexColors( NULL ),
|
||||
mRepetitions( -1 ),
|
||||
mBlend( BlendAlpha ),
|
||||
mEffect( RENDER_NORMAL ),
|
||||
mCurrentFrame( 0 ),
|
||||
mfCurrentFrame( 0.f ),
|
||||
mCurrentSubFrame( 0 ),
|
||||
mSubFrames( 1 ),
|
||||
mAnimTo( 0 ),
|
||||
mUserData( NULL ) {
|
||||
Sprite::Sprite( TextureRegion* TextureRegion ) : Drawable( Drawable::SPRITE ) {
|
||||
createStatic( TextureRegion );
|
||||
}
|
||||
|
||||
Sprite::Sprite( const Uint32& TexId, const Sizef& DestSize, const Vector2i& Offset,
|
||||
const Rect& TexSector ) :
|
||||
Drawable( Drawable::SPRITE ),
|
||||
mFlags( SPRITE_FLAG_AUTO_ANIM | SPRITE_FLAG_EVENTS_ENABLED ),
|
||||
mRotation( 0.f ),
|
||||
mScale( 1.f, 1.f ),
|
||||
mAnimSpeed( 16.f ),
|
||||
mVertexColors( NULL ),
|
||||
mRepetitions( -1 ),
|
||||
mBlend( BlendAlpha ),
|
||||
mEffect( RENDER_NORMAL ),
|
||||
mCurrentFrame( 0 ),
|
||||
mfCurrentFrame( 0.f ),
|
||||
mCurrentSubFrame( 0 ),
|
||||
mSubFrames( 1 ),
|
||||
mAnimTo( 0 ),
|
||||
mUserData( NULL ) {
|
||||
Drawable( Drawable::SPRITE ) {
|
||||
createStatic( TexId, DestSize, Offset, TexSector );
|
||||
}
|
||||
|
||||
@@ -194,7 +136,7 @@ void Sprite::reset() {
|
||||
mRotation = 0;
|
||||
mColor = Color::White;
|
||||
|
||||
mBlend = BlendAlpha;
|
||||
mBlend = BlendMode::Alpha();
|
||||
mEffect = RENDER_NORMAL;
|
||||
|
||||
mCurrentFrame = 0;
|
||||
|
||||
@@ -942,7 +942,7 @@ void Texture::draw( const Vector2f& position ) {
|
||||
}
|
||||
|
||||
void Texture::draw( const Vector2f& position, const Sizef& size ) {
|
||||
drawFast( position.x, position.y, 0, Vector2f::One, mColor, BlendAlpha, size.x, size.y );
|
||||
drawFast( position.x, position.y, 0, Vector2f::One, mColor, BlendMode::Alpha(), size.x, size.y );
|
||||
}
|
||||
|
||||
}} // namespace EE::Graphics
|
||||
|
||||
@@ -122,7 +122,8 @@ RenderMode GameObject::getRenderModeFromFlags() {
|
||||
}
|
||||
|
||||
BlendMode GameObject::getBlendModeFromFlags() {
|
||||
return isBlendAdd() ? BlendMode( BlendMode::DstColor, BlendMode::One ) : BlendAlpha;
|
||||
return isBlendAdd() ? BlendMode( BlendMode::Factor::DstColor, BlendMode::Factor::One )
|
||||
: BlendMode::Alpha();
|
||||
}
|
||||
|
||||
MapLayer* GameObject::getLayer() const {
|
||||
|
||||
@@ -44,7 +44,7 @@ void GameObjectTextureRegion::draw() {
|
||||
getRenderModeFromFlags() );
|
||||
} else {
|
||||
mTextureRegion->draw( mPos.x, mPos.y, *LM->getTileColor( Tile ), getRotation(),
|
||||
Vector2f::One, BlendAlpha, getRenderModeFromFlags() );
|
||||
Vector2f::One, BlendMode::Alpha(), getRenderModeFromFlags() );
|
||||
}
|
||||
} else {
|
||||
if ( LM->isByVertex() ) {
|
||||
|
||||
@@ -88,7 +88,7 @@ void GameObjectVirtual::draw() {
|
||||
} else {
|
||||
mTextureRegion->draw(
|
||||
mPos.x, mPos.y, LM->getColorFromPos( Vector2f( mPos.x, mPos.y ) ),
|
||||
getRotation(), Vector2f::One, BlendAlpha, getRenderModeFromFlags() );
|
||||
getRotation(), Vector2f::One, BlendMode::Alpha(), getRenderModeFromFlags() );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -44,8 +44,6 @@ void ShapePoint::draw( Space* space ) {
|
||||
#ifdef PHYSICS_RENDERER_ENABLED
|
||||
BatchRenderer* BR = GlobalBatchRenderer::instance();
|
||||
|
||||
BR->setPointSize( mDrawRadius );
|
||||
|
||||
BR->setTexture( NULL );
|
||||
BR->pointsBegin();
|
||||
BR->pointSetColor( colorForShape( mShape, space->getSpace() ) );
|
||||
@@ -53,6 +51,7 @@ void ShapePoint::draw( Space* space ) {
|
||||
cpCircleShape* cs = (cpCircleShape*)mShape;
|
||||
|
||||
BR->batchPoint( cs->CP_PRIVATE( tc ).x, cs->CP_PRIVATE( tc ).y );
|
||||
BR->setPointSize( mDrawRadius );
|
||||
|
||||
BR->drawOpt();
|
||||
#endif
|
||||
|
||||
@@ -288,7 +288,7 @@ void Space::draw() {
|
||||
#ifdef PHYSICS_RENDERER_ENABLED
|
||||
|
||||
BatchRenderer* BR = GlobalBatchRenderer::instance();
|
||||
BR->setBlendMode( BlendAlpha );
|
||||
BR->setBlendMode( BlendMode::Alpha() );
|
||||
|
||||
PhysicsManager::DrawSpaceOptions* options = PhysicsManager::instance()->getDrawOptions();
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ Node::Node() :
|
||||
mNext( NULL ),
|
||||
mPrev( NULL ),
|
||||
mNodeFlags( NODE_FLAG_POSITION_DIRTY | NODE_FLAG_POLYGON_DIRTY ),
|
||||
mBlend( BlendAlpha ),
|
||||
mBlend( BlendMode::Alpha() ),
|
||||
mNumCallBacks( 0 ),
|
||||
mVisible( true ),
|
||||
mEnabled( true ),
|
||||
|
||||
@@ -343,13 +343,13 @@ static BlendMode toBlendMode( std::string val ) {
|
||||
BlendMode blendMode;
|
||||
|
||||
if ( val == "add" )
|
||||
blendMode = BlendAdd;
|
||||
blendMode = BlendMode::Add();
|
||||
else if ( val == "alpha" )
|
||||
blendMode = BlendAlpha;
|
||||
blendMode = BlendMode::Alpha();
|
||||
else if ( val == "multiply" )
|
||||
blendMode = BlendMultiply;
|
||||
blendMode = BlendMode::Multiply();
|
||||
else if ( val == "none" )
|
||||
blendMode = BlendNone;
|
||||
blendMode = BlendMode::None();
|
||||
|
||||
return blendMode;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ void Window::setup2D( const bool& KeepView ) {
|
||||
setView( mDefaultView, true );
|
||||
}
|
||||
|
||||
BlendMode::setMode( BlendAlpha, true );
|
||||
BlendMode::setMode( BlendMode::Alpha(), true );
|
||||
|
||||
if ( GLv_3CP != GLi->version() && GLv_3 != GLi->version() && GLv_ES2 != GLi->version() ) {
|
||||
#if !defined( EE_GLES2 ) || defined( EE_GLES_BOTH )
|
||||
|
||||
@@ -21,7 +21,7 @@ Vector3ff* vertices = eeNewArray( Vector3ff, ParticlesNum );
|
||||
Vector3ff* velocities = eeNewArray( Vector3ff, ParticlesNum );
|
||||
ColorAf* colors = eeNewArray( ColorAf, ParticlesNum );
|
||||
|
||||
void videoResize( EE::Window::Window* w ) {
|
||||
void videoResize( EE::Window::Window* ) {
|
||||
/// Video Resize event will re-setup the 2D projection and states, so we must rebuild them.
|
||||
aspectRatio = (Float)win->getWidth() / (Float)win->getHeight();
|
||||
tw = (Float)win->getWidth() / 2;
|
||||
@@ -57,8 +57,8 @@ void videoResize( EE::Window::Window* w ) {
|
||||
GLi->enableClientState( GL_VERTEX_ARRAY );
|
||||
GLi->enableClientState( GL_COLOR_ARRAY );
|
||||
|
||||
/// Reset the default blend func ( by default eepp use BlendAlpha )
|
||||
BlendMode::setMode( BlendAdd );
|
||||
/// Reset the default blend func ( by default eepp use BlendMode::Alpha() )
|
||||
BlendMode::setMode( BlendMode::Add() );
|
||||
|
||||
/// Set the line width
|
||||
GLi->lineWidth( 2 );
|
||||
|
||||
@@ -102,7 +102,7 @@ static const char image_bitmap[] = {
|
||||
127, -1, -29, -4, 127, -64, 15, -8, 0, 0, 55, -1, -1, -121, -8, 127, -97,
|
||||
-25, -8, 0, 63, -61, -61, -4, 127, -1, -29, -4, 63, -64, 15, -32, 0, 0,
|
||||
23, -1, -2, 3, -16, 63, 15, -61, -16, 0, 31, -127, -127, -8, 31, -1, -127,
|
||||
-8, 31, -128, 7, -128, 0, 0};
|
||||
-8, 31, -128, 7, -128, 0, 0 };
|
||||
|
||||
int get_pixel( int x, int y ) {
|
||||
return ( image_bitmap[( x >> 3 ) + y * image_row_length] >> ( ~x & 0x7 ) ) & 1;
|
||||
@@ -260,7 +260,7 @@ struct Emitter {
|
||||
};
|
||||
Emitter emitterInstance;
|
||||
|
||||
cpBool blockerBegin( Arbiter* arb, Space* space, void* unused ) {
|
||||
cpBool blockerBegin( Arbiter* arb, Space*, void* ) {
|
||||
Shape *a, *b;
|
||||
arb->getShapes( &a, &b );
|
||||
|
||||
@@ -271,7 +271,7 @@ cpBool blockerBegin( Arbiter* arb, Space* space, void* unused ) {
|
||||
return cpFalse; // Return values from sensors callbacks are ignored,
|
||||
}
|
||||
|
||||
void blockerSeparate( Arbiter* arb, Space* space, void* unused ) {
|
||||
void blockerSeparate( Arbiter* arb, Space*, void* ) {
|
||||
Shape *a, *b;
|
||||
arb->getShapes( &a, &b );
|
||||
|
||||
@@ -280,7 +280,7 @@ void blockerSeparate( Arbiter* arb, Space* space, void* unused ) {
|
||||
emitter->blocked--;
|
||||
}
|
||||
|
||||
void postStepRemove( Space* space, void* tshape, void* unused ) {
|
||||
void postStepRemove( Space* space, void* tshape, void* ) {
|
||||
Shape* shape = reinterpret_cast<Shape*>( tshape );
|
||||
|
||||
if ( NULL != mMouseJoint &&
|
||||
@@ -295,7 +295,7 @@ void postStepRemove( Space* space, void* tshape, void* unused ) {
|
||||
Shape::Free( shape, true );
|
||||
}
|
||||
|
||||
cpBool catcherBarBegin( Arbiter* arb, Space* space, void* unused ) {
|
||||
cpBool catcherBarBegin( Arbiter* arb, Space* space, void* ) {
|
||||
Shape *a, *b;
|
||||
arb->getShapes( &a, &b );
|
||||
|
||||
@@ -303,7 +303,7 @@ cpBool catcherBarBegin( Arbiter* arb, Space* space, void* unused ) {
|
||||
|
||||
emitter->queue++;
|
||||
|
||||
space->addPostStepCallback( cb::Make3( &postStepRemove ), b, NULL );
|
||||
space->addPostStepCallback( &postStepRemove, b, NULL );
|
||||
|
||||
return cpFalse;
|
||||
}
|
||||
@@ -343,15 +343,15 @@ void demo3Create() {
|
||||
Space::CollisionHandler handler;
|
||||
handler.a = BLOCKING_SENSOR_TYPE;
|
||||
handler.b = BALL_TYPE;
|
||||
handler.begin = cb::Make3( &blockerBegin );
|
||||
handler.separate = cb::Make3( &blockerSeparate );
|
||||
handler.begin = &blockerBegin;
|
||||
handler.separate = &blockerSeparate;
|
||||
mSpace->addCollisionHandler( handler );
|
||||
|
||||
handler.reset(); // Reset all the values and the callbacks ( set the callbacks as !IsSet()
|
||||
|
||||
handler.a = CATCH_SENSOR_TYPE;
|
||||
handler.b = BALL_TYPE;
|
||||
handler.begin = cb::Make3( &catcherBarBegin );
|
||||
handler.begin = &catcherBarBegin;
|
||||
mSpace->addCollisionHandler( handler );
|
||||
}
|
||||
|
||||
@@ -377,12 +377,12 @@ enum { COLLIDE_STICK_SENSOR = 1 };
|
||||
|
||||
#define STICK_SENSOR_THICKNESS 2.5f
|
||||
|
||||
void postStepAddJoint( Space* space, void* key, void* data ) {
|
||||
void postStepAddJoint( Space* space, void* key, void* ) {
|
||||
Constraint* joint = (Constraint*)key;
|
||||
space->addConstraint( joint );
|
||||
}
|
||||
|
||||
cpBool stickyPreSolve( Arbiter* arb, Space* space, void* data ) {
|
||||
cpBool stickyPreSolve( Arbiter* arb, Space* space, void* ) {
|
||||
// We want to fudge the collisions a bit to allow shapes to overlap more.
|
||||
// This simulates their squishy sticky surface, and more importantly
|
||||
// keeps them from separating and destroying the joint.
|
||||
@@ -424,7 +424,7 @@ cpBool stickyPreSolve( Arbiter* arb, Space* space, void* data ) {
|
||||
joint->setMaxForce( 3e3 );
|
||||
|
||||
// Schedule a post-step() callback to add the joint.
|
||||
space->addPostStepCallback( cb::Make3( &postStepAddJoint ), joint, NULL );
|
||||
space->addPostStepCallback( &postStepAddJoint, joint, NULL );
|
||||
|
||||
// Store the joint on the arbiter so we can remove it later.
|
||||
arb->setUserData( joint );
|
||||
@@ -443,13 +443,13 @@ cpBool stickyPreSolve( Arbiter* arb, Space* space, void* data ) {
|
||||
// pointer).
|
||||
}
|
||||
|
||||
void postStepRemoveJoint( Space* space, void* key, void* data ) {
|
||||
void postStepRemoveJoint( Space* space, void* key, void* ) {
|
||||
Constraint* joint = (Constraint*)key;
|
||||
space->removeConstraint( joint );
|
||||
Constraint::Free( joint );
|
||||
}
|
||||
|
||||
void stickySeparate( Arbiter* arb, Space* space, void* data ) {
|
||||
void stickySeparate( Arbiter* arb, Space* space, void* ) {
|
||||
Constraint* joint = (Constraint*)arb->getUserData();
|
||||
|
||||
if ( joint ) {
|
||||
@@ -459,7 +459,7 @@ void stickySeparate( Arbiter* arb, Space* space, void* data ) {
|
||||
joint->setMaxForce( 0.0f );
|
||||
|
||||
// Perform the removal in a post-step() callback.
|
||||
space->addPostStepCallback( cb::Make3( &postStepRemoveJoint ), joint, NULL );
|
||||
space->addPostStepCallback( &postStepRemoveJoint, joint, NULL );
|
||||
|
||||
// NULL out the reference to the joint.
|
||||
// Not required, but it's a good practice.
|
||||
@@ -538,8 +538,8 @@ void demo4Create() {
|
||||
Space::CollisionHandler c;
|
||||
c.a = COLLIDE_STICK_SENSOR;
|
||||
c.b = COLLIDE_STICK_SENSOR;
|
||||
c.preSolve = cb::Make3( &stickyPreSolve );
|
||||
c.separate = cb::Make3( &stickySeparate );
|
||||
c.preSolve = &stickyPreSolve;
|
||||
c.separate = &stickySeparate;
|
||||
|
||||
mSpace->addCollisionHandler( c );
|
||||
}
|
||||
@@ -570,24 +570,24 @@ void physicsCreate() {
|
||||
// Add the demos
|
||||
physicDemo demo;
|
||||
|
||||
demo.init = cb::Make0( &demo1Create );
|
||||
demo.update = cb::Make0( &demo1Update );
|
||||
demo.destroy = cb::Make0( &demo1Destroy );
|
||||
demo.init = &demo1Create;
|
||||
demo.update = &demo1Update;
|
||||
demo.destroy = &demo1Destroy;
|
||||
mDemo.push_back( demo );
|
||||
|
||||
demo.init = cb::Make0( &demo2Create );
|
||||
demo.update = cb::Make0( &demo2Update );
|
||||
demo.destroy = cb::Make0( &demo2Destroy );
|
||||
demo.init = &demo2Create;
|
||||
demo.update = &demo2Update;
|
||||
demo.destroy = &demo2Destroy;
|
||||
mDemo.push_back( demo );
|
||||
|
||||
demo.init = cb::Make0( &demo3Create );
|
||||
demo.update = cb::Make0( &demo3Update );
|
||||
demo.destroy = cb::Make0( &demo3Destroy );
|
||||
demo.init = &demo3Create;
|
||||
demo.update = &demo3Update;
|
||||
demo.destroy = &demo3Destroy;
|
||||
mDemo.push_back( demo );
|
||||
|
||||
demo.init = cb::Make0( &demo4Create );
|
||||
demo.update = cb::Make0( &demo4Update );
|
||||
demo.destroy = cb::Make0( &demo4Destroy );
|
||||
demo.init = &demo4Create;
|
||||
demo.update = &demo4Update;
|
||||
demo.destroy = &demo4Destroy;
|
||||
mDemo.push_back( demo );
|
||||
|
||||
ChangeDemo( 0 );
|
||||
@@ -649,9 +649,9 @@ void mainLoop() {
|
||||
mWindow->display();
|
||||
}
|
||||
|
||||
EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
||||
EE_MAIN_FUNC int main( int, char*[] ) {
|
||||
mWindow = Engine::instance()->createWindow( WindowSettings( 1024, 768, "eepp - Physics" ),
|
||||
ContextSettings( true ) );
|
||||
ContextSettings( true, EE::Graphics::GLv_ES2 ) );
|
||||
|
||||
if ( mWindow->isOpen() ) {
|
||||
KM = mWindow->getInput();
|
||||
|
||||
@@ -88,7 +88,7 @@ void mainLoop() {
|
||||
win->display();
|
||||
}
|
||||
|
||||
EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
||||
EE_MAIN_FUNC int main( int, char*[] ) {
|
||||
// Create a new window
|
||||
win = Engine::instance()->createWindow( WindowSettings( 640, 480, "eepp - Sprites" ),
|
||||
ContextSettings( true ) );
|
||||
@@ -135,7 +135,7 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
||||
Blindy.setRenderMode( RENDER_MIRROR );
|
||||
|
||||
// Set the Blend Mode of the sprite
|
||||
Blindy.setBlendMode( BlendAdd );
|
||||
Blindy.setBlendMode( BlendMode::Add() );
|
||||
|
||||
// Set the primitive fill mode
|
||||
P.setFillMode( DRAW_LINE );
|
||||
|
||||
@@ -110,7 +110,7 @@ void mainLoop() {
|
||||
win->display();
|
||||
}
|
||||
|
||||
EE_MAIN_FUNC int main( int argc, char* argv[] ) {
|
||||
EE_MAIN_FUNC int main( int, char*[] ) {
|
||||
// Create a new window
|
||||
win = Engine::instance()->createWindow(
|
||||
WindowSettings( 1024, 768, "eepp - VBO - FBO and Batch Rendering" ),
|
||||
|
||||
@@ -52,7 +52,6 @@ class UIBlurredWindow : public UIWindow {
|
||||
|
||||
mBlurShader->bind();
|
||||
|
||||
mBlurShader->setUniform( "radius", 16.f );
|
||||
mBlurShader->setUniform( "dir", (Int32)0 );
|
||||
mBlurShader->setUniform( "textureRes", mFboBlur->getSizef() );
|
||||
|
||||
@@ -186,7 +185,7 @@ void EETest::init() {
|
||||
WP.start();
|
||||
|
||||
Batch.allocVertexs( 2048 );
|
||||
Batch.setBlendMode( BlendAdd );
|
||||
Batch.setBlendMode( BlendMode::Add() );
|
||||
|
||||
mFBO = FrameBuffer::New( 256, 256 );
|
||||
|
||||
@@ -1602,13 +1601,13 @@ void EETest::screen2() {
|
||||
if ( mUseShaders )
|
||||
mShaderProgram->unbind();
|
||||
|
||||
TNP[3]->draw( HWidth - 128, HHeight, 0, Vector2f::One, Color( 255, 255, 255, 150 ), BlendAlpha,
|
||||
TNP[3]->draw( HWidth - 128, HHeight, 0, Vector2f::One, Color( 255, 255, 255, 150 ), BlendMode::Alpha(),
|
||||
RENDER_ISOMETRIC );
|
||||
TNP[3]->draw( HWidth - 128, HHeight - 128, 0, Vector2f::One, Color( 255, 255, 255, 50 ),
|
||||
BlendAlpha, RENDER_ISOMETRIC );
|
||||
TNP[3]->draw( HWidth - 128, HHeight, 0, Vector2f::One, Color( 255, 255, 255, 50 ), BlendAlpha,
|
||||
BlendMode::Alpha(), RENDER_ISOMETRIC );
|
||||
TNP[3]->draw( HWidth - 128, HHeight, 0, Vector2f::One, Color( 255, 255, 255, 50 ), BlendMode::Alpha(),
|
||||
RENDER_ISOMETRIC_VERTICAL );
|
||||
TNP[3]->draw( HWidth, HHeight, 0, Vector2f::One, Color( 255, 255, 255, 50 ), BlendAlpha,
|
||||
TNP[3]->draw( HWidth, HHeight, 0, Vector2f::One, Color( 255, 255, 255, 50 ), BlendMode::Alpha(),
|
||||
RENDER_ISOMETRIC_VERTICAL_NEGATIVE );
|
||||
|
||||
alpha = ( !aside ) ? alpha + et.asMilliseconds() * 0.1f : alpha - et.asMilliseconds() * 0.1f;
|
||||
@@ -1622,7 +1621,7 @@ void EETest::screen2() {
|
||||
|
||||
Color Col( 255, 255, 255, (int)alpha );
|
||||
TNP[1]->drawEx( (Float)mWindow->getWidth() - 128.f, (Float)mWindow->getHeight() - 128.f, 128.f,
|
||||
128.f, ang, Vector2f::One, Col, Col, Col, Col, BlendAdd,
|
||||
128.f, ang, Vector2f::One, Col, Col, Col, Col, BlendMode::Add(),
|
||||
RENDER_FLIPPED_MIRRORED );
|
||||
|
||||
SP.setPosition( Vector2f( alpha, alpha ) );
|
||||
@@ -2232,30 +2231,30 @@ void EETest::demo1Create() {
|
||||
mSpace->setGravity( cVectNew( 0, 100 ) );
|
||||
mSpace->setSleepTimeThreshold( 0.5f );
|
||||
|
||||
Body *body, *statiBody = mSpace->getStaticBody();
|
||||
Body *body, *staticBody = mSpace->getStaticBody();
|
||||
Shape* shape;
|
||||
|
||||
shape = mSpace->addShape(
|
||||
ShapeSegment::New( statiBody, cVectNew( 0, mWindow->getHeight() ),
|
||||
ShapeSegment::New( staticBody, cVectNew( 0, mWindow->getHeight() ),
|
||||
cVectNew( mWindow->getWidth(), mWindow->getHeight() ), 0.0f ) );
|
||||
shape->setE( 1.0f );
|
||||
shape->setU( 1.0f );
|
||||
shape->setLayers( NOT_GRABABLE_MASK );
|
||||
|
||||
shape = mSpace->addShape(
|
||||
ShapeSegment::New( statiBody, cVectNew( mWindow->getWidth(), 0 ),
|
||||
ShapeSegment::New( staticBody, cVectNew( mWindow->getWidth(), 0 ),
|
||||
cVectNew( mWindow->getWidth(), mWindow->getHeight() ), 0.0f ) );
|
||||
shape->setE( 1.0f );
|
||||
shape->setU( 1.0f );
|
||||
shape->setLayers( NOT_GRABABLE_MASK );
|
||||
|
||||
shape = mSpace->addShape( ShapeSegment::New( statiBody, cVectNew( 0, 0 ),
|
||||
shape = mSpace->addShape( ShapeSegment::New( staticBody, cVectNew( 0, 0 ),
|
||||
cVectNew( 0, mWindow->getHeight() ), 0.0f ) );
|
||||
shape->setE( 1.0f );
|
||||
shape->setU( 1.0f );
|
||||
shape->setLayers( NOT_GRABABLE_MASK );
|
||||
|
||||
shape = mSpace->addShape( ShapeSegment::New( statiBody, cVectNew( 0, 0 ),
|
||||
shape = mSpace->addShape( ShapeSegment::New( staticBody, cVectNew( 0, 0 ),
|
||||
cVectNew( mWindow->getWidth(), 0 ), 0.0f ) );
|
||||
shape->setE( 1.0f );
|
||||
shape->setU( 1.0f );
|
||||
|
||||
7
src/thirdparty/chipmunk/cpBBTree.c
vendored
7
src/thirdparty/chipmunk/cpBBTree.c
vendored
@@ -630,13 +630,18 @@ cpBBTreeContains(cpBBTree *tree, void *obj, cpHashValue hashid)
|
||||
|
||||
//MARK: Reindex
|
||||
|
||||
static void LeafUpdate2(void* elt, void* data)
|
||||
{
|
||||
LeafUpdate((Node*)elt, (cpBBTree*)data);
|
||||
}
|
||||
|
||||
static void
|
||||
cpBBTreeReindexQuery(cpBBTree *tree, cpSpatialIndexQueryFunc func, void *data)
|
||||
{
|
||||
if(!tree->root) return;
|
||||
|
||||
// LeafUpdate() may modify tree->root. Don't cache it.
|
||||
cpHashSetEach(tree->leaves, (cpHashSetIteratorFunc)LeafUpdate, tree);
|
||||
cpHashSetEach(tree->leaves, (cpHashSetIteratorFunc)LeafUpdate2, tree);
|
||||
|
||||
cpSpatialIndex *staticIndex = tree->spatialIndex.staticIndex;
|
||||
Node *staticRoot = (staticIndex && staticIndex->klass == Klass() ? ((cpBBTree *)staticIndex)->root : NULL);
|
||||
|
||||
7
src/thirdparty/chipmunk/cpSpace.c
vendored
7
src/thirdparty/chipmunk/cpSpace.c
vendored
@@ -141,10 +141,15 @@ cpSpaceNew(void)
|
||||
return cpSpaceInit(cpSpaceAlloc());
|
||||
}
|
||||
|
||||
void cpBodyActivate2(cpBody *body, void *data)
|
||||
{
|
||||
cpBodyActivate(body);
|
||||
}
|
||||
|
||||
void
|
||||
cpSpaceDestroy(cpSpace *space)
|
||||
{
|
||||
cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)cpBodyActivate, NULL);
|
||||
cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)cpBodyActivate2, NULL);
|
||||
|
||||
cpSpatialIndexFree(space->staticShapes);
|
||||
cpSpatialIndexFree(space->activeShapes);
|
||||
|
||||
Reference in New Issue
Block a user