shader-shark.cpp
author František Kučera <franta-hg@frantovo.cz>
Tue, 05 Dec 2023 22:55:25 +0100
branchv_0
changeset 20 0899e966993e
parent 0 bb715a82a8f1
permissions -rw-r--r--
process all X11 event waiting in the queue in the same cycle avoid so called glitches after continuous key press or X11 tunelled through SSH
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * ShaderShark
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
 * Copyright © 2023 František Kučera (Frantovo.cz, GlobalCode.info)
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, version 3 of the License.
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 *
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * GNU General Public License for more details.
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 *
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 */
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
#include <iostream>
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
#include <locale>
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <stdexcept>
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
#include <vector>
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
#include <string>
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
#include "CLIParser.h"
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
#include "Shark.h"
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
int main(int argc, char** argv) {
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
	setlocale(LC_ALL, "");
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
	std::cout << "ShaderShark for OpenGL" << std::endl;
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
	int result = 0;
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
	try {
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
		std::vector<std::string> arguments;
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
		for (int i = 1; i < argc; i++) arguments.push_back(argv[i]);
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
		CLIParser cliParser;
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
		Configuration cfg = cliParser.parse(arguments);
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
		Shark shaderShark(cfg);
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
		shaderShark.run();
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
	} catch (const std::exception& e) {
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
		std::cerr << "Exception: " << e.what() << std::endl;
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
		result = 1;
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
	} catch (...) {
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
		std::cerr << "Exception: unexpected" << std::endl;
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
		result = 2;
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
	}
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
	return result;
bb715a82a8f1 project skeleton
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
}