本文整理汇总了C#中Loon.Core.Graphics.Opengl.LTexture.LoadTexture方法的典型用法代码示例。如果您正苦于以下问题:C# LTexture.LoadTexture方法的具体用法?C# LTexture.LoadTexture怎么用?C# LTexture.LoadTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loon.Core.Graphics.Opengl.LTexture
的用法示例。
在下文中一共展示了LTexture.LoadTexture方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSplit2Textures
public static LTexture[][] GetSplit2Textures(LTexture image, int width,
int height)
{
if (image == null)
{
return null;
}
if (!image.IsLoaded())
{
image.LoadTexture();
}
int wlength = image.GetWidth() / width;
int hlength = image.GetHeight() / height;
LTexture[][] textures = (LTexture[][])CollectionUtils.XNA_CreateJaggedArray(typeof(LTexture), wlength, hlength);
for (int y = 0; y < hlength; y++)
{
for (int x = 0; x < wlength; x++)
{
textures[x][y] = image.GetSubTexture((x * width), (y * height),
width, height);
}
}
return textures;
}
示例2: GetSplitTextures
public static LTexture[] GetSplitTextures(LTexture image, int width,
int height)
{
if (image == null)
{
return null;
}
if (!image.IsLoaded())
{
image.LoadTexture();
}
int frame = 0;
int wlength = image.GetWidth() / width;
int hlength = image.GetHeight() / height;
int total = wlength * hlength;
LTexture[] images = new LTexture[total];
for (int y = 0; y < hlength; y++)
{
for (int x = 0; x < wlength; x++)
{
images[frame] = image.GetSubTexture((x * width), (y * height),
width, height);
frame++;
}
}
return images;
}
示例3: DrawTexture
private void DrawTexture(LTexture texture, float x, float y,
float width, float height, float srcX, float srcY, float srcWidth,
float srcHeight, LColor c, float rotation, Vector2f origin,
Direction dir)
{
if (isClose)
{
return;
}
if (!texture.isVisible)
{
return;
}
if (!texture.isLoaded)
{
texture.LoadTexture();
}
lastTextre = texture;
texBatch.SetTexture(texture);
texBatch.GLBegin();
lastTextre = texture;
if (c != null)
{
texBatch.SetImageColor(c);
}
else
{
if (lastAlpha != 1f)
{
byte old = color.A;
color.A = (byte)(old * lastAlpha);
texBatch.SetImageColor(color);
color.A = old;
}
else
{
texBatch.SetImageColor(color);
}
}
bool flipX = false;
bool flipY = false;
if (Direction.TRANS_MIRROR == dir)
{
flipX = true;
}
else if (Direction.TRANS_FILP == dir)
{
flipY = true;
}
else if (Direction.TRANS_MF == dir)
{
flipX = true;
flipY = true;
}
if (origin != null)
{
texBatch.Draw(x, y, origin.x, origin.y, width, height, 1f, 1f,
rotation, srcX, srcY, srcWidth, srcHeight, flipX, flipY);
}
else if (rotation == 0 && !flipX && !flipY)
{
texBatch.Draw(x, y, width, height, srcX, srcY, srcWidth, srcHeight);
}
else if (rotation == 0)
{
texBatch.Draw(x, y, width,
height, srcX, srcY, srcWidth,
srcHeight, flipX, flipY);
}
else
{
texBatch.Draw(x, y, width / 2, height / 2, width, height, 1f, 1f,
rotation, srcX, srcY, srcWidth, srcHeight, flipX, flipY);
}
if (texBatch.isColor)
{
texBatch.SetImageColor(LColor.white);
}
texBatch.GLEnd();
}
示例4: CheckTexture
private void CheckTexture(LTexture texture)
{
CheckDrawing();
if (!texture.isLoaded)
{
texture.LoadTexture();
}
LTexture tex2d = texture.GetParent();
if (tex2d != null)
{
if (tex2d != lastTexture)
{
Submit();
lastTexture = tex2d;
}
else if (idx == vertices.Length)
{
Submit();
}
invTexWidth = (1f / texture.Width) * texture.widthRatio;
invTexHeight = (1f / texture.Height) * texture.heightRatio;
}
else if (texture != lastTexture)
{
Submit();
lastTexture = texture;
invTexWidth = (1f / texture.Width) * texture.widthRatio;
invTexHeight = (1f / texture.Height) * texture.heightRatio;
}
else if (idx == vertices.Length)
{
Submit();
}
}
示例5: DrawRegion
/**
* 渲染纹理为指定状态
*
* @param texture
* @param x_src
* @param y_src
* @param width
* @param height
* @param transform
* @param x_dst
* @param y_dst
* @param anchor
* @param c
*/
public void DrawRegion(LTexture texture, int x_src, int y_src, int width,
int height, int transform, int x_dst, int y_dst, int anchor,
LColor c)
{
if (isClose || texture == null || texture.isClose)
{
return;
}
if (!texture.isLoaded)
{
texture.LoadTexture();
}
if (x_src + width > texture.GetWidth()
|| y_src + height > texture.GetHeight() || width < 0
|| height < 0 || x_src < 0 || y_src < 0)
{
throw new Exception("Area out of texture");
}
int dW = width, dH = height;
float rotate = 0;
Direction dir = Direction.TRANS_NONE;
switch (transform)
{
case TRANS_NONE:
{
break;
}
case TRANS_ROT90:
{
rotate = 90;
dW = height;
dH = width;
break;
}
case TRANS_ROT180:
{
rotate = 180;
break;
}
case TRANS_ROT270:
{
rotate = 270;
dW = height;
dH = width;
break;
}
case TRANS_MIRROR:
{
dir = Direction.TRANS_MIRROR;
break;
}
case TRANS_MIRROR_ROT90:
{
dir = Direction.TRANS_MIRROR;
rotate = -90;
dW = height;
dH = width;
break;
}
case TRANS_MIRROR_ROT180:
{
dir = Direction.TRANS_MIRROR;
rotate = -180;
break;
}
case TRANS_MIRROR_ROT270:
{
dir = Direction.TRANS_MIRROR;
rotate = -270;
dW = height;
dH = width;
break;
}
default:
throw new Exception("Bad transform");
}
bool badAnchor = false;
if (anchor == 0)
{
anchor = LGraphics.TOP | LGraphics.LEFT;
}
//.........这里部分代码省略.........
示例6: SetTexture
public void SetTexture(LTexture tex2d)
{
if (!tex2d.isLoaded)
{
tex2d.LoadTexture();
}
this.textureBuffer = tex2d;
this.texWidth = textureBuffer.width;
this.texHeight = textureBuffer.height;
this.invTexWidth = (1f / texWidth) * textureBuffer.widthRatio;
this.invTexHeight = (1f / texHeight) * textureBuffer.heightRatio;
}