File size: 2,341 Bytes
dec7e7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* -*- tab-width: 4; -*- */
/* vi: set sw=2 ts=4 expandtab: */

/*
 * Copyright 2017-2020 Mark Callow, <khronos at callow dot im>.
 * SPDX-License-Identifier: Apache-2.0
 */

#ifndef GL3_LOAD_TEST_SAMPLE_H
#define GL3_LOAD_TEST_SAMPLE_H

#include <ktx.h>
#include "LoadTestSample.h"
#include "mygl.h"
#include "utils/GLMeshLoader.hpp"

#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))

class GL3LoadTestSample : public LoadTestSample {
  public:
    typedef uint64_t ticks_t;
    GL3LoadTestSample(uint32_t width, uint32_t height,
                     const char* const /*szArgs*/,
                     const std::string sBasePath)
           : LoadTestSample(width, height, sBasePath)
    {
    }

    virtual ~GL3LoadTestSample() { }
    virtual int doEvent(SDL_Event* event) { return LoadTestSample::doEvent(event); };
    virtual void resize(uint32_t width, uint32_t height) = 0;
    virtual void run(uint32_t msTicks) = 0;

    //virtual void getOverlayText(TextOverlay *textOverlay) { };

    typedef LoadTestSample* (*PFN_create)(uint32_t width, uint32_t height,
                                          const char* const szArgs,
                                          const std::string sBasePath);

  protected:
    using ShaderSource = std::vector<const GLchar*>;

    virtual void keyPressed(uint32_t /*keyCode*/) { }
    virtual void viewChanged() { }

    static bool contextSupportsSwizzle();

    std::string ktxfilename;
    int externalFile = 0;

    struct compressedTexFeatures {
        bool astc_ldr;
        bool astc_hdr;
        bool bc6h;
        bool bc7;
        bool etc1;
        bool etc2;
        bool bc3;
        bool pvrtc1;
        bool pvrtc_srgb;
        bool pvrtc2;
        bool rgtc;
    };

    static void determineCompressedTexFeatures(compressedTexFeatures& features);
    static GLint framebufferColorEncoding();
    void loadMesh(std::string filename, glMeshLoader::MeshBuffer& meshBuffer,
                  std::vector<glMeshLoader::VertexLayout> vertexLayout,
                  float scale);
    static void makeShader(GLenum type, ShaderSource& source, GLuint* shader);
    static void makeShader(GLenum type, const GLchar* const source,
                           GLuint* shader);
    static void makeProgram(GLuint vs, GLuint fs, GLuint* program);
};

#endif /* GL3_LOAD_TEST_SAMPLE_H */