Rev 787 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tao.OpenGl;
#pragma warning disable 0618
namespace BauzoidNET
.graphics.renderstates
{
public class ScissorStates
: RenderStatesObject
{
public class ScissorRect
{
public int x
;
public int y
;
public int width
;
public int height
;
public ScissorRect
(int _x,
int _y,
int _w,
int _h
)
{
x
= _x
;
y
= _y
;
width
= _w
;
height
= _h
;
}
}
private bool mEnabled
= false;
private ScissorRect mScissorRect
= null; // not set means full screen
private bool mCurrentlyEnabled
= false;
private bool mDefaultEnabled
= false;
public ScissorStates
(RenderStates renderStates
) : base(renderStates
)
{
}
public override void activate
(bool force
)
{
if ((force
) || (mEnabled
!= mCurrentlyEnabled
))
{
if (mEnabled
&& (mScissorRect
!= null))
{
mCurrentlyEnabled
= true;
Gl
.glEnable(Gl
.GL_SCISSOR_TEST);
Gl
.glScissor(mScissorRect
.x, mScissorRect
.y, mScissorRect
.width, mScissorRect
.height);
}
else
{
Gl
.glDisable(Gl
.GL_SCISSOR_TEST);
mCurrentlyEnabled
= false;
}
}
}
public override void reset
()
{
if ((mLocked
) || (mRenderStates
.isLocked()))
return;
mEnabled
= mDefaultEnabled
;
mScissorRect
= null;
}
/** Check enabled state. */
public bool isEnabled
()
{
return mEnabled
;
}
/** Check default enabled state. */
public bool isDefaultEnabled
()
{
return mDefaultEnabled
;
}
/** Set enabled state. */
public void setEnabled
(bool value
)
{
if ((mLocked
) || (mRenderStates
.isLocked()))
return;
mEnabled
= value
;
}
/** Set default enabled state. */
public void setDefaultEnabled
(bool value
)
{
if ((mLocked
) || (mRenderStates
.isLocked()))
return;
mDefaultEnabled
= value
;
}
/** Set a scissor rect. Note that Y is bottom up. */
public void setScissor
(int x,
int y,
int w,
int h
)
{
mScissorRect
= new ScissorRect
(x, y, w, h
);
}
}
}