graphic
anulax1225 ago%!(EXTRA string=7 months)
parent 1f5f756508
commit d0457d9624
  1. 4
      .gitignore
  2. BIN
      app/assets/textures/warhammer.jpg
  3. 169
      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)
{
//Sieve of Eratosthenes algo from https://www.baeldung.com/cs/prime-number-algorithms
std::vector<long long int> primes;
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++) class TestLayer : public Layer
if (primes_check[i])
{ {
long long int j = i * i; public:
while (j <= max) TestLayer() : Layer("Test")
{ {
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; )"));
float squareVertices[7 * 3] = {
-0.5f, -0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
0.5f, 0.5f, 0.0f,
-0.5f, 0.5f, 0.0f,
};
squareVA = Ref<VertexArray>(VertexArray::Create());
Ref<VertexBuffer> squareVB = Ref<VertexBuffer>(VertexBuffer::Create(squareVertices, sizeof(squareVertices)));
squareVB->SetLayout({
{ ShaderType::Float3, "aPos" }
});
squareVA->AddVertexBuffer(squareVB);
u32 squareIndices[6] = { 0, 1, 2, 0, 2, 3 };
squareVA->SetIndexbuffer(Ref<IndexBuffer>(IndexBuffer::Create(squareIndices, sizeof(squareIndices) / sizeof(u32))));
} }
long long int power(long long int val, long long int power) void OnUpdate(DeltaTime dt) override
{ {
long long int res = val; if(Keyboard::KeyDown(KeyCode::W))
for(long long int i = 1; i < power; i++) res *= val; cameraPos.y += cameraSpeed * dt;
return res; 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);
void rsa() Renderer::BeginScene(camera);
{ RenderCommand::Clear(0.1, 0.1, 0.1, 1.0);
auto primes = prime_range(100, 50); for(int x = 0; x < 20; x += 2)
//long long int p = primes[random(primes.size())]; for(int y = 0; y < 20; y += 2)
//long long int q = primes[random(primes.size())]; Renderer::Submit(squareVA, blueShader, Math::translate(Mat4(1.0f), Vec3(x, y, 0)));
long long int p = 13;
long long int q = 17;
long long int n = p * q;
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; private:
long long int j = 0; OrthographicCamera camera = { -10.0f, 10.0f, -10.0f, 10.0f };
while (j < 2) Ref<Shader> blueShader;
Ref<VertexArray> squareVA;
Vec3 cameraPos = {0, 0, 0};
float cameraSpeed = 5.0f;
float rotation = 0.0f;
float rotationSpeed = 30.0f;
};
class Sandbox : public Application
{ {
d += 1; public:
if (1 == (e * d) % phi) Sandbox()
{ {
j += 1; h_window->SetVsync(true);
} PushLayer(new TestLayer());
} }
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;
long long int C = power(msg, e) % n;
BK_INFO("{0} {1}", C, power(msg, e));
long long int M = C ^ d % n;
BK_INFO(M);
}
void diffi()
{
long long int a, b, g, p, ga, gb, gab, gba;
a = 10030;
b = 10294;
g = 10927;
p = prime_range(1000, 900)[3];
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);
} Application* Bk::CreateApp(int argc, char** argv) {
return new Sandbox();
int main()
{
Bk::Log::init("Bakacypher");
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