Skip to content

Commit d89c68a

Browse files
Adding WIP examples
1 parent 76e1be1 commit d89c68a

File tree

2 files changed

+168
-0
lines changed

2 files changed

+168
-0
lines changed

Examples/test.cpp

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/* runcpp2
2+
3+
Dependencies:
4+
- Name: ssLogger
5+
Platforms: [Windows, Linux, MacOS]
6+
Source:
7+
Type: Git
8+
Value: "https://github.com/Neko-Box-Coder/ssLogger.git"
9+
# LibraryType: Static
10+
LibraryType: Header
11+
IncludePaths:
12+
- "Include"
13+
14+
# (Optional if LibraryType is Header) Link properties of the dependency
15+
# LinkProperties:
16+
# # Properties for searching the library binary for the profile
17+
# "g++":
18+
# # The library names to be searched for when linking against the script
19+
# SearchLibraryNames: ["ssLogger"]
20+
#
21+
# # (Optional) The library names to be excluded from being searched
22+
# ExcludeLibraryNames: ["ssLogger_SRC"]
23+
#
24+
# # The path (relative to the dependency folder) to be searched for the dependency binaries
25+
# SearchDirectories: ["./build"]
26+
#
27+
# # (Optional) Additional link options for this dependency
28+
# AdditionalLinkOptions:
29+
# All: []
30+
31+
32+
# (Optional) List of setup commands for the supported platforms
33+
Setup:
34+
# Setup commands for the specified platform
35+
All:
36+
# Setup commands for the specified profile.
37+
# All commands are run in the dependency folder
38+
"g++":
39+
- "git submodule update --init --recursive"
40+
- "mkdir build"
41+
- "cd build && cmake .."
42+
- "cd build && cmake --build . -j 16"
43+
*/
44+
45+
46+
#include "ssLogger/ssLogSwitches.hpp"
47+
48+
#define ssLOG_USE_SOURCE 0
49+
#if !ssLOG_USE_SOURCE
50+
#include "ssLogger/ssLogInit.hpp"
51+
#endif
52+
53+
#include "ssLogger/ssLog.hpp"
54+
55+
#include <iostream>
56+
#include <chrono>
57+
58+
int main(int argc, char* argv[])
59+
{
60+
std::cout << "Hello World" << std::endl;
61+
62+
for(int i = 0; i < argc; ++i)
63+
std::cout << "Arg" << i << ": " << argv[i] << std::endl;
64+
65+
#if ssLOG_USE_SOURCE
66+
ssLOG_LINE("Source dependency is working!!!");
67+
#else
68+
ssLOG_LINE("Header only dependency is working!!!");
69+
#endif
70+
71+
int CheckCounter = 5;
72+
ssLOG_FATAL("Test fatal: " << CheckCounter);
73+
ssLOG_ERROR("Test error: " << CheckCounter);
74+
ssLOG_WARNING("Test warning: " << CheckCounter);
75+
ssLOG_INFO("Test info: " << CheckCounter);
76+
ssLOG_DEBUG("Test debug: " << CheckCounter);
77+
78+
for(int i = 0; i < 10000; ++i)
79+
{
80+
ssLOG_LINE("Logging test: " << i);
81+
std::this_thread::sleep_for(std::chrono::milliseconds(10));
82+
}
83+
84+
85+
86+
return 0;
87+
}

Examples/testSDL.cpp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/* runcpp2
2+
3+
# (Optional) The list of dependencies needed by the script
4+
Dependencies:
5+
# Dependency name
6+
- Name: SDL2
7+
8+
# Supported platforms of the dependency
9+
Platforms: [Unix]
10+
11+
# The source of getting the dependency
12+
Source:
13+
Type: Local
14+
Value: "./dummy"
15+
16+
# Library Type (Static, Object, Shared, Header)
17+
LibraryType: Shared
18+
19+
# (Optional if LibraryType is Header) Link properties of the dependency
20+
LinkProperties:
21+
# Properties for searching the library binary for the profile
22+
"g++":
23+
# The library names to be searched for when linking against the script
24+
SearchLibraryNames: []
25+
26+
# (Optional) The library names to be excluded from being searched
27+
ExcludeLibraryNames: []
28+
29+
# The path (relative to the dependency folder) to be searched for the dependency binaries
30+
SearchDirectories: []
31+
32+
# (Optional) Additional link options for this dependency
33+
AdditionalLinkOptions:
34+
# Applies to all platforms (Can be changed to Linux, MacOS, Windows, Unix, etc.)
35+
Unix: ["-lSDL2"]
36+
*/
37+
38+
39+
#include <SDL2/SDL.h>
40+
41+
#include <iostream>
42+
43+
const int SCREEN_WIDTH = 800;
44+
const int SCREEN_HEIGHT = 600;
45+
46+
int main(int arc, char ** argv)
47+
{
48+
49+
SDL_Window* window = nullptr;
50+
51+
if (SDL_Init( SDL_INIT_VIDEO ) < 0) {
52+
std::cout << "SDL could not initialize! SDL_Error: " << SDL_GetError() << std::endl;
53+
} else {
54+
55+
window = SDL_CreateWindow(
56+
"SDL2 Demo",
57+
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
58+
SCREEN_WIDTH, SCREEN_HEIGHT,
59+
SDL_WINDOW_SHOWN
60+
);
61+
}
62+
63+
bool quit = false;
64+
65+
SDL_Event e;
66+
67+
while (!quit)
68+
{
69+
while (SDL_PollEvent(&e) != 0)
70+
{
71+
if (e.type == SDL_QUIT)
72+
quit = true;
73+
}
74+
}
75+
76+
SDL_DestroyWindow(window);
77+
78+
SDL_Quit();
79+
80+
return 0;
81+
}

0 commit comments

Comments
 (0)