Add shader example and clean up (#152)

* Add shader example
* Remove unused shaders
* Clean up
This commit is contained in:
Rob Loach
2021-12-13 17:46:08 -05:00
committed by GitHub
parent 3279571bf4
commit bf2cb770ab
19 changed files with 334 additions and 96 deletions

View File

@@ -1,44 +1,59 @@
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include "raylib-cpp.hpp"
int main() {
// Vector
raylib::Vector2 position(50, 100);
assert(position.GetX() == position.x);
position.x = 150;
assert(position.GetX() == 150);
int main(int argc, char *argv[]) {
TraceLog(LOG_INFO, "TEST: raylib-cpp test");
// Addition operator.
raylib::Vector2 speed(10, 10);
position += speed;
assert(position.x == 160);
assert(raylib::Window::IsReady() == false);
// Get a path to where the executable is so file loading is relative.
std::string path = "";
if (argc > 0) {
path = GetDirectoryPath(argv[0]);
}
// Vector
{
raylib::Vector2 position(50, 100);
assert(position.GetX() == position.x);
position.x = 150;
assert(position.GetX() == 150);
position.SetX(300);
assert(position.GetX() == 300);
raylib::Vector2 speed(10, 10);
position += speed;
assert(position.x == 310);
assert(raylib::Window::IsReady() == false);
}
// Color
raylib::Color color = RED;
assert(color.ToInt() == ::ColorToInt(RED));
color = RAYWHITE;
assert(color.r == RAYWHITE.r);
{
raylib::Color color = RED;
assert(color.ToInt() == ::ColorToInt(RED));
color = RAYWHITE;
assert(color.r == RAYWHITE.r);
}
// Math
raylib::Vector2 direction(50, 50);
raylib::Vector2 newDirection = direction.Rotate(30);
std::cout << "Out: " << newDirection.x << std::endl;
assert((int)newDirection.x == 57);
{
raylib::Vector2 direction(50, 50);
raylib::Vector2 newDirection = direction.Rotate(30);
assert(((int)newDirection.x) == 57);
}
// raylib::GetDirectoryFiles()
std::vector<std::string> files = raylib::GetDirectoryFiles(::GetWorkingDirectory());
assert(files.size() > 3);
{
std::vector<std::string> files = raylib::GetDirectoryFiles(::GetWorkingDirectory());
assert(files.size() > 3);
}
// Sound
{
raylib::Sound sound("resources/weird.wav");
sound.Play();
raylib::Wave wave(path + "/resources/weird.wav");
assert(wave.IsLoaded());
}
std::cout << "Tests complete" << std::endl;
TraceLog(LOG_INFO, "TEST: raylib-cpp test complete");
return 0;
}