mirror of
https://github.com/allankoechke/raylib-cpp.git
synced 2026-12-01 01:18:52 +00:00
Add shader example and clean up (#152)
* Add shader example * Remove unused shaders * Clean up
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user