<commit_before>﻿#include "FTTextureDDS.h"
#include <FTEngine.h>
#include <Util/FTFileManager.h>

#include <string.h> // for strncmp

FTTextureDDS::FTTextureDDS(const std::string& filename) {
    texture_id_ = loadDDS(filename);
}

FTTextureDDS::~FTTextureDDS() {
    glDeleteTextures(1, &texture_id_);
}

#define FOURCC_DXT1 0x31545844 // Equivalent to "DXT1" in ASCII
#define FOURCC_DXT3 0x33545844 // Equivalent to "DXT3" in ASCII
#define FOURCC_DXT5 0x35545844 // Equivalent to "DXT5" in ASCII

// Code from http://www.opengl-tutorial.org/beginners-tutorials/tutorial-5-a-textured-cube/
GLuint FTTextureDDS::loadDDS(const std::string& provided_path) {
    unsigned char header[124];

    auto imagepath = FTEngine::getFileManager()->getPathToFile(provided_path);
    FTAssert(imagepath != "", "File %s not found", provided_path.c_str());

    FILE* fp;<commit_msg>FTTextureDDS.cpp: work around lack of fopen_s on non Win32 platforms<commit_after>﻿#include "FTTextureDDS.h"
#include <FTEngine.h>
#include <Util/FTFileManager.h>

#include <string.h> // for strncmp

FTTextureDDS::FTTextureDDS(const std::string& filename) {
    texture_id_ = loadDDS(filename);
}

FTTextureDDS::~FTTextureDDS() {
    glDeleteTextures(1, &texture_id_);
}

#define FOURCC_DXT1 0x31545844 // Equivalent to "DXT1" in ASCII
#define FOURCC_DXT3 0x33545844 // Equivalent to "DXT3" in ASCII
#define FOURCC_DXT5 0x35545844 // Equivalent to "DXT5" in ASCII

/* HACK: no fopen_s on non-Windows systems */
#ifndef WIN32
#   define fopen_s(pFile,filename,mode) ((*(pFile))=fopen((filename),(mode)))==NULL
#endif

// Code from http://www.opengl-tutorial.org/beginners-tutorials/tutorial-5-a-textured-cube/
GLuint FTTextureDDS::loadDDS(const std::string& provided_path) {
    unsigned char header[124];

    auto imagepath = FTEngine::getFileManager()->getPathToFile(provided_path);
    FTAssert(imagepath != "", "File %s not found", provided_path.c_str());

    FILE* fp;
{'fraction_non_alphanumeric': 0.13704276146316333, 'fraction_numerical': 0.04121586810922205, 'mean_word_length': 5.34640522875817, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3619044', 'n_tokens_mistral': 785, 'n_tokens_neox': 711, 'n_words': 146}