aboutsummaryrefslogtreecommitdiff
path: root/src/content/content.cpp
blob: 66ef83d42bbfec76362f5512d7426bde565b39b3 (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
Minetest
Copyright (C) 2018 rubenwardy <rw@rubenwardy.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <fstream>
#include "content/content.h"
#include "content/subgames.h"
#include "content/mods.h"
#include "filesys.h"
#include "settings.h"

enum ContentType
{
	ECT_UNKNOWN,
	ECT_MOD,
	ECT_MODPACK,
	ECT_GAME,
	ECT_TXP
};

ContentType getContentType(const ContentSpec &spec)
{
	std::ifstream modpack_is((spec.path + DIR_DELIM + "modpack.txt").c_str());
	if (modpack_is.good()) {
		modpack_is.close();
		return ECT_MODPACK;
	}

	std::ifstream modpack2_is((spec.path + DIR_DELIM + "modpack.conf").c_str());
	if (modpack2_is.good()) {
		modpack2_is.close();
		return ECT_MODPACK;
	}

	std::ifstream init_is((spec.path + DIR_DELIM + "init.lua").c_str());
	if (init_is.good()) {
		init_is.close();
		return ECT_MOD;
	}

	std::ifstream game_is((spec.path + DIR_DELIM + "game.conf").c_str());
	if (game_is.good()) {
		game_is.close();
		return ECT_GAME;
	}

	std::ifstream txp_is((spec.path + DIR_DELIM + "texture_pack.conf").c_str());
	if (txp_is.good()) {
		txp_is.close();
		return ECT_TXP;
	}

	return ECT_UNKNOWN;
}

void parseContentInfo(ContentSpec &spec)
{
	std::string conf_path;

	switch (getContentType(spec)) {
	case ECT_MOD:
		spec.type = "mod";
		conf_path = spec.path + DIR_DELIM + "mod.conf";
		break;
	case ECT_MODPACK:
		spec.type = "modpack";
		conf_path = spec.path + DIR_DELIM + "modpack.conf";
		break;
	case ECT_GAME:
		spec.type = "game";
		conf_path = spec.path + DIR_DELIM + "game.conf";
		break;
	case ECT_TXP:
		spec.type = "txp";
		conf_path = spec.path + DIR_DELIM + "texture_pack.conf";
		break;
	default:
		spec.type = "unknown";
		break;
	}

	Settings conf;
	if (!conf_path.empty() && conf.readConfigFile(conf_path.c_str())) {
		if (conf.exists("name"))
			spec.name = conf.get("name");

		if (conf.exists("description"))
			spec.desc = conf.get("description");

		if (conf.exists("author"))
			spec.author = conf.get("author");

		if (conf.exists("release"))
			spec.release = conf.getS32("release");
	}

	if (spec.desc.empty()) {
		std::ifstream is((spec.path + DIR_DELIM + "description.txt").c_str());
		spec.desc = std::string((std::istreambuf_iterator<char>(is)),
				std::istreambuf_iterator<char>());
	}
}
ck(); - - if (!level && newTexture) - { - if (IsCompressed && !mipmapData) { - if (image->hasMipMaps()) - mipmapData = static_cast<u8*>(image->lock())+compressedImageSize; + if (IsCompressed) + { + glCompressedTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, image->getDimension().Width, + image->getDimension().Height, PixelFormat, compressedImageSize, source); + } else - HasMipMaps = false; + glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, image->getDimension().Width, + image->getDimension().Height, PixelFormat, PixelType, source); } - regenerateMipMapLevels(mipmapData); - - if (HasMipMaps) // might have changed in regenerateMipMapLevels + if (convert) { - // enable bilinear mipmap filter - GLint filteringMipMaps = GL_LINEAR_MIPMAP_NEAREST; - - if (filtering != GL_LINEAR) - filteringMipMaps = GL_NEAREST_MIPMAP_NEAREST; + tmpImage->unlock(); + tmpImage->drop(); + } + else + image->unlock(); + + if (glGetError() != GL_NO_ERROR) { + static bool warned = false; + if ((!retry) && (ColorFormat == ECF_A8R8G8B8)) { + + if (!warned) { + os::Printer::log("Your driver claims to support GL_BGRA but fails on trying to upload a texture, converting to GL_RGBA and trying again", ELL_ERROR); + warned = true; + } + } + else if (retry) { + os::Printer::log("Neither uploading texture as GL_BGRA nor, converted one using GL_RGBA succeeded", ELL_ERROR); + } + retry = !retry; + continue; + } else { + retry = false; + } - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filteringMipMaps); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); + if (!level && newTexture) + { + if (IsCompressed && !mipmapData) + { + if (image->hasMipMaps()) + mipmapData = static_cast<u8*>(image->lock())+compressedImageSize; + else + HasMipMaps = false; + } + + regenerateMipMapLevels(mipmapData); + + if (HasMipMaps) // might have changed in regenerateMipMapLevels + { + // enable bilinear mipmap filter + GLint filteringMipMaps = GL_LINEAR_MIPMAP_NEAREST; + + if (filtering != GL_LINEAR) + filteringMipMaps = GL_NEAREST_MIPMAP_NEAREST; + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filteringMipMaps); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); + } } - } - if (Driver->testGLError()) - os::Printer::log("Could not glTexImage2D", ELL_ERROR); + if (Driver->testGLError()) + os::Printer::log("Could not glTexImage2D", ELL_ERROR); + } + while(retry); } --- irrlicht/source/Irrlicht/COGLESTexture.cpp.orig 2014-06-25 00:28:50.820501856 +0200 +++ irrlicht/source/Irrlicht/COGLESTexture.cpp 2014-06-25 00:08:37.712544692 +0200 @@ -422,6 +422,9 @@ source = dest; } + //clear old error + glGetError(); + if (newTexture) { if (IsCompressed)