File size: 1,786 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
/* -*- tab-width: 4; -*- */
/* vi: set sw=2 ts=4 expandtab: */

/*
 * Copyright 2018-2022 Mark Callow.
 * SPDX-License-Identifier: Apache-2.0
 */

/**
 * @file
 * @brief   GLLoadTestSample derived class for encoding a texture and texturing a cube with it.
 *
 * @author Mark Callow, github.com/MarkCallow.
 */

#ifndef ENCODE_TEXTURE_H
#define ENCODE_TEXTURE_H

#include "GL3LoadTestSample.h"

#include <iostream>

class EncodeTexture : public GL3LoadTestSample {
  public:
    EncodeTexture(uint32_t width, uint32_t height,
                const char* const szArgs,
                const std::string sBasePath);
    ~EncodeTexture();

    virtual void resize(uint32_t width, uint32_t height);
    virtual void run(uint32_t msTicks);

    //virtual void getOverlayText(GLTextOverlay *textOverlay);

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

  protected:
    void processArgs(std::string sArgs);

    GLuint gnTexture;
    GLuint gnTexProg;

    GLuint gnVao;
    GLuint gnVbo[2];

    GLint gulMvMatrixLocTP;
    GLint gulPMatrixLocTP;
    GLint gulSamplerLocTP;

    bool bInitialized;
    ktx_transcode_fmt_e transcodeTarget;
    enum encode_fmt_e { EF_ASTC = 1, EF_ETC1S = 2, EF_UASTC = 3 };
    friend std::ostream& operator<<(std::ostream& os, encode_fmt_e format);
    encode_fmt_e encodeTarget;
};

inline std::ostream& operator<<(std::ostream& os, EncodeTexture::encode_fmt_e format)
{
    switch (format) {
      case EncodeTexture::EF_ASTC:
        os << "astc";
        break;
      case EncodeTexture::EF_ETC1S:
        os << "etc1s";
        break;
      case EncodeTexture::EF_UASTC:
        os << "uastc";
        break;
    }
    return os;
}
#endif /* ENCODE_TEXTURE_H */