File: texture.h

package info (click to toggle)
embree 3.12.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 27,412 kB
  • sloc: cpp: 173,822; xml: 3,737; ansic: 2,955; python: 1,628; sh: 480; makefile: 193; csh: 42
file content (69 lines) | stat: -rw-r--r-- 1,490 bytes parent folder | download
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
// Copyright 2009-2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#pragma once

#if defined(ISPC)

enum TEXTURE_FORMAT {
    Texture_RGBA8        = 1,
    Texture_RGB8         = 2,
    Texture_FLOAT32      = 3,
  };

struct Texture {
  int width;
  int height;
  int format;
  int bytesPerTexel;
  int width_mask;
  int height_mask;
  void* data;
};

#else

#include "../default.h"
#include "../image/image.h"

namespace embree
{
  struct Texture // FIXME: should be derived from SceneGraph::Node
  {
    enum Format {
      INVALID = 0,
      RGBA8   = 1,
      RGB8    = 2,
      FLOAT32 = 3,
    };
    
  public:
    Texture (); 
    Texture (Ref<Image> image, const std::string fileName); 
    Texture (unsigned width, unsigned height, const Format format, const char* in = nullptr);
    ~Texture ();

  private:
    Texture (const Texture& other) DELETED; // do not implement
    Texture& operator= (const Texture& other) DELETED; // do not implement

  public:
    static const char* format_to_string(const Format format);
    static Format string_to_format(const std::string& str);
    static unsigned getFormatBytesPerTexel(const Format format);

    static std::shared_ptr<Texture> load(const FileName& fileName);
    static void clearTextureCache();
    
  public:
    unsigned width;
    unsigned height;    
    Format format;
    unsigned bytesPerTexel;
    unsigned width_mask;
    unsigned height_mask;
    void* data;
    std::string fileName;
  };
}
#endif