This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #include <chrono> | |
| double GetTime() | |
| { | |
| static auto start = std::chrono::high_resolution_clock::now(); | |
| auto now = std::chrono::high_resolution_clock::now(); | |
| return std::chrono::duration_cast<std::chrono::duration<double, std::ratio<1, 1>>>(now - start).count(); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | android { | |
| defaultConfig { | |
| ndk { | |
| moduleName 'AdamasNative' | |
| cFlags "-std=c++11" | |
| ldLibs "log" | |
| ldLibs "GLESv3" | |
| abiFilters "armeabi", "mips", "x86" | |
| stl "gnustl_static" | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #version 310 es | |
| layout(location = 0) in vec3 position; | |
| layout(location = 1) in vec3 normal; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | static const int POSITION_INDEX = 0; | |
| static const int NORMAL_INDEX = 1; | |
| glBindAttribLocation(program, POSITION_INDEX, "position"); | |
| glBindAttribLocation(program, NORMAL_INDEX, "normal"); | |
| glLinkProgram(program); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | GLint positionIndex = glGetAttribLocation(program, "position"); | |
| GLint normalIndex = glGetAttribLocation(program, "normal"); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #ifdef OPENGL_OR_ES30 | |
| // ES 3.0 | |
| glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, w, h, 0, GL_RGBA, GL_HALF_FLOAT, nullptr); | |
| #else | |
| // ES 2.0 | |
| glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_HALF_FLOAT_OES, nullptr); | |
| #endif | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | cbuffer perObject : register(b0) | |
| { | |
| row_major matrix invVP; | |
| } | |
| TextureCube texCube : register(t0); | |
| SamplerState samplerState : register(s0); | |
| struct VsToPs | |
| { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | float4 mainPS(VsToPs inp) : SV_Target | |
| { | |
| float2 scale = float2(4.0f / 3.0f, 1) * 3; // scale & aspect ratio | |
| float2 plane = inp.screenPos.xy * scale; | |
| float3 dir = float3(plane.x * 2, plane.y * 2, -1 + dot(plane, plane)) / (1 + dot(plane, plane)); | |
| return texCube.Sample(samplerState, dir.xzy); // y is upper | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | float4 mainPS(VsToPs inp) : SV_Target | |
| { | |
| float2 scale = float2(4.0f / 3.0f, 1) * 3; // scale & aspect ratio | |
| float2 plane = inp.screenPos.xy * scale; | |
| float3 dir = float3(plane.x * 2, plane.y * 2, -1 + dot(plane, plane)) / (1 + dot(plane, plane)); | |
| dir = dir.xzy; // y is upper | |
| float longitude = atan2(dir.x, dir.z) * (180 / 3.14159265f); | |
| float latitude = asin(dir.y) * (180 / 3.14159265f); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | struct DDSHeader { | |
| uint32_t h3[3]; | |
| int h, w; | |
| uint32_t h2[2]; | |
| int mipCnt; | |
| uint32_t h13[13]; | |
| uint32_t fourcc, bitsPerPixel, rMask, gMask, bMask, aMask, caps1, caps2; | |
| bool IsCubeMap() const { return caps2 == 0xFE00; } | |
| int GetArraySize() const { return IsCubeMap() ? 6 : 1; } | |
| int GetMipCnt() const { return std::max(mipCnt, 1); } |