aboutsummaryrefslogtreecommitdiff
path: root/BuddhaTest/include/Helpers.h
blob: ad1430556001edd08571dad1ed075d705e014706 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <vector>
#include <stdio.h> //includes FILE typedef

namespace Helpers
{
	GLuint LoadShaders(const char * vertex_file_path, const char * fragment_file_path);
	GLuint LoadComputeShader(const char * compute_file_path);

    void WriteOutputPNG(const std::vector<uint32_t>& data, unsigned int width, unsigned int height);

    /** Wraps around a C file descriptor. Libpng could be taught to use C++ streams, but I'm too lazy and rather wrap this ugly thing up, so it gets cleaned... */
    class ScopedCFileDescriptor
    {
    public:
        ScopedCFileDescriptor(const char *path, const char *mode);
        ~ScopedCFileDescriptor();
        FILE * Get() const;
        bool IsValid() const;
    private:
        FILE * Descriptor;
    };
}