mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
simplify drawing clipped text
This commit is contained in:
parent
b1c76ea153
commit
effed1f351
@ -117,32 +117,6 @@ namespace ClassicalSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawClippedText(ref DrawTextArgs args, int x, int y, float maxWidth, float maxHeight) {
|
||||
if (EmptyText(args.Text)) return;
|
||||
if (!args.SkipPartsCheck)
|
||||
GetTextParts(args.Text);
|
||||
|
||||
Brush shadowBrush = GetOrCreateBrush(PackedCol.Black);
|
||||
StringFormatFlags flags = format.FormatFlags;
|
||||
format.FormatFlags |= StringFormatFlags.NoWrap;
|
||||
format.Trimming = StringTrimming.EllipsisCharacter;
|
||||
float textX = x;
|
||||
|
||||
for (int i = 0; i < parts.Count; i++) {
|
||||
TextPart part = parts[i];
|
||||
Brush textBrush = GetOrCreateBrush(part.Col);
|
||||
RectangleF rect = new RectangleF(textX + Offset, y + Offset, maxWidth, maxHeight);
|
||||
if (args.UseShadow)
|
||||
g.DrawString(part.Text, args.Font, shadowBrush, rect, format);
|
||||
|
||||
rect = new RectangleF(textX, y, maxWidth, maxHeight);
|
||||
g.DrawString(part.Text, args.Font, textBrush, rect, format);
|
||||
textX += g.MeasureString(part.Text, args.Font, Int32.MaxValue, format).Width;
|
||||
}
|
||||
format.Trimming = StringTrimming.None;
|
||||
format.FormatFlags = flags;
|
||||
}
|
||||
|
||||
FastBitmap bitmapWrapper = new FastBitmap();
|
||||
protected override void DrawBitmappedText(ref DrawTextArgs args, int x, int y) {
|
||||
using (bitmapWrapper) {
|
||||
|
@ -68,10 +68,6 @@ namespace ClassicalSharp {
|
||||
|
||||
protected abstract void DrawSysText(ref DrawTextArgs args, int x, int y);
|
||||
|
||||
/// <summary> Draws a string using the specified arguments and fonts at the
|
||||
/// specified coordinates in the currently bound bitmap, clipping if necessary. </summary>
|
||||
public abstract void DrawClippedText(ref DrawTextArgs args, int x, int y, float maxWidth, float maxHeight);
|
||||
|
||||
protected abstract void DrawBitmappedText(ref DrawTextArgs args, int x, int y);
|
||||
|
||||
public void DrawText(ref DrawTextArgs args, int x, int y) {
|
||||
|
@ -9,7 +9,8 @@ using AndroidColor = Android.Graphics.Color;
|
||||
namespace ClassicalSharp {
|
||||
|
||||
/// <summary> Structure that can be used for quick manipulations of A/R/G/B colours. </summary>
|
||||
/// <remarks> This structure is **not** suitable for interop with OpenGL or Direct3D. </remarks>
|
||||
/// <remarks> This structure is suitable for interop with OpenGL or Direct3D.
|
||||
/// The order of each colour component differs depending on the underlying API. </remarks>
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct PackedCol : IEquatable<PackedCol> {
|
||||
|
||||
@ -44,8 +45,8 @@ namespace ClassicalSharp {
|
||||
public PackedCol(int r, int g, int b) {
|
||||
Packed = 0;
|
||||
A = 255; R = (byte)r; G = (byte)g; B = (byte)b;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary> Multiplies the RGB components of this instance by the
|
||||
/// specified t parameter, where 0 ≤ t ≤ 1 </summary>
|
||||
public static PackedCol Scale(PackedCol value, float t) {
|
||||
@ -71,21 +72,21 @@ namespace ClassicalSharp {
|
||||
lo * ((hex >> 0) & 1) + hi * (hex >> 3));
|
||||
}
|
||||
|
||||
#if !LAUNCHER
|
||||
#if !LAUNCHER
|
||||
public const float ShadeX = 0.6f, ShadeZ = 0.8f, ShadeYBottom = 0.5f;
|
||||
public static void GetShaded(PackedCol normal, out PackedCol xSide,
|
||||
public static void GetShaded(PackedCol normal, out PackedCol xSide,
|
||||
out PackedCol zSide, out PackedCol yBottom) {
|
||||
xSide = PackedCol.Scale(normal, ShadeX);
|
||||
zSide = PackedCol.Scale(normal, ShadeZ);
|
||||
yBottom = PackedCol.Scale(normal, ShadeYBottom);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/// <summary> Packs this instance into a 32 bit integer, where A occupies
|
||||
/// the highest 8 bits and B occupies the lowest 8 bits. </summary>
|
||||
public int ToArgb() { return A << 24 | R << 16 | G << 8 | B; }
|
||||
|
||||
public int ToArgb() { return A << 24 | R << 16 | G << 8 | B; }
|
||||
|
||||
public static PackedCol Argb(int c) {
|
||||
PackedCol col = default(PackedCol);
|
||||
col.A = (byte)(c >> 24);
|
||||
@ -99,20 +100,19 @@ namespace ClassicalSharp {
|
||||
return (obj is PackedCol) && Equals((PackedCol)obj);
|
||||
}
|
||||
|
||||
public bool Equals(PackedCol other) { return Packed == other.Packed; }
|
||||
public bool Equals(PackedCol other) { return Packed == other.Packed; }
|
||||
public override int GetHashCode() { return (int)Packed; }
|
||||
|
||||
public override string ToString() {
|
||||
return R + ", " + G + ", " + B + " : " + A;
|
||||
}
|
||||
|
||||
|
||||
public static bool operator == (PackedCol left, PackedCol right) {
|
||||
return left.Equals(right);
|
||||
return left.Packed == right.Packed;
|
||||
}
|
||||
|
||||
public static bool operator != (PackedCol left, PackedCol right) {
|
||||
return !left.Equals(right);
|
||||
return left.Packed != right.Packed;
|
||||
}
|
||||
|
||||
public static PackedCol operator * (PackedCol left, PackedCol right) {
|
||||
@ -142,14 +142,14 @@ namespace ClassicalSharp {
|
||||
public static PackedCol Yellow = new PackedCol(255, 255, 0);
|
||||
public static PackedCol Magenta = new PackedCol(255, 0, 255);
|
||||
public static PackedCol Cyan = new PackedCol(0, 255, 255);
|
||||
|
||||
|
||||
public string ToHex() {
|
||||
byte[] array = new byte[] { R, G, B };
|
||||
int len = array.Length;
|
||||
char[] hex = new char[len * 2];
|
||||
|
||||
for (int i = 0; i < array.Length; i++) {
|
||||
int value = array[i], hi = value >> 4, lo = value & 0x0F;
|
||||
int value = array[i], hi = value >> 4, lo = value & 0x0F;
|
||||
// 48 = index of 0, 55 = index of (A - 10)
|
||||
hex[i * 2 + 0] = hi < 10 ? (char)(hi + 48) : (char)(hi + 55);
|
||||
hex[i * 2 + 1] = lo < 10 ? (char)(lo + 48) : (char)(lo + 55);
|
||||
|
@ -434,7 +434,6 @@ namespace SharpDX.Direct3D9 {
|
||||
SpecularEnable = 29,
|
||||
FogColor = 34,
|
||||
FogTableMode = 35,
|
||||
FogStart = 36,
|
||||
FogEnd = 37,
|
||||
FogDensity = 38,
|
||||
Lighting = 137,
|
||||
|
@ -128,19 +128,13 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
Device.SetRenderState(device, RenderState.FogColor, (int)fogCol.Packed);
|
||||
}
|
||||
|
||||
float fogDensity = -1, fogStart = -1, fogEnd = -1;
|
||||
float fogDensity = -1, fogEnd = -1;
|
||||
public override void SetFogDensity(float value) {
|
||||
if (value == fogDensity) return;
|
||||
fogDensity = value;
|
||||
if (LostContext) return;
|
||||
Device.SetRenderState(device, RenderState.FogDensity, value);
|
||||
}
|
||||
|
||||
public override void SetFogStart(float value) {
|
||||
fogStart = value;
|
||||
if (LostContext) return;
|
||||
Device.SetRenderState(device, RenderState.FogStart, value);
|
||||
}
|
||||
|
||||
public override void SetFogEnd(float value) {
|
||||
if (value == fogEnd) return;
|
||||
@ -484,7 +478,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
Device.SetRenderState(device, RenderState.FogEnable, fogEnable);
|
||||
Device.SetRenderState(device, RenderState.FogColor, (int)fogCol.Packed);
|
||||
Device.SetRenderState(device, RenderState.FogDensity, fogDensity);
|
||||
Device.SetRenderState(device, RenderState.FogStart, fogStart);
|
||||
Device.SetRenderState(device, RenderState.FogEnd, fogEnd);
|
||||
Device.SetRenderState(device, RenderState.FogTableMode, (int)fogTableMode);
|
||||
Device.SetRenderState(device, RenderState.ZFunc, (int)depthTestFunc);
|
||||
|
@ -353,7 +353,6 @@ namespace OpenTK.Graphics.OpenGL {
|
||||
|
||||
public enum FogParameter : int {
|
||||
FogDensity = 0x0B62,
|
||||
FogStart = 0x0B63,
|
||||
FogEnd = 0x0B64,
|
||||
FogMode = 0x0B65,
|
||||
FogColor = 0x0B66,
|
||||
|
@ -59,7 +59,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
public abstract bool Fog { get; set; }
|
||||
public abstract void SetFogCol(PackedCol col);
|
||||
public abstract void SetFogDensity(float value);
|
||||
public abstract void SetFogStart(float value);
|
||||
public abstract void SetFogEnd(float value);
|
||||
public abstract void SetFogMode(Fog fogMode);
|
||||
|
||||
|
@ -113,10 +113,6 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
lastFogDensity = value;
|
||||
}
|
||||
|
||||
public override void SetFogStart(float value) {
|
||||
GL.Fogf(FogParameter.FogStart, value);
|
||||
}
|
||||
|
||||
public override void SetFogEnd(float value) {
|
||||
if (value == lastFogEnd) return;
|
||||
GL.Fogf(FogParameter.FogEnd, value);
|
||||
|
@ -56,15 +56,11 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
}
|
||||
}
|
||||
|
||||
float lastFogStart = -1, lastFogEnd = -1, lastFogDensity = -1;
|
||||
float lastFogEnd = -1, lastFogDensity = -1;
|
||||
public override void SetFogDensity(float value) {
|
||||
FogParam(All.FogDensity, value, ref lastFogDensity);
|
||||
}
|
||||
|
||||
public override void SetFogStart(float value) {
|
||||
FogParam(All.FogStart, value, ref lastFogStart);
|
||||
}
|
||||
|
||||
public override void SetFogEnd(float value) {
|
||||
FogParam(All.FogEnd, value, ref lastFogEnd);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace Launcher.Drawing {
|
||||
row[x + xx] = pixel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool ClampCoords(FastBitmap bmp, Rectangle rect, out int x,
|
||||
out int y, out int width, out int height) {
|
||||
width = rect.Width; height = rect.Height;
|
||||
@ -28,35 +28,50 @@ namespace Launcher.Drawing {
|
||||
if (x < 0) { width += x; x = 0; }
|
||||
if (y < 0) { height += y; y = 0; }
|
||||
|
||||
width = Math.Min(x + width, bmp.Width) - x;
|
||||
width = Math.Min(x + width, bmp.Width) - x;
|
||||
height = Math.Min(y + height, bmp.Height) - y;
|
||||
return width > 0 && height > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool TryDraw(ref DrawTextArgs args, IDrawer2D drawer,
|
||||
int x, int y, int maxWidth) {
|
||||
Size size = drawer.MeasureSize(ref args);
|
||||
if (size.Width > maxWidth) return false;
|
||||
|
||||
args.SkipPartsCheck = true;
|
||||
drawer.DrawText(ref args, x, y);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void DrawClippedText(ref DrawTextArgs args, IDrawer2D drawer,
|
||||
int x, int y, int maxWidth) {
|
||||
Size size = drawer.MeasureSize(ref args);
|
||||
// No clipping necessary
|
||||
if (size.Width <= maxWidth) { drawer.DrawText(ref args, x, y); return; }
|
||||
DrawTextArgs copy = args;
|
||||
copy.SkipPartsCheck = true;
|
||||
// No clipping needed
|
||||
if (size.Width <= maxWidth) {
|
||||
args.SkipPartsCheck = true;
|
||||
drawer.DrawText(ref args, x, y); return;
|
||||
}
|
||||
|
||||
char[] chars = new char[args.Text.Length + 2];
|
||||
for (int i = 0; i < args.Text.Length; i++)
|
||||
chars[i] = args.Text[i];
|
||||
chars[args.Text.Length] = '.';
|
||||
chars[args.Text.Length + 1] = '.';
|
||||
string text = args.Text;
|
||||
char[] chars = new char[text.Length + 2];
|
||||
|
||||
for (int len = args.Text.Length; len > 0; len--) {
|
||||
chars[len] = '.';
|
||||
if (chars[len - 1] == ' ') continue;
|
||||
for (int i = 0; i < text.Length; i++) { chars[i] = text[i]; }
|
||||
chars[text.Length] = '.';
|
||||
chars[text.Length + 1] = '.';
|
||||
|
||||
DrawTextArgs part = args;
|
||||
for (int i = text.Length - 1; i > 0; i--) {
|
||||
chars[i] = '.';
|
||||
if (text[i - 1] == ' ') continue;
|
||||
|
||||
copy.Text = new string(chars, 0, len + 2);
|
||||
size = drawer.MeasureSize(ref copy);
|
||||
if (size.Width > maxWidth) continue;
|
||||
part.Text = new string(chars, 0, i + 2);
|
||||
if (TryDraw(ref part, drawer, x, y, maxWidth)) return;
|
||||
|
||||
drawer.DrawText(ref copy, x, y); return;
|
||||
// If down to <= 2 chars, try omit trailing ..
|
||||
if (i > 2) continue;
|
||||
part.Text = new string(chars, 0, i);
|
||||
if (TryDraw(ref part, drawer, x, y, maxWidth)) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,8 +159,7 @@ namespace Launcher.Gui.Widgets {
|
||||
if (!empty) {
|
||||
size.Width = Math.Min(maxWidth, size.Width);
|
||||
args.SkipPartsCheck = false;
|
||||
//Drawer2DExt.DrawClippedText(ref args, drawer, x, y, maxWidth);
|
||||
drawer.DrawClippedText(ref args, x, y, maxWidth, 30);
|
||||
Drawer2DExt.DrawClippedText(ref args, drawer, x, y, maxWidth);
|
||||
}
|
||||
y += size.Height + 2;
|
||||
return true;
|
||||
|
@ -92,7 +92,7 @@ static void AsyncDownloader_Add(String* url, bool priority, String* id, UInt8 ty
|
||||
if (etag) {
|
||||
String reqEtag = String_FromEmptyArray(req.Etag); String_Set(&reqEtag, etag);
|
||||
}
|
||||
//request.Data = data; TODO: Implement this. do we need to copy or expect caller to malloc it?
|
||||
/* request.Data = data; TODO: Implement this. do we need to copy or expect caller to malloc it? */
|
||||
|
||||
Platform_CurrentUTCTime(&req.TimeAdded);
|
||||
if (priority) {
|
||||
|
@ -10,9 +10,11 @@ struct IGameComponent;
|
||||
struct ScheduledTask;
|
||||
|
||||
enum REQUEST_TYPE { REQUEST_TYPE_DATA, REQUEST_TYPE_CONTENT_LENGTH };
|
||||
#define ASYNC_PROGRESS_NOTHING -3
|
||||
#define ASYNC_PROGRESS_MAKING_REQUEST -2
|
||||
#define ASYNC_PROGRESS_FETCHING_DATA -1
|
||||
enum ASYNC_PROGRESS {
|
||||
ASYNC_PROGRESS_NOTHING = -3,
|
||||
ASYNC_PROGRESS_MAKING_REQUEST = -2,
|
||||
ASYNC_PROGRESS_FETCHING_DATA = -1,
|
||||
};
|
||||
|
||||
struct AsyncRequest {
|
||||
UChar URL[String_BufferSize(STRING_SIZE)];
|
||||
@ -37,7 +39,7 @@ void AsyncDownloader_GetSkin(STRING_PURE String* id, STRING_PURE String* skinNam
|
||||
void AsyncDownloader_GetData(STRING_PURE String* url, bool priority, STRING_PURE String* id);
|
||||
void AsyncDownloader_GetContentLength(STRING_PURE String* url, bool priority, STRING_PURE String* id);
|
||||
/* TODO: Implement post */
|
||||
//void AsyncDownloader_PostString(STRING_PURE String* url, bool priority, STRING_PURE String* id, STRING_PURE String* contents);
|
||||
/* void AsyncDownloader_PostString(STRING_PURE String* url, bool priority, STRING_PURE String* id, STRING_PURE String* contents); */
|
||||
void AsyncDownloader_GetDataEx(STRING_PURE String* url, bool priority, STRING_PURE String* id, DateTime* lastModified, STRING_PURE String* etag);
|
||||
|
||||
bool AsyncDownloader_Get(STRING_PURE String* id, struct AsyncRequest* item);
|
||||
|
@ -311,14 +311,6 @@ void Gfx_SetFogDensity(Real32 value) {
|
||||
D3D9_SetRenderState(D3DRS_FOGDENSITY, raw.uVal, "D3D9_SetFogDensity");
|
||||
}
|
||||
|
||||
Real32 d3d9_fogStart = -1.0f;
|
||||
void Gfx_SetFogStart(Real32 value) {
|
||||
d3d9_fogStart = value;
|
||||
if (Gfx_LostContext) return;
|
||||
IntAndFloat raw; raw.fVal = value;
|
||||
D3D9_SetRenderState(D3DRS_FOGSTART, raw.uVal, "D3D9_SetFogStart");
|
||||
}
|
||||
|
||||
Real32 d3d9_fogEnd = -1.0f;
|
||||
void Gfx_SetFogEnd(Real32 value) {
|
||||
if (value == d3d9_fogEnd) return;
|
||||
@ -656,8 +648,6 @@ static void D3D9_RestoreRenderStates(void) {
|
||||
D3D9_SetRenderState2(D3DRS_FOGCOLOR, d3d9_fogCol, "D3D9_FogColor");
|
||||
raw.fVal = d3d9_fogDensity;
|
||||
D3D9_SetRenderState2(D3DRS_FOGDENSITY, raw.uVal, "D3D9_FogDensity");
|
||||
raw.fVal = d3d9_fogStart;
|
||||
D3D9_SetRenderState2(D3DRS_FOGSTART, raw.uVal, "D3D9_FogStart");
|
||||
raw.fVal = d3d9_fogEnd;
|
||||
D3D9_SetRenderState2(D3DRS_FOGEND, raw.uVal, "D3D9_FogEnd");
|
||||
D3D9_SetRenderState2(D3DRS_FOGTABLEMODE, d3d9_fogTableMode, "D3D9_FogMode");
|
||||
|
@ -295,7 +295,7 @@ static void Drawer2D_DrawUnderline(struct DrawTextArgs* args, Int32 x, Int32 y,
|
||||
UChar c = text.buffer[i];
|
||||
if (c == '&' && Drawer2D_ValidColCodeAt(&text, i + 1)) {
|
||||
col = Drawer2D_Cols[text.buffer[i + 1]];
|
||||
i++; continue; // Skip over the colour code.
|
||||
i++; continue; /* Skip over the colour code */
|
||||
}
|
||||
|
||||
Int32 dstWidth = Drawer2D_Width(point, c);
|
||||
|
@ -299,35 +299,35 @@ void EnvRenderer_RenderSkybox(Real64 deltaTime) {
|
||||
Gfx_SetDepthWrite(true);
|
||||
}
|
||||
|
||||
VertexP3fT2fC4b skybox_vertices[SKYBOX_COUNT] = {
|
||||
/* Front quad */
|
||||
{ 1, -1, -1, {0,0,0,0}, 0.25f, 1.00f }, { -1, -1, -1, {0,0,0,0}, 0.50f, 1.00f },
|
||||
{ -1, 1, -1, {0,0,0,0}, 0.50f, 0.50f }, { 1, 1, -1, {0,0,0,0}, 0.25f, 0.50f },
|
||||
/* Left quad */
|
||||
{ 1, -1, 1, {0,0,0,0}, 0.00f, 1.00f }, { 1, -1, -1, {0,0,0,0}, 0.25f, 1.00f },
|
||||
{ 1, 1, -1, {0,0,0,0}, 0.25f, 0.50f }, { 1, 1, 1, {0,0,0,0}, 0.00f, 0.50f },
|
||||
/* Back quad */
|
||||
{ -1, -1, 1, {0,0,0,0}, 0.75f, 1.00f }, { 1, -1, 1, {0,0,0,0}, 1.00f, 1.00f },
|
||||
{ 1, 1, 1, {0,0,0,0}, 1.00f, 0.50f }, { -1, 1, 1, {0,0,0,0}, 0.75f, 0.50f },
|
||||
/* Right quad */
|
||||
{ -1, -1, -1, {0,0,0,0}, 0.50f, 1.00f }, { -1, -1, 1, {0,0,0,0}, 0.75f, 1.00f },
|
||||
{ -1, 1, 1, {0,0,0,0}, 0.75f, 0.50f }, { -1, 1, -1, {0,0,0,0}, 0.50f, 0.50f },
|
||||
/* Top quad */
|
||||
{ -1, 1, -1, {0,0,0,0}, 0.50f, 0.50f }, { -1, 1, 1, {0,0,0,0}, 0.50f, 0.00f },
|
||||
{ 1, 1, 1, {0,0,0,0}, 0.25f, 0.00f }, { 1, 1, -1, {0,0,0,0}, 0.25f, 0.50f },
|
||||
/* Bottom quad */
|
||||
{ -1, -1, -1, {0,0,0,0}, 0.75f, 0.50f }, { -1, -1, 1, {0,0,0,0}, 0.75f, 0.00f },
|
||||
{ 1, -1, 1, {0,0,0,0}, 0.50f, 0.00f }, { 1, -1, -1, {0,0,0,0}, 0.50f, 0.50f },
|
||||
};
|
||||
|
||||
static void EnvRenderer_UpdateSkybox(void) {
|
||||
if (Gfx_LostContext) return;
|
||||
Gfx_DeleteVb(&skybox_vb);
|
||||
if (EnvRenderer_Minimal) return;
|
||||
|
||||
static VertexP3fT2fC4b vertices[SKYBOX_COUNT] = {
|
||||
/* Front quad */
|
||||
{ 1, -1, -1, {0,0,0,0}, 0.25f, 1.00f }, { -1, -1, -1, {0,0,0,0}, 0.50f, 1.00f },
|
||||
{ -1, 1, -1, {0,0,0,0}, 0.50f, 0.50f }, { 1, 1, -1, {0,0,0,0}, 0.25f, 0.50f },
|
||||
/* Left quad */
|
||||
{ 1, -1, 1, {0,0,0,0}, 0.00f, 1.00f }, { 1, -1, -1, {0,0,0,0}, 0.25f, 1.00f },
|
||||
{ 1, 1, -1, {0,0,0,0}, 0.25f, 0.50f }, { 1, 1, 1, {0,0,0,0}, 0.00f, 0.50f },
|
||||
/* Back quad */
|
||||
{ -1, -1, 1, {0,0,0,0}, 0.75f, 1.00f }, { 1, -1, 1, {0,0,0,0}, 1.00f, 1.00f },
|
||||
{ 1, 1, 1, {0,0,0,0}, 1.00f, 0.50f }, { -1, 1, 1, {0,0,0,0}, 0.75f, 0.50f },
|
||||
/* Right quad */
|
||||
{ -1, -1, -1, {0,0,0,0}, 0.50f, 1.00f }, { -1, -1, 1, {0,0,0,0}, 0.75f, 1.00f },
|
||||
{ -1, 1, 1, {0,0,0,0}, 0.75f, 0.50f }, { -1, 1, -1, {0,0,0,0}, 0.50f, 0.50f },
|
||||
/* Top quad */
|
||||
{ -1, 1, -1, {0,0,0,0}, 0.50f, 0.50f }, { -1, 1, 1, {0,0,0,0}, 0.50f, 0.00f },
|
||||
{ 1, 1, 1, {0,0,0,0}, 0.25f, 0.00f }, { 1, 1, -1, {0,0,0,0}, 0.25f, 0.50f },
|
||||
/* Bottom quad */
|
||||
{ -1, -1, -1, {0,0,0,0}, 0.75f, 0.50f }, { -1, -1, 1, {0,0,0,0}, 0.75f, 0.00f },
|
||||
{ 1, -1, 1, {0,0,0,0}, 0.50f, 0.00f }, { 1, -1, -1, {0,0,0,0}, 0.50f, 0.50f },
|
||||
};
|
||||
|
||||
Int32 i;
|
||||
for (i = 0; i < SKYBOX_COUNT; i++) { skybox_vertices[i].Col = WorldEnv_CloudsCol; }
|
||||
skybox_vb = Gfx_CreateVb(skybox_vertices, VERTEX_FORMAT_P3FT2FC4B, SKYBOX_COUNT);
|
||||
for (i = 0; i < SKYBOX_COUNT; i++) { vertices[i].Col = WorldEnv_CloudsCol; }
|
||||
skybox_vb = Gfx_CreateVb(vertices, VERTEX_FORMAT_P3FT2FC4B, SKYBOX_COUNT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,7 +56,6 @@ bool Gfx_GetFog(void);
|
||||
void Gfx_SetFog(bool enabled);
|
||||
void Gfx_SetFogCol(PackedCol col);
|
||||
void Gfx_SetFogDensity(Real32 value);
|
||||
void Gfx_SetFogStart(Real32 value);
|
||||
void Gfx_SetFogEnd(Real32 value);
|
||||
void Gfx_SetFogMode(Int32 fogMode);
|
||||
|
||||
|
@ -167,7 +167,7 @@ static UInt32 GfxCommon_Average(UInt32 p1, UInt32 p2) {
|
||||
UInt32 a1 = ((p1 & alphaMask) >> 24) & 0xFF;
|
||||
UInt32 a2 = ((p2 & alphaMask) >> 24) & 0xFF;
|
||||
UInt32 aSum = (a1 + a2);
|
||||
aSum = aSum > 0 ? aSum : 1; // avoid divide by 0 below
|
||||
aSum = aSum > 0 ? aSum : 1; /* avoid divide by 0 below */
|
||||
|
||||
/* Convert RGB to pre-multiplied form */
|
||||
UInt32 r1 = ((p1 >> 16) & 0xFF) * a1, g1 = ((p1 >> 8) & 0xFF) * a1, b1 = (p1 & 0xFF) * a1;
|
||||
|
@ -203,10 +203,6 @@ void Gfx_SetFogDensity(Real32 value) {
|
||||
gl_lastFogDensity = value;
|
||||
}
|
||||
|
||||
void Gfx_SetFogStart(Real32 value) {
|
||||
glFogf(GL_FOG_START, value);
|
||||
}
|
||||
|
||||
void Gfx_SetFogEnd(Real32 value) {
|
||||
if (value == gl_lastFogEnd) return;
|
||||
glFogf(GL_FOG_END, value);
|
||||
|
@ -6,15 +6,13 @@
|
||||
*/
|
||||
|
||||
/* Represents an ARGB colour, in a format suitable for the native graphics api. */
|
||||
typedef struct PackedCol_ {
|
||||
union {
|
||||
typedef union PackedCol_ {
|
||||
#if CC_BUILD_D3D9
|
||||
struct { UInt8 B; UInt8 G; UInt8 R; UInt8 A; };
|
||||
struct { UInt8 B; UInt8 G; UInt8 R; UInt8 A; };
|
||||
#else
|
||||
struct { UInt8 R; UInt8 G; UInt8 B; UInt8 A; };
|
||||
struct { UInt8 R; UInt8 G; UInt8 B; UInt8 A; };
|
||||
#endif
|
||||
UInt32 Packed;
|
||||
};
|
||||
UInt32 Packed;
|
||||
} PackedCol;
|
||||
|
||||
#if CC_BUILD_D3D9
|
||||
|
@ -154,10 +154,12 @@ String lines10[3] = { 0 };
|
||||
WordWrap_Do(&text10, lines10, 3, 4);
|
||||
*/
|
||||
|
||||
//#include <Windows.h>
|
||||
int main_test(int argc, char* argv[]) {
|
||||
return 0;
|
||||
/*void* file;
|
||||
/*
|
||||
#include <Windows.h>
|
||||
|
||||
void* file;
|
||||
String path = String_FromConstant("H:\\PortableApps\\GitPortable\\App\\Git\\ClassicalSharp\\output\\release\\texpacks\\skybox.png");
|
||||
ReturnCode openCode = Platform_FileOpen(&file, &path);
|
||||
Stream fileStream;
|
||||
|
@ -814,11 +814,10 @@ static void ChatScreen_CheckOtherStatuses(struct ChatScreen* screen) {
|
||||
bool hasRequest = AsyncDownloader_GetCurrent(&request, &progress);
|
||||
|
||||
String id = String_FromRawArray(request.ID);
|
||||
String terrain = String_FromConst("terrain");
|
||||
String texPack = String_FromConst("texturePack");
|
||||
|
||||
/* Is terrain / texture pack currently being downloaded? */
|
||||
if (!hasRequest || !(String_Equals(&id, &terrain) || String_Equals(&id, &texPack))) {
|
||||
if (!hasRequest || !String_Equals(&id, &texPack)) {
|
||||
if (screen->Status.Textures[1].ID) {
|
||||
String empty = String_MakeNull();
|
||||
TextGroupWidget_SetText(&screen->Status, 1, &empty);
|
||||
|
@ -59,7 +59,7 @@ struct FontDesc { void* Handle; UInt16 Size, Style; };
|
||||
#define UInt32_MaxValue ((UInt32)4294967295UL)
|
||||
|
||||
#define CC_BUILD_GL11 false
|
||||
#define CC_BUILD_D3D9 true
|
||||
#define CC_BUILD_D3D9 false
|
||||
|
||||
#define CC_BUILD_WIN true
|
||||
#define CC_BUILD_OSX false
|
||||
|
@ -556,9 +556,9 @@ void Window_ProcessEvents(void) {
|
||||
Event_RaiseVoid(&WindowEvents_WindowStateChanged);
|
||||
}
|
||||
|
||||
//if (e.xproperty.atom == net_frame_extents) {
|
||||
// RefreshWindowBorders();
|
||||
//}
|
||||
/*if (e.xproperty.atom == net_frame_extents) {
|
||||
RefreshWindowBorders();
|
||||
}*/
|
||||
break;
|
||||
|
||||
case SelectionNotify:
|
||||
@ -721,10 +721,9 @@ void GLContext_SetVSync(bool enabled) {
|
||||
static void GLContext_GetAttribs(struct GraphicsMode mode, Int32* attribs) {
|
||||
Int32 i = 0;
|
||||
struct ColorFormat color = mode.Format;
|
||||
// See http://www-01.ibm.com/support/knowledgecenter/ssw_aix_61/com.ibm.aix.opengl/doc/openglrf/glXChooseFBConfig.htm%23glxchoosefbconfig
|
||||
// See http://www-01.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.opengl/doc/openglrf/glXChooseVisual.htm%23b5c84be452rree
|
||||
// for the attribute declarations. Note that the attributes are different than those used in Glx.ChooseVisual.
|
||||
|
||||
/* See http://www-01.ibm.com/support/knowledgecenter/ssw_aix_61/com.ibm.aix.opengl/doc/openglrf/glXChooseFBConfig.htm%23glxchoosefbconfig */
|
||||
/* See http://www-01.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.opengl/doc/openglrf/glXChooseVisual.htm%23b5c84be452rree */
|
||||
/* for the attribute declarations. Note that the attributes are different than those used in Glx.ChooseVisual */
|
||||
|
||||
if (!color.IsIndexed) {
|
||||
attribs[i++] = GLX_RGBA;
|
||||
|
Loading…
x
Reference in New Issue
Block a user