Changeset View
Changeset View
Standalone View
Standalone View
source/lib/tex/tex_codec.cpp
/* Copyright (C) 2014 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* "Software"), to deal in the Software without restriction, including | * "Software"), to deal in the Software without restriction, including | ||||
* without limitation the rights to use, copy, modify, merge, publish, | * without limitation the rights to use, copy, modify, merge, publish, | ||||
* distribute, sublicense, and/or sell copies of the Software, and to | * distribute, sublicense, and/or sell copies of the Software, and to | ||||
* permit persons to whom the Software is furnished to do so, subject to | * permit persons to whom the Software is furnished to do so, subject to | ||||
* the following conditions: | * the following conditions: | ||||
Show All 21 Lines | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include "lib/allocators/shared_ptr.h" // ArrayDeleter | #include "lib/allocators/shared_ptr.h" // ArrayDeleter | ||||
#include "tex.h" | #include "tex.h" | ||||
// Statically allocate all of the codecs... | // Statically allocate all of the codecs... | ||||
TexCodecDds DdsCodec; | TexCodecDds DdsCodec; | ||||
TexCodecPng PngCodec; | TexCodecPng PngCodec; | ||||
TexCodecJpg JpgCodec; | |||||
TexCodecTga TgaCodec; | TexCodecTga TgaCodec; | ||||
TexCodecBmp BmpCodec; | TexCodecBmp BmpCodec; | ||||
// Codecs will be searched in this order | // Codecs will be searched in this order | ||||
static const ITexCodec *codecs[] = {(ITexCodec *)&DdsCodec, (ITexCodec *)&PngCodec, | static const ITexCodec *codecs[] = {(ITexCodec *)&DdsCodec, (ITexCodec *)&PngCodec, | ||||
(ITexCodec *)&TgaCodec, (ITexCodec *)&BmpCodec}; | (ITexCodec *)&JpgCodec, (ITexCodec *)&TgaCodec, (ITexCodec *)&BmpCodec}; | ||||
static const int codecs_len = sizeof(codecs) / sizeof(ITexCodec*); | static const int codecs_len = sizeof(codecs) / sizeof(ITexCodec*); | ||||
// find codec that recognizes the desired output file extension, | // find codec that recognizes the desired output file extension, | ||||
// or return ERR::TEX_UNKNOWN_FORMAT if unknown. | // or return ERR::TEX_UNKNOWN_FORMAT if unknown. | ||||
// note: does not raise a warning because it is used by | // note: does not raise a warning because it is used by | ||||
// tex_is_known_extension. | // tex_is_known_extension. | ||||
Status tex_codec_for_filename(const OsPath& extension, const ITexCodec** c) | Status tex_codec_for_filename(const OsPath& extension, const ITexCodec** c) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator