mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-28 07:45:40 +00:00
update assimp lib
This commit is contained in:
parent
03a348deb7
commit
d3f8fee74e
1725 changed files with 196314 additions and 62009 deletions
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "UTFConverter.h"
|
||||
|
||||
namespace AssimpSamples {
|
||||
namespace SharedCode {
|
||||
|
||||
typename UTFConverter::UTFConverterImpl UTFConverter::impl_;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms,
|
||||
with or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of the assimp team, nor the names of its
|
||||
contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior
|
||||
written permission of the assimp team.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef ASSIMP_SAMPLES_SHARED_CODE_UTFCONVERTER_H
|
||||
#define ASSIMP_SAMPLES_SHARED_CODE_UTFCONVERTER_H
|
||||
|
||||
#include <string>
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
|
||||
namespace AssimpSamples {
|
||||
namespace SharedCode {
|
||||
|
||||
// Used to convert between multibyte and unicode strings.
|
||||
class UTFConverter {
|
||||
using UTFConverterImpl = std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t>;
|
||||
public:
|
||||
UTFConverter(const char* s) :
|
||||
s_(s),
|
||||
ws_(impl_.from_bytes(s)) {
|
||||
}
|
||||
UTFConverter(const wchar_t* s) :
|
||||
s_(impl_.to_bytes(s)),
|
||||
ws_(s) {
|
||||
}
|
||||
UTFConverter(const std::string& s) :
|
||||
s_(s),
|
||||
ws_(impl_.from_bytes(s)) {
|
||||
}
|
||||
UTFConverter(const std::wstring& s) :
|
||||
s_(impl_.to_bytes(s)),
|
||||
ws_(s) {
|
||||
}
|
||||
inline const char* c_str() const {
|
||||
return s_.c_str();
|
||||
}
|
||||
inline const std::string& str() const {
|
||||
return s_;
|
||||
}
|
||||
inline const wchar_t* c_wstr() const {
|
||||
return ws_.c_str();
|
||||
}
|
||||
private:
|
||||
static UTFConverterImpl impl_;
|
||||
std::string s_;
|
||||
std::wstring ws_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ASSIMP_SAMPLES_SHARED_CODE_UTFCONVERTER_H
|
||||
|
|
@ -8,6 +8,9 @@ if ( MSVC )
|
|||
ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
|
||||
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
|
||||
REMOVE_DEFINITIONS( -DUNICODE -D_UNICODE )
|
||||
if ( MSVC_VERSION GREATER_EQUAL 1930 )
|
||||
ADD_DEFINITIONS( -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING=1 )
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
ADD_COMPILE_DEFINITIONS(SHADER_PATH="${CMAKE_CURRENT_SOURCE_DIR}/SimpleTexturedDirectx11/")
|
||||
|
|
@ -16,6 +19,7 @@ INCLUDE_DIRECTORIES(
|
|||
${Assimp_SOURCE_DIR}/include
|
||||
${Assimp_SOURCE_DIR}/code
|
||||
${SAMPLES_SHARED_CODE_DIR}
|
||||
${Assimp_SOURCE_DIR}/contrib/utf8cpp/source
|
||||
)
|
||||
|
||||
LINK_DIRECTORIES(
|
||||
|
|
@ -33,8 +37,6 @@ ADD_EXECUTABLE( assimp_simpletextureddirectx11 WIN32
|
|||
#SimpleTexturedDirectx11/VertexShader.hlsl
|
||||
SimpleTexturedDirectx11/main.cpp
|
||||
SimpleTexturedDirectx11/SafeRelease.hpp
|
||||
${SAMPLES_SHARED_CODE_DIR}/UTFConverter.cpp
|
||||
${SAMPLES_SHARED_CODE_DIR}/UTFConverter.h
|
||||
)
|
||||
|
||||
TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp_simpletextureddirectx11)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
// Written by IAS. :)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#include <assimp/types.h>
|
||||
|
||||
#include <Windows.h>
|
||||
#include <shellapi.h>
|
||||
#include <stdexcept>
|
||||
|
|
@ -21,8 +23,9 @@
|
|||
#include <dxgi1_2.h>
|
||||
#include <DirectXMath.h>
|
||||
#include <d3dcompiler.h>
|
||||
#include <utf8.h>
|
||||
|
||||
#include "ModelLoader.h"
|
||||
#include "UTFConverter.h"
|
||||
#include "SafeRelease.hpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
|
@ -33,7 +36,6 @@
|
|||
#endif // _MSC_VER
|
||||
|
||||
using namespace DirectX;
|
||||
using namespace AssimpSamples::SharedCode;
|
||||
|
||||
#define VERTEX_SHADER_FILE L"VertexShader.hlsl"
|
||||
#define PIXEL_SHADER_FILE L"PixelShader.hlsl"
|
||||
|
|
@ -50,10 +52,10 @@ struct ConstantBuffer {
|
|||
// ------------------------------------------------------------
|
||||
// Window Variables
|
||||
// ------------------------------------------------------------
|
||||
#define SCREEN_WIDTH 800
|
||||
#define SCREEN_HEIGHT 600
|
||||
static constexpr uint32_t SCREEN_WIDTH = 800;
|
||||
static constexpr uint32_t SCREEN_HEIGHT = 600;
|
||||
|
||||
const char g_szClassName[] = "directxWindowClass";
|
||||
constexpr char g_szClassName[] = "directxWindowClass";
|
||||
|
||||
static std::string g_ModelPath;
|
||||
|
||||
|
|
@ -154,8 +156,14 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/,
|
|||
}
|
||||
|
||||
// Retrieve the model file path.
|
||||
g_ModelPath = UTFConverter(argv[1]).str();
|
||||
std::wstring filename(argv[1]);
|
||||
|
||||
char *targetStart = new char[filename.size()+1];
|
||||
memset(targetStart, '\0', filename.size() + 1);
|
||||
|
||||
utf8::utf16to8(filename.c_str(), filename.c_str() + filename.size(), targetStart);
|
||||
g_ModelPath = targetStart;
|
||||
delete[] targetStart;
|
||||
free_command_line_allocated_memory();
|
||||
|
||||
WNDCLASSEX wc;
|
||||
|
|
@ -511,9 +519,9 @@ void InitPipeline()
|
|||
{
|
||||
ID3DBlob *VS, *PS;
|
||||
if(FAILED(CompileShaderFromFile(SHADER_PATH VERTEX_SHADER_FILE, 0, "main", "vs_4_0", &VS)))
|
||||
Throwanerror(UTFConverter(L"Failed to compile shader from file " VERTEX_SHADER_FILE).c_str());
|
||||
Throwanerror("Failed to compile shader from file");
|
||||
if(FAILED(CompileShaderFromFile(SHADER_PATH PIXEL_SHADER_FILE, 0, "main", "ps_4_0", &PS)))
|
||||
Throwanerror(UTFConverter(L"Failed to compile shader from file " PIXEL_SHADER_FILE).c_str());
|
||||
Throwanerror("Failed to compile shader from file ");
|
||||
|
||||
dev->CreateVertexShader(VS->GetBufferPointer(), VS->GetBufferSize(), nullptr, &pVS);
|
||||
dev->CreatePixelShader(PS->GetBufferPointer(), PS->GetBufferSize(), nullptr, &pPS);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ INCLUDE_DIRECTORIES(
|
|||
${OPENGL_INCLUDE_DIR}
|
||||
${GLUT_INCLUDE_DIR}
|
||||
${SAMPLES_SHARED_CODE_DIR}
|
||||
${Assimp_SOURCE_DIR}/contrib/utf8cpp/source
|
||||
)
|
||||
|
||||
LINK_DIRECTORIES(
|
||||
|
|
@ -30,8 +31,6 @@ LINK_DIRECTORIES(
|
|||
|
||||
ADD_EXECUTABLE( assimp_simpletexturedogl WIN32
|
||||
SimpleTexturedOpenGL/src/model_loading.cpp
|
||||
${SAMPLES_SHARED_CODE_DIR}/UTFConverter.cpp
|
||||
${SAMPLES_SHARED_CODE_DIR}/UTFConverter.h
|
||||
)
|
||||
|
||||
TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp_simpletexturedogl)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include <stdio.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <utf8.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4100) // Disable warning 'unreferenced formal parameter'
|
||||
|
|
@ -41,15 +42,14 @@
|
|||
#include <assimp/scene.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/LogStream.hpp>
|
||||
#include "UTFConverter.h"
|
||||
|
||||
// The default hard-coded path. Can be overridden by supplying a path through the command line.
|
||||
static std::string modelpath = "../../test/models/OBJ/spider.obj";
|
||||
|
||||
HGLRC hRC=nullptr; // Permanent Rendering Context
|
||||
HDC hDC=nullptr; // Private GDI Device Context
|
||||
HWND g_hWnd=nullptr; // Holds Window Handle
|
||||
HINSTANCE g_hInstance=nullptr; // Holds The Instance Of The Application
|
||||
HGLRC hRC = nullptr; // Permanent Rendering Context
|
||||
HDC hDC = nullptr; // Private GDI Device Context
|
||||
HWND g_hWnd = nullptr; // Holds Window Handle
|
||||
HINSTANCE g_hInstance = nullptr; // Holds The Instance Of The Application
|
||||
|
||||
bool keys[256]; // Array used for Keyboard Routine;
|
||||
bool active=TRUE; // Window Active Flag Set To TRUE by Default
|
||||
|
|
@ -69,8 +69,6 @@ GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f };
|
|||
GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
GLfloat LightPosition[]= { 0.0f, 0.0f, 15.0f, 1.0f };
|
||||
|
||||
|
||||
|
||||
// the global Assimp scene object
|
||||
const aiScene* g_scene = nullptr;
|
||||
GLuint scene_list = 0;
|
||||
|
|
@ -83,12 +81,8 @@ GLuint* textureIds; // pointer to texture Array
|
|||
// Create an instance of the Importer class
|
||||
Assimp::Importer importer;
|
||||
|
||||
using namespace AssimpSamples::SharedCode;
|
||||
|
||||
void createAILogger()
|
||||
{
|
||||
// Change this line to normal if you not want to analyse the import process
|
||||
//Assimp::Logger::LogSeverity severity = Assimp::Logger::NORMAL;
|
||||
void createAILogger() {
|
||||
// Change this line to normal if you not want to analyze the import process
|
||||
Assimp::Logger::LogSeverity severity = Assimp::Logger::VERBOSE;
|
||||
|
||||
// Create a logger instance for Console Output
|
||||
|
|
@ -101,62 +95,52 @@ void createAILogger()
|
|||
Assimp::DefaultLogger::get()->info("this is my info-call");
|
||||
}
|
||||
|
||||
void destroyAILogger()
|
||||
{
|
||||
// Kill it after the work is done
|
||||
void destroyAILogger() {
|
||||
Assimp::DefaultLogger::kill();
|
||||
}
|
||||
|
||||
void logInfo(std::string logString)
|
||||
{
|
||||
// Will add message to File with "info" Tag
|
||||
void logInfo(const std::string &logString) {
|
||||
Assimp::DefaultLogger::get()->info(logString.c_str());
|
||||
}
|
||||
|
||||
void logDebug(const char* logString)
|
||||
{
|
||||
// Will add message to File with "debug" Tag
|
||||
void logDebug(const char* logString) {
|
||||
Assimp::DefaultLogger::get()->debug(logString);
|
||||
}
|
||||
|
||||
|
||||
bool Import3DFromFile( const std::string& pFile)
|
||||
{
|
||||
bool Import3DFromFile( const std::string &filename) {
|
||||
// Check if file exists
|
||||
std::ifstream fin(pFile.c_str());
|
||||
if(!fin.fail())
|
||||
{
|
||||
fin.close();
|
||||
std::ifstream fin(filename.c_str());
|
||||
if(fin.fail()) {
|
||||
std::string message = "Couldn't open file: " + filename;
|
||||
std::wstring targetMessage;
|
||||
//utf8::utf8to16(message.c_str(), message.c_str() + message.size(), targetMessage);
|
||||
::MessageBox(nullptr, targetMessage.c_str(), L"Error", MB_OK | MB_ICONEXCLAMATION);
|
||||
logInfo(importer.GetErrorString());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(nullptr, UTFConverter("Couldn't open file: " + pFile).c_wstr() , TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
||||
logInfo( importer.GetErrorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
g_scene = importer.ReadFile(pFile, aiProcessPreset_TargetRealtime_Quality);
|
||||
|
||||
fin.close();
|
||||
|
||||
g_scene = importer.ReadFile(filename, aiProcessPreset_TargetRealtime_Quality);
|
||||
|
||||
// If the import failed, report it
|
||||
if(!g_scene)
|
||||
{
|
||||
if (g_scene == nullptr) {
|
||||
logInfo( importer.GetErrorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now we can access the file's contents.
|
||||
logInfo("Import of scene " + pFile + " succeeded.");
|
||||
logInfo("Import of scene " + filename + " succeeded.");
|
||||
|
||||
// We're done. Everything will be cleaned up by the importer destructor
|
||||
return true;
|
||||
}
|
||||
|
||||
// Resize And Initialize The GL Window
|
||||
void ReSizeGLScene(GLsizei width, GLsizei height)
|
||||
{
|
||||
void ReSizeGLScene(GLsizei width, GLsizei height) {
|
||||
// Prevent A Divide By Zero By
|
||||
if (height==0)
|
||||
{
|
||||
if (height == 0) {
|
||||
// Making Height Equal One
|
||||
height=1;
|
||||
}
|
||||
|
|
@ -174,43 +158,26 @@ void ReSizeGLScene(GLsizei width, GLsizei height)
|
|||
}
|
||||
|
||||
|
||||
std::string getBasePath(const std::string& path)
|
||||
{
|
||||
std::string getBasePath(const std::string& path) {
|
||||
size_t pos = path.find_last_of("\\/");
|
||||
return (std::string::npos == pos) ? "" : path.substr(0, pos + 1);
|
||||
}
|
||||
|
||||
void freeTextureIds()
|
||||
{
|
||||
textureIdMap.clear(); //no need to delete pointers in it manually here. (Pointers point to textureIds deleted in next step)
|
||||
void freeTextureIds() {
|
||||
// no need to delete pointers in it manually here. (Pointers point to textureIds deleted in next step)
|
||||
textureIdMap.clear();
|
||||
|
||||
if (textureIds)
|
||||
{
|
||||
if (textureIds) {
|
||||
delete[] textureIds;
|
||||
textureIds = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
int LoadGLTextures(const aiScene* scene)
|
||||
{
|
||||
int LoadGLTextures(const aiScene* scene) {
|
||||
freeTextureIds();
|
||||
|
||||
//ILboolean success;
|
||||
|
||||
/* Before calling ilInit() version should be checked. */
|
||||
/*if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION)
|
||||
{
|
||||
/// wrong DevIL version ///
|
||||
std::string err_msg = "Wrong DevIL version. Old devil.dll in system32/SysWow64?";
|
||||
char* cErr_msg = (char *) err_msg.c_str();
|
||||
abortGLInit(cErr_msg);
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
//ilInit(); /* Initialization of DevIL */
|
||||
|
||||
if (scene->HasTextures()) return 1;
|
||||
//abortGLInit("Support for meshes with embedded textures is not implemented");
|
||||
if (scene->HasTextures())
|
||||
return 1;
|
||||
|
||||
/* getTexture Filenames and Numb of Textures */
|
||||
for (unsigned int m=0; m<scene->mNumMaterials; m++)
|
||||
|
|
@ -230,14 +197,6 @@ int LoadGLTextures(const aiScene* scene)
|
|||
|
||||
const size_t numTextures = textureIdMap.size();
|
||||
|
||||
|
||||
/* array with DevIL image IDs */
|
||||
//ILuint* imageIds = NULL;
|
||||
// imageIds = new ILuint[numTextures];
|
||||
|
||||
/* generate DevIL Image IDs */
|
||||
// ilGenImages(numTextures, imageIds); /* Generation of numTextures image names */
|
||||
|
||||
/* create and fill array with GL texture ids */
|
||||
textureIds = new GLuint[numTextures];
|
||||
glGenTextures(static_cast<GLsizei>(numTextures), textureIds); /* Texture name generation */
|
||||
|
|
@ -248,29 +207,17 @@ int LoadGLTextures(const aiScene* scene)
|
|||
std::string basepath = getBasePath(modelpath);
|
||||
for (size_t i=0; i<numTextures; i++)
|
||||
{
|
||||
|
||||
//save IL image ID
|
||||
std::string filename = (*itr).first; // get filename
|
||||
(*itr).second = &textureIds[i]; // save texture id for filename in map
|
||||
itr++; // next texture
|
||||
|
||||
|
||||
//ilBindImage(imageIds[i]); /* Binding of DevIL image name */
|
||||
std::string fileloc = basepath + filename; /* Loading of image */
|
||||
//success = ilLoadImage(fileloc.c_str());
|
||||
int x, y, n;
|
||||
unsigned char *data = stbi_load(fileloc.c_str(), &x, &y, &n, STBI_rgb_alpha);
|
||||
|
||||
if (nullptr != data )
|
||||
{
|
||||
// Convert every colour component into unsigned byte.If your image contains
|
||||
// alpha channel you can replace IL_RGB with IL_RGBA
|
||||
//success = ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);
|
||||
/*if (!success)
|
||||
{
|
||||
abortGLInit("Couldn't convert image");
|
||||
return -1;
|
||||
}*/
|
||||
// Binding of texture name
|
||||
glBindTexture(GL_TEXTURE_2D, textureIds[i]);
|
||||
// redefine standard texture values
|
||||
|
|
@ -287,19 +234,18 @@ int LoadGLTextures(const aiScene* scene)
|
|||
glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
|
||||
glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
|
||||
stbi_image_free(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Error occurred */
|
||||
MessageBox(nullptr, UTFConverter("Couldn't load Image: " + fileloc).c_wstr(), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
||||
} else {
|
||||
/* Error occurred */
|
||||
const std::string message = "Couldn't load Image: " + fileloc;
|
||||
std::wstring targetMessage;
|
||||
wchar_t *tmp = new wchar_t[message.size() + 1];
|
||||
memset(tmp, L'\0', sizeof(wchar_t) *(message.size() + 1));
|
||||
utf8::utf8to16(message.c_str(), message.c_str() + message.size(), tmp);
|
||||
targetMessage = tmp;
|
||||
delete [] tmp;
|
||||
MessageBox(nullptr, targetMessage.c_str(), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
}
|
||||
// Because we have already copied image data into texture data we can release memory used by image.
|
||||
// ilDeleteImages(numTextures, imageIds);
|
||||
|
||||
// Cleanup
|
||||
//delete [] imageIds;
|
||||
//imageIds = NULL;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -312,7 +258,6 @@ int InitGL()
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glShadeModel(GL_SMOOTH); // Enables Smooth Shading
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
|
||||
|
|
@ -537,9 +482,7 @@ int DrawGLScene() //Here's where we do all the drawing
|
|||
|
||||
drawAiScene(g_scene);
|
||||
|
||||
//xrot+=0.3f;
|
||||
yrot+=0.2f;
|
||||
//zrot+=0.4f;
|
||||
yrot += 0.2f;
|
||||
|
||||
return TRUE; // okay
|
||||
}
|
||||
|
|
@ -591,8 +534,18 @@ void KillGLWindow() // Properly Kill The Window
|
|||
|
||||
GLboolean abortGLInit(const char* abortMessage)
|
||||
{
|
||||
KillGLWindow(); // Reset Display
|
||||
MessageBox(nullptr, UTFConverter(abortMessage).c_wstr(), TEXT("ERROR"), MB_OK|MB_ICONEXCLAMATION);
|
||||
// Reset Display
|
||||
KillGLWindow();
|
||||
const std::string message = abortMessage;
|
||||
std::wstring targetMessage;
|
||||
const size_t len = std::strlen(abortMessage) + 1;
|
||||
wchar_t *tmp = new wchar_t[len];
|
||||
memset(tmp, L'\0', len);
|
||||
utf8::utf8to16(message.c_str(), message.c_str() + message.size(), tmp);
|
||||
targetMessage = tmp;
|
||||
delete [] tmp;
|
||||
|
||||
MessageBox(nullptr, targetMessage.c_str(), TEXT("ERROR"), MB_OK|MB_ICONEXCLAMATION);
|
||||
return FALSE; // quit and return False
|
||||
}
|
||||
|
||||
|
|
@ -642,7 +595,8 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
|||
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
// If The Mode Fails, Offer Two Options. Quit Or Run In A Window.
|
||||
if (MessageBox(nullptr,TEXT("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"),TEXT("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
|
||||
if (MessageBox(nullptr,TEXT("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"),
|
||||
TEXT("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
|
||||
{
|
||||
fullscreen = FALSE; // Select Windowed Mode (Fullscreen = FALSE)
|
||||
}
|
||||
|
|
@ -669,9 +623,16 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
|||
|
||||
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size
|
||||
|
||||
if (nullptr == (g_hWnd=CreateWindowEx(dwExStyle, // Extended Style For The Window
|
||||
const size_t len = std::strlen(title) + 1;
|
||||
wchar_t *tmp = new wchar_t[len];
|
||||
memset(tmp, L'\0', sizeof(wchar_t) * len);
|
||||
utf8::utf8to16(title, title+len, tmp);
|
||||
std::wstring targetMessage = tmp;
|
||||
delete[] tmp;
|
||||
|
||||
if (nullptr == (g_hWnd = CreateWindowEx(dwExStyle, // Extended Style For The Window
|
||||
TEXT("OpenGL"), // Class Name
|
||||
UTFConverter(title).c_wstr(), // Window Title
|
||||
targetMessage.c_str(), // Window Title
|
||||
WS_CLIPSIBLINGS | // Required Window Style
|
||||
WS_CLIPCHILDREN | // Required Window Style
|
||||
dwStyle, // Selected WIndow Style
|
||||
|
|
@ -843,7 +804,11 @@ int WINAPI WinMain( HINSTANCE /*hInstance*/, // The instance
|
|||
if (argv != nullptr && argc > 1)
|
||||
{
|
||||
std::wstring modelpathW(argv[1]);
|
||||
modelpath = UTFConverter(modelpathW).str();
|
||||
char *tmp = new char[modelpathW.size() + 1];
|
||||
memset(tmp, '\0', modelpathW.size() + 1);
|
||||
utf8::utf16to8(modelpathW.c_str(), modelpathW.c_str() + modelpathW.size(), tmp);
|
||||
modelpath = tmp;
|
||||
delete[]tmp;
|
||||
}
|
||||
|
||||
if (!Import3DFromFile(modelpath))
|
||||
|
|
@ -871,7 +836,7 @@ int WINAPI WinMain( HINSTANCE /*hInstance*/, // The instance
|
|||
{
|
||||
if (msg.message==WM_QUIT)
|
||||
{
|
||||
done=TRUE;
|
||||
done = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue