Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "RenderManager.h"
- #define _CRT_SECURE_NO_WARNINGS
- #define M_PI 3.14159265358979323846
- namespace Render
- {
- namespace Fonts
- {
- DWORD Default;
- DWORD Menu;
- DWORD MenuBold;
- DWORD ESP;
- DWORD MenuText;
- DWORD Icon;
- DWORD MenuTabs;
- DWORD Text;
- DWORD ICON;
- DWORD Slider;
- DWORD AAarows;
- DWORD Clock;
- DWORD Untitled1;
- DWORD LBY;
- DWORD Tabs;
- DWORD CheckBox;
- DWORD MenuSymbols;
- DWORD LBYIndicator;
- DWORD WeaponIcon;
- DWORD xd;
- DWORD jew;
- DWORD gay;
- };
- };
- enum EFontFlags
- {
- FONTFLAG_NONE,
- FONTFLAG_ITALIC = 0x001,
- FONTFLAG_UNDERLINE = 0x002,
- FONTFLAG_STRIKEOUT = 0x004,
- FONTFLAG_SYMBOL = 0x008,
- FONTFLAG_ANTIALIAS = 0x010,
- FONTFLAG_GAUSSIANBLUR = 0x020,
- FONTFLAG_ROTARY = 0x040,
- FONTFLAG_DROPSHADOW = 0x080,
- FONTFLAG_ADDITIVE = 0x100,
- FONTFLAG_OUTLINE = 0x200,
- FONTFLAG_CUSTOM = 0x400,
- FONTFLAG_BITMAP = 0x800,
- };
- void Render::Initialise()
- {
- Fonts::Default = 0x1D;
- Fonts::Menu = Interfaces::Surface->FontCreate();
- Fonts::MenuBold = Interfaces::Surface->FontCreate();
- Fonts::ESP = Interfaces::Surface->FontCreate();
- Fonts::MenuText = Interfaces::Surface->FontCreate();
- Fonts::Icon = Interfaces::Surface->FontCreate();
- Fonts::ICON = Interfaces::Surface->FontCreate();
- Fonts::MenuTabs = Interfaces::Surface->FontCreate();
- Fonts::MenuText = Interfaces::Surface->FontCreate();
- Fonts::Slider = Interfaces::Surface->FontCreate();
- Fonts::AAarows = Interfaces::Surface->FontCreate();
- Fonts::Clock = Interfaces::Surface->FontCreate();
- Fonts::Untitled1 = Interfaces::Surface->FontCreate();
- Fonts::LBY = Interfaces::Surface->FontCreate();
- Fonts::Tabs = Interfaces::Surface->FontCreate();
- Fonts::CheckBox = Interfaces::Surface->FontCreate();
- Fonts::MenuSymbols = Interfaces::Surface->FontCreate();
- Fonts::LBYIndicator = Interfaces::Surface->FontCreate();
- Fonts::WeaponIcon = Interfaces::Surface->FontCreate();
- Fonts::xd= Interfaces::Surface->FontCreate();
- Fonts::gay= Interfaces::Surface->FontCreate();
- Fonts::jew = Interfaces::Surface->FontCreate();
- Interfaces::Surface->SetFontGlyphSet(Fonts::Menu, "Arial", 12, 400, 0, 0, FONTFLAG_ANTIALIAS);
- Interfaces::Surface->SetFontGlyphSet(Fonts::Text, "DINPro-Regular", 30, 500, 0, 0, FONTFLAG_ANTIALIAS);
- Interfaces::Surface->SetFontGlyphSet(Fonts::MenuBold, "Arial", 14, 420, 0, 0, FONTFLAG_ANTIALIAS);
- Interfaces::Surface->SetFontGlyphSet(Fonts::ESP, "Tahoma", 12, 700, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_DROPSHADOW); //"Verdana", 12, 500, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_OUTLINE);
- Interfaces::Surface->SetFontGlyphSet(Fonts::MenuText, "Arial", 14, 370, 0, 0, FONTFLAG_ANTIALIAS);
- Interfaces::Surface->SetFontGlyphSet(Fonts::MenuTabs, "MyScriptFont", 18, 600, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_DROPSHADOW);
- Interfaces::Surface->SetFontGlyphSet(Fonts::Slider, "Arial", 17, 600, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_OUTLINE);
- Interfaces::Surface->SetFontGlyphSet(Fonts::Clock, "Arial", 22, 600, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_OUTLINE);
- Interfaces::Surface->SetFontGlyphSet(Fonts::Tabs, "badcache", 30, 600, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_DROPSHADOW);
- Interfaces::Surface->SetFontGlyphSet(Fonts::ICON, "Tahoma", 35, 800, 0, 0, FONTFLAG_ANTIALIAS);
- Interfaces::Surface->SetFontGlyphSet(Fonts::LBY, "Consolas", 38, 840, 0, 0, FONTFLAG_ANTIALIAS);
- Interfaces::Surface->SetFontGlyphSet(Fonts::CheckBox, "eagle", 14, 900, 0, 0, FONTFLAG_ANTIALIAS);
- Interfaces::Surface->SetFontGlyphSet(Fonts::Untitled1, "badcache", 16, 800, 0, 0, FONTFLAG_ANTIALIAS); //18
- Interfaces::Surface->SetFontGlyphSet(Fonts::Icon, "undefeated", 10, 500, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_DROPSHADOW | FONTFLAG_OUTLINE);
- Interfaces::Surface->SetFontGlyphSet(Fonts::MenuSymbols, "Tahoma", 16, 500, 0, 0, FONTFLAG_ANTIALIAS);
- Interfaces::Surface->SetFontGlyphSet(Fonts::LBYIndicator, "Verdana", 20, 700, 0, 0, FONTFLAG_ANTIALIAS | FONTFLAG_DROPSHADOW);
- Interfaces::Surface->SetFontGlyphSet(Fonts::WeaponIcon, "cs", 20, 500, 0, 0, FONTFLAG_NONE);
- Interfaces::Surface->SetFontGlyphSet(Fonts::AAarows, "Verdana", 37, 900, 0, 0, FONTFLAG_ANTIALIAS);
- Interfaces::Surface->SetFontGlyphSet(Fonts::gay, "Courier", 14, 505, 0, 0, FONTFLAG_ANTIALIAS);
- Interfaces::Surface->SetFontGlyphSet(Fonts::xd, "Courier", 20, 500, 0, 0, FONTFLAG_NONE);
- Interfaces::Surface->SetFontGlyphSet(Fonts::jew, "Courier", 30, 530, 0, 0, FONTFLAG_NONE);
- Utilities::Log("Render System Ready");
- }
- RECT Render::GetViewport()
- {
- RECT Viewport = { 0, 0, 0, 0 };
- int w, h;
- Interfaces::Engine->GetScreenSize(w, h);
- Viewport.right = w; Viewport.bottom = h;
- return Viewport;
- }
- void Render::Clear(int x, int y, int w, int h, Color color)
- {
- Interfaces::Surface->DrawSetColor(color);
- Interfaces::Surface->DrawFilledRect(x, y, x + w, y + h);
- }
- void Render::Outline(int x, int y, int w, int h, Color color)
- {
- Interfaces::Surface->DrawSetColor(color);
- Interfaces::Surface->DrawOutlinedRect(x, y, x + w, y + h);
- }
- void Render::OutlinedRect(int x, int y, int w, int h, Color color_out, Color color_in)
- {
- Interfaces::Surface->DrawSetColor(color_in);
- Interfaces::Surface->DrawFilledRect(x, y, x + w, y + h);
- Interfaces::Surface->DrawSetColor(color_out);
- Interfaces::Surface->DrawOutlinedRect(x, y, x + w, y + h);
- }
- void Render::Line(int x, int y, int x2, int y2, Color color)
- {
- Interfaces::Surface->DrawSetColor(color);
- Interfaces::Surface->DrawLine(x, y, x2, y2);
- }
- void Render::PolyLine(int *x, int *y, int count, Color color)
- {
- Interfaces::Surface->DrawSetColor(color);
- Interfaces::Surface->DrawPolyLine(x, y, count);
- }
- void Render::DrawOutlinedRect(int x, int y, int w, int h, Color col)
- {
- Interfaces::Surface->DrawSetColor(col);
- Interfaces::Surface->DrawOutlinedRect(x, y, x + w, y + h);
- }
- void Render::DrawLine(int x0, int y0, int x1, int y1, Color col)
- {
- Interfaces::Surface->DrawSetColor(col);
- Interfaces::Surface->DrawLine(x0, y0, x1, y1);
- }
- void Render::DrawRect(int x, int y, int w, int h, Color col)
- {
- Interfaces::Surface->DrawSetColor(col);
- Interfaces::Surface->DrawFilledRect(x, y, x + w, y + h);
- }
- void Render::rect(int x, int y, int w, int h, Color color)
- {
- Interfaces::Surface->DrawSetColor(color);
- Interfaces::Surface->DrawFilledRect(x, y, x + w, y + h);
- }
- bool Render::TransformScreen(const Vector& in, Vector& out)
- {
- static ptrdiff_t ptrViewMatrix;
- if (!ptrViewMatrix)
- {// findpattern z idy do wyszkuania
- ptrViewMatrix = static_cast<ptrdiff_t>(Utilities::Memory::FindPatternV2("client.dll", "0F 10 05 ? ? ? ? 8D 85 ? ? ? ? B9"));
- ptrViewMatrix += 0x3; // do ptrMatrix dodajemy +0x3 byte aby uzyskac dokladna lokalizacje
- ptrViewMatrix = *reinterpret_cast<uintptr_t*>(ptrViewMatrix);
- ptrViewMatrix += 176;
- }
- const matrix3x4& worldToScreen = Interfaces::Engine->WorldToScreenMatrix(); // matrix
- int ScrW, ScrH;
- Interfaces::Engine->GetScreenSize(ScrW, ScrH);
- float w = worldToScreen[3][0] * in[0] + worldToScreen[3][1] * in[1] + worldToScreen[3][2] * in[2] + worldToScreen[3][3];
- out.z = 0; // 0 poniewaz z nie jest nam potrzebne | uzywamy tylko wysokosci i szerokosci (x,y)
- if (w > 0.01)
- {
- float inverseWidth = 1 / w; // inverse na 1 pozycje ekranu
- out.x = (ScrW / 2) + (0.5 * ((worldToScreen[0][0] * in[0] + worldToScreen[0][1] * in[1] + worldToScreen[0][2] * in[2] + worldToScreen[0][3]) * inverseWidth) * ScrW + 0.5);
- out.y = (ScrH / 2) - (0.5 * ((worldToScreen[1][0] * in[0] + worldToScreen[1][1] * in[1] + worldToScreen[1][2] * in[2] + worldToScreen[1][3]) * inverseWidth) * ScrH + 0.5);
- return true;
- }
- return false;
- }
- bool Render::WorldToScreen(const Vector& in, Vector& out)
- {
- if (Render::TransformScreen(in, out)) {
- int w, h;
- Interfaces::Engine->GetScreenSize(w, h);
- out.x = (w / 2.0f) + (out.x * w) / 2.0f;
- out.y = (h / 2.0f) - (out.y * h) / 2.0f;
- return true;
- }
- return false;
- }
- void Render::Text(int x, int y, Color color, DWORD font, const char* text)
- {
- size_t origsize = strlen(text) + 1;
- const size_t newsize = 100;
- size_t convertedChars = 0;
- wchar_t wcstring[newsize];
- mbstowcs_s(&convertedChars, wcstring, origsize, text, _TRUNCATE);
- Interfaces::Surface->DrawSetTextFont(font);
- Interfaces::Surface->DrawSetTextColor(color);
- Interfaces::Surface->DrawSetTextPos(x, y);
- Interfaces::Surface->DrawPrintText(wcstring, wcslen(wcstring));
- return;
- }
- void Render::Text(int x, int y, Color color, DWORD font, const wchar_t* text)
- {
- Interfaces::Surface->DrawSetTextFont(font);
- Interfaces::Surface->DrawSetTextColor(color);
- Interfaces::Surface->DrawSetTextPos(x, y);
- Interfaces::Surface->DrawPrintText(text, wcslen(text));
- }
- void Render::Text2(int x, int y, const char* _Input, int font, Color color)
- {
- int apple = 0;
- char Buffer[2048] = { '\0' };
- va_list Args;
- va_start(Args, _Input);
- vsprintf_s(Buffer, _Input, Args);
- va_end(Args);
- size_t Size = strlen(Buffer) + 1;
- wchar_t* WideBuffer = new wchar_t[Size];
- mbstowcs_s(0, WideBuffer, Size, Buffer, Size - 1);
- Interfaces::Surface->DrawSetTextColor(color);
- Interfaces::Surface->DrawSetTextFont(font);
- Interfaces::Surface->DrawSetTextPos(x, y);
- Interfaces::Surface->DrawPrintText(WideBuffer, wcslen(WideBuffer));
- }
- void Render::Textf(int x, int y, Color color, DWORD font, const char* fmt, ...)
- {
- if (!fmt) return; //if the passed string is null return
- if (strlen(fmt) < 2) return;
- //Set up va_list and buffer to hold the params
- va_list va_alist;
- char logBuf[256] = { 0 };
- //Do sprintf with the parameters
- va_start(va_alist, fmt);
- _vsnprintf_s(logBuf + strlen(logBuf), 256 - strlen(logBuf), sizeof(logBuf) - strlen(logBuf), fmt, va_alist);
- va_end(va_alist);
- Text(x, y, color, font, logBuf);
- }
- RECT Render::GetTextSize(DWORD font, const char* text)
- {
- size_t origsize = strlen(text) + 1;
- const size_t newsize = 100;
- size_t convertedChars = 0;
- wchar_t wcstring[newsize];
- mbstowcs_s(&convertedChars, wcstring, origsize, text, _TRUNCATE);
- RECT rect; int x, y;
- Interfaces::Surface->GetTextSize(font, wcstring, x, y);
- rect.left = x; rect.bottom = y;
- rect.right = x;
- return rect;
- }
- void Render::GradientV(int x, int y, int w, int h, Color c1, Color c2)
- {
- Clear(x, y, w, h, c1);
- BYTE first = c2.r();
- BYTE second = c2.g();
- BYTE third = c2.b();
- for (int i = 0; i < h; i++)
- {
- float fi = i, fh = h;
- float a = fi / fh;
- DWORD ia = a * 255;
- Clear(x, y + i, w, 1, Color(first, second, third, ia));
- }
- }
- void Render::TexturedPolygon(int n, std::vector<Vertex_t> vertice, Color color)
- {
- static int texture_id = Interfaces::Surface->CreateNewTextureID(true); //
- static unsigned char buf[4] = { 255, 255, 255, 255 };
- Interfaces::Surface->DrawSetTextureRGBA(texture_id, buf, 1, 1); //
- Interfaces::Surface->DrawSetColor(color); //
- Interfaces::Surface->DrawSetTexture(texture_id); //
- Interfaces::Surface->DrawTexturedPolygon(n, vertice.data()); //
- }
- void Render::DrawCircle(float x, float y, float r, float segments, Color color)
- {
- Interfaces::Surface->DrawSetColor(color);
- Interfaces::Surface->DrawOutlinedCircle(x, y, r, segments);
- }
- void Render::GradientH(int x, int y, int w, int h, Color c1, Color c2)
- {
- Clear(x, y, w, h, c1);
- BYTE first = c2.r();
- BYTE second = c2.g();
- BYTE third = c2.b();
- for (int i = 0; i < w; i++)
- {
- float fi = i, fw = w;
- float a = fi / fw;
- DWORD ia = a * 255;
- Clear(x + i, y, 1, h, Color(first, second, third, ia));
- }
- }
- void Render::Polygon(int count, Vertex_t* Vertexs, Color color)
- {
- static int Texture = Interfaces::Surface->CreateNewTextureID(true); //need to make a texture with procedural true
- unsigned char buffer[4] = { 255, 255, 255, 255 };//{ color.r(), color.g(), color.b(), color.a() };
- Interfaces::Surface->DrawSetTextureRGBA(Texture, buffer, 1, 1); //Texture, char array of texture, width, height
- Interfaces::Surface->DrawSetColor(color); // keep this full color and opacity use the RGBA @top to set values.
- Interfaces::Surface->DrawSetTexture(Texture); // bind texture
- Interfaces::Surface->DrawTexturedPolygon(count, Vertexs);
- }
- void Render::PolygonOutline(int count, Vertex_t* Vertexs, Color color, Color colorLine)
- {
- static int x[128];
- static int y[128];
- Render::Polygon(count, Vertexs, color);
- for (int i = 0; i < count; i++)
- {
- x[i] = Vertexs[i].m_Position.x;
- y[i] = Vertexs[i].m_Position.y;
- }
- Render::PolyLine(x, y, count, colorLine);
- }
- void Render::PolyLine(int count, Vertex_t* Vertexs, Color colorLine)
- {
- static int x[128];
- static int y[128];
- for (int i = 0; i < count; i++)
- {
- x[i] = Vertexs[i].m_Position.x;
- y[i] = Vertexs[i].m_Position.y;
- }
- Render::PolyLine(x, y, count, colorLine);
- }
- void Render::Color_spectrum(int x, int y, int w, int h)
- {
- static int GradientTexture = 0;
- static std::unique_ptr<Color[]> Gradient = nullptr;
- if (!Gradient)
- {
- Gradient = std::make_unique<Color[]>(w * h);
- for (int i = 0; i < w; i++)
- {
- int div = w / 6;
- int phase = i / div;
- float t = (i % div) / (float)div;
- int r, g, b;
- switch (phase)
- {
- case(0):
- r = 255;
- g = 255 * t;
- b = 0;
- break;
- case(1):
- r = 255 * (1.f - t);
- g = 255;
- b = 0;
- break;
- case(2):
- r = 0;
- g = 255;
- b = 255 * t;
- break;
- case(3):
- r = 0;
- g = 255 * (1.f - t);
- b = 255;
- break;
- case(4):
- r = 255 * t;
- g = 0;
- b = 255;
- break;
- case(5):
- r = 255;
- g = 0;
- b = 255 * (1.f - t);
- break;
- }
- for (int k = 0; k < h; k++)
- {
- float sat = k / (float)h;
- int _r = r + sat * (128 - r);
- int _g = g + sat * (128 - g);
- int _b = b + sat * (128 - b);
- *reinterpret_cast<Color*>(Gradient.get() + i + k * w) = Color(_r, _g, _b);
- }
- }
- GradientTexture = Interfaces::Surface->CreateNewTextureID(true);
- Interfaces::Surface->DrawSetTextureRGBA(GradientTexture, (unsigned char*)Gradient.get(), w, h);
- }
- Interfaces::Surface->DrawSetColor(Color(255, 255, 255, 255));
- Interfaces::Surface->DrawSetTexture(GradientTexture);
- Interfaces::Surface->DrawTexturedRect(x, y, x + w, y + h);
- }
- Color Render::Color_spectrum_pen(int x, int y, int w, int h, Vector stx)
- {
- int div = w / 6;
- int phase = stx.x / div;
- float t = ((int)stx.x % div) / (float)div;
- int r, g, b;
- switch (phase)
- {
- case(0):
- r = 255;
- g = 255 * t;
- b = 0;
- break;
- case(1):
- r = 255 * (1.f - t);
- g = 255;
- b = 0;
- break;
- case(2):
- r = 0;
- g = 255;
- b = 255 * t;
- break;
- case(3):
- r = 0;
- g = 255 * (1.f - t);
- b = 255;
- break;
- case(4):
- r = 255 * t;
- g = 0;
- b = 255;
- break;
- case(5):
- r = 255;
- g = 0;
- b = 255 * (1.f - t);
- break;
- }
- float sat = stx.y / h;
- return Color(r + sat * (128 - r), g + sat * (128 - g), b + sat * (128 - b), 255);
- }
- void Render::DrawTexturedPoly(int n, Vertex_t* vertice, Color col)
- {
- static int texture_id = Interfaces::Surface->CreateNewTextureID(true);
- static unsigned char buf[4] = { 255, 255, 255, 255 };
- Interfaces::Surface->DrawSetTextureRGBA(texture_id, buf, 1, 1);
- Interfaces::Surface->DrawSetColor(col);
- Interfaces::Surface->DrawSetTexture(texture_id);
- Interfaces::Surface->DrawTexturedPolygon(n, vertice);
- }
- void Render::DrawFilledCircle(Vector2D center, Color color, float radius, float points)
- {
- std::vector<Vertex_t> vertices;
- float step = (float)M_PI * 2.0f / points;
- for (float a = 0; a < (M_PI * 2.0f); a += step)
- vertices.push_back(Vertex_t(Vector2D(radius * cosf(a) + center.x, radius * sinf(a) + center.y)));
- DrawTexturedPoly((int)points, vertices.data(), color);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement