graphic
anulax1225 ago%!(EXTRA string=7 months)
parent 1f5f756508
commit d0457d9624
  1. 4
      .gitignore
  2. BIN
      app/assets/textures/warhammer.jpg
  3. 173
      app/src/app.cpp
  4. 4
      package.json
  5. 3
      premake5.lua

4
.gitignore vendored

@ -4,10 +4,14 @@
/.vscode/ /.vscode/
/.vs/ /.vs/
/docs/ /docs/
/.cache/
**.log **.log
**.ninja
**.sln **.sln
**.vcxproj* **.vcxproj*
**.make **.make
**Makefile **Makefile
**dependencies.lua **dependencies.lua
**linker.lua **linker.lua
/compile_commands/
**compile_commands.json

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

@ -1,114 +1,101 @@
#include <bakatools.h> #include "bakara/renderer/renderer.h"
#include <math.h> #include "bakatools/logging/log.h"
#include <stdlib.h> #include "glm/ext/matrix_transform.hpp"
#include <bakara.h>
long long int random(long long int max, long long int min = 0) using namespace Bk;
{
long long int n = rand();
while (n > max || n < min) n = rand();
return n;
}
std::vector<long long int> prime_range(long long int max, long long int min = 2) class TestLayer : public Layer
{ {
//Sieve of Eratosthenes algo from https://www.baeldung.com/cs/prime-number-algorithms public:
std::vector<long long int> primes; TestLayer() : Layer("Test")
std::vector<bool> primes_check(max);
std::fill(primes_check.begin(), primes_check.end(), true);
for (long long int i = 2; i < sqrt(max); i++)
if (primes_check[i])
{
long long int j = i * i;
while (j <= max)
{ {
primes_check[j] = false; blueShader = Ref<Shader>(Shader::Create(R"(
j += i; #version 420 core
} layout (location = 0) in vec3 aPos;
}
for (long long int i = min; i < primes_check.size(); i++) uniform mat4 viewProjection;
if (primes_check[i]) primes.push_back(i); uniform mat4 transform;
return primes; void main() {
} gl_Position = viewProjection * transform * vec4(aPos, 1.0);
}
)", R"(
#version 420 core
long long int gcd(long long int a, long long int b) out vec4 FragColor;
{
long long int temp; void main() {
while (b != 0) FragColor = vec4(0.0, 0.0, 0.5, 1.0);
{
temp = a % b;
a = b;
b = temp;
} }
return a; )"));
}
long long int power(long long int val, long long int power) float squareVertices[7 * 3] = {
{ -0.5f, -0.5f, 0.0f,
long long int res = val; 0.5f, -0.5f, 0.0f,
for(long long int i = 1; i < power; i++) res *= val; 0.5f, 0.5f, 0.0f,
return res; -0.5f, 0.5f, 0.0f,
} };
squareVA = Ref<VertexArray>(VertexArray::Create());
void rsa() Ref<VertexBuffer> squareVB = Ref<VertexBuffer>(VertexBuffer::Create(squareVertices, sizeof(squareVertices)));
{ squareVB->SetLayout({
auto primes = prime_range(100, 50); { ShaderType::Float3, "aPos" }
//long long int p = primes[random(primes.size())]; });
//long long int q = primes[random(primes.size())]; squareVA->AddVertexBuffer(squareVB);
long long int p = 13;
long long int q = 17; u32 squareIndices[6] = { 0, 1, 2, 0, 2, 3 };
long long int n = p * q; squareVA->SetIndexbuffer(Ref<IndexBuffer>(IndexBuffer::Create(squareIndices, sizeof(squareIndices) / sizeof(u32))));
long long int phi = (p - 1) * (q - 1);
long long int e = 2;
long long int k = 0;
while(e < phi)
{
if (gcd(e, phi) == 1) k += 1;
if (k >= 20) break;
e += 1;
} }
long long int d = 0; void OnUpdate(DeltaTime dt) override
long long int j = 0;
while (j < 2)
{
d += 1;
if (1 == (e * d) % phi)
{ {
j += 1; if(Keyboard::KeyDown(KeyCode::W))
} cameraPos.y += cameraSpeed * dt;
if(Keyboard::KeyDown(KeyCode::S))
cameraPos.y -= cameraSpeed * dt;
if(Keyboard::KeyDown(KeyCode::D))
cameraPos.x += cameraSpeed * dt;
if(Keyboard::KeyDown(KeyCode::A))
cameraPos.x -= cameraSpeed * dt;
if(Keyboard::KeyDown(KeyCode::Q))
rotation -= rotationSpeed * dt;
if(Keyboard::KeyDown(KeyCode::E))
rotation += rotationSpeed * dt;
camera.SetPosition(cameraPos);
camera.SetRotation(rotation);
Renderer::BeginScene(camera);
RenderCommand::Clear(0.1, 0.1, 0.1, 1.0);
for(int x = 0; x < 20; x += 2)
for(int y = 0; y < 20; y += 2)
Renderer::Submit(squareVA, blueShader, Math::translate(Mat4(1.0f), Vec3(x, y, 0)));
} }
BK_INFO("p:{4} q:{5} n:{0} phi:{1} e:{2} d:{3}", n, phi, e, d, p, q);
long long int msg = 20; private:
long long int C = power(msg, e) % n; OrthographicCamera camera = { -10.0f, 10.0f, -10.0f, 10.0f };
BK_INFO("{0} {1}", C, power(msg, e)); Ref<Shader> blueShader;
long long int M = C ^ d % n; Ref<VertexArray> squareVA;
BK_INFO(M); Vec3 cameraPos = {0, 0, 0};
} float cameraSpeed = 5.0f;
float rotation = 0.0f;
float rotationSpeed = 30.0f;
};
void diffi() class Sandbox : public Application
{ {
long long int a, b, g, p, ga, gb, gab, gba; public:
a = 10030; Sandbox()
b = 10294; {
g = 10927; h_window->SetVsync(true);
p = prime_range(1000, 900)[3]; PushLayer(new TestLayer());
ga = g^a % p; }
gb = g^b % p; };
gab = ga^b % p;
gba = gb^a % p;
BK_INFO("a{0} b{1} g{2} p{3} ga{4} gb{5} gab{6} gba{7}", a, b, g, p, ga, gb, gab, gba);
}
int main()
{ Application* Bk::CreateApp(int argc, char** argv) {
Bk::Log::init("Bakacypher"); return new Sandbox();
diffi();
return 0;
} }

@ -1,11 +1,11 @@
{ {
"name": "Bakacrypt", "name": "graphics",
"author": "anulax1225", "author": "anulax1225",
"git": "", "git": "",
"packages": [ "packages": [
{ {
"author": "anulax1225", "author": "anulax1225",
"name": "bakatools" "name": "bakara"
} }
] ]
} }

@ -1,4 +1,4 @@
workspace "Bakacrypt" workspace "graphics"
architecture "x64" architecture "x64"
configurations { "Debug", "Release" } configurations { "Debug", "Release" }
startproject "App" startproject "App"
@ -9,6 +9,7 @@ workspace "Bakacrypt"
} }
linkgroups "On" linkgroups "On"
toolset "clang"
outputdir = "%{cfg.system}-%{cfg.architecture}-%{cfg.buildcfg}" outputdir = "%{cfg.system}-%{cfg.architecture}-%{cfg.buildcfg}"
include "dependencies.lua" include "dependencies.lua"

Loading…
Cancel
Save