Merge pull request #216 from 4jcraft/feat/iggy-dev
Some checks are pending
Publish Documentation / build (push) Waiting to run
Publish Documentation / deploy (push) Blocked by required conditions
Build (Linux, x86_64) / build-linux (push) Waiting to run
Build (Linux, x86_64) / build-linux-debug (push) Waiting to run
Clang Format / clang-format (push) Waiting to run

feat: Iggy on x86_64 linux
This commit is contained in:
ffqq 2026-03-16 01:59:12 +03:00 committed by GitHub
commit 8ef0e9572b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
64 changed files with 5092 additions and 618 deletions

29
.gitignore vendored
View file

@ -4,40 +4,19 @@ builddir/
.cache/
.idea/
build_meson/
cmake-build-debug/
# meson subprojects (git clone'd on build)
/subprojects/*
!/subprojects/*.wrap
# Nix flake output
result
# Final binaries and platform output
/Linux/
/x64/
# CMake generated artifacts
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
Makefile
# Meson generated artifacts (inside source tree, e.g. per-subdir)
meson-private/
meson-info/
meson-logs/
# Compiler/linker intermediates
*.o
*.a
*.so
*.so.*
*.out
*.d
compile_commands.json
.clangd
# ----- Scratch / legacy -----
oldimpl/
# ----- IDE / editor -----
.cache/
.idea/

View file

@ -48,7 +48,8 @@ static const int s_watchedKeys[] = {
SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3,
SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6,
SDL_SCANCODE_7, SDL_SCANCODE_8, SDL_SCANCODE_9,
};
SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_C,
SDL_SCANCODE_V};
static const int s_watchedKeyCount =
(int)(sizeof(s_watchedKeys) / sizeof(s_watchedKeys[0]));
@ -352,13 +353,13 @@ int C_4JInput::GetHotbarSlotPressed(int iPad) {
case ACTION_MENU_PAGEDOWN: \
return KFN(SDL_SCANCODE_PAGEDOWN); \
case ACTION_MENU_OK: \
return KFN(SDL_SCANCODE_RETURN) || CFN(SDL_CONTROLLER_BUTTON_A); \
return KFN(SDL_SCANCODE_RETURN) || KFN(SDL_SCANCODE_Z) || CFN(SDL_CONTROLLER_BUTTON_A); \
case ACTION_MENU_CANCEL: \
return KFN(SDL_SCANCODE_ESCAPE) || CFN(SDL_CONTROLLER_BUTTON_B); \
return KFN(SDL_SCANCODE_ESCAPE) || KFN(SDL_SCANCODE_X) || CFN(SDL_CONTROLLER_BUTTON_B); \
case ACTION_MENU_A: \
return KFN(SDL_SCANCODE_Z) || CFN(SDL_CONTROLLER_BUTTON_A); \
return KFN(SDL_SCANCODE_Z) || KFN(SDL_SCANCODE_RETURN) || CFN(SDL_CONTROLLER_BUTTON_A); \
case ACTION_MENU_B: \
return KFN(SDL_SCANCODE_X) || CFN(SDL_CONTROLLER_BUTTON_B); \
return KFN(SDL_SCANCODE_X) || KFN(SDL_SCANCODE_ESCAPE) || CFN(SDL_CONTROLLER_BUTTON_B); \
case ACTION_MENU_X: \
return KFN(SDL_SCANCODE_C) || CFN(SDL_CONTROLLER_BUTTON_X); \
case ACTION_MENU_Y: \

View file

@ -20,8 +20,8 @@ static SDL_Window* s_window = nullptr;
static SDL_GLContext s_glContext = nullptr;
static bool s_shouldClose = false;
static int s_textureLevels = 1;
static int s_windowWidth = 0;
static int s_windowHeight = 0;
static int s_windowWidth = 1920;
static int s_windowHeight = 1080;
// We set Window size with the monitor's res, so that I can get rid of ugly
// values.
@ -34,20 +34,14 @@ static void SetInitialWindowSize() {
h = (int)(mode.h * 0.4f);
}
}
if (w > 0 && h > 0) {
s_windowWidth = w;
s_windowHeight = h;
} else {
s_windowWidth = 1280;
s_windowHeight = 720;
}
if (w > 0 && h > 0) { s_windowWidth = w; s_windowHeight = h; }
else { s_windowWidth = 1920; s_windowHeight = 1080; }
}
// (can't believe i had to rewrite this, i literally did it TODAY.)
static int s_reqWidth = 0;
static int s_reqHeight = 0;
// When we'll have a settings system in order, we'll set bool to that value,
// right now it's hardcoded.
static bool s_fullscreen = false;
static int s_reqWidth = 1920;
static int s_reqHeight = 1080;
// When we'll have a settings system in order, we'll set bool to that value, right now it's hardcoded.
static bool s_fullscreen = false;
static pthread_key_t s_glCtxKey;
static pthread_once_t s_glCtxKeyOnce = PTHREAD_ONCE_INIT;

View file

@ -142,6 +142,9 @@ unsigned int C4JStorage::GetAvailableDLCCount(int iPad) { return 0; }
C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad,
int (*Func)(void*, int, int),
void* lpParam) {
if (Func) {
Func(lpParam, 0, iPad);
}
return EDLC_NoInstalledDLC;
}
XCONTENT_DATA& C4JStorage::GetDLC(unsigned int dw) { return s_dummyContentData; }

View file

@ -324,7 +324,7 @@ void Minecraft::init() {
// if (options.languageCode != null) {
// Language.getInstance().loadLanguage(options.languageCode);
// //
//font.setEnforceUnicodeSheet("true".equalsIgnoreCase(I18n.get("language.enforceUnicode")));
// font.setEnforceUnicodeSheet("true".equalsIgnoreCase(I18n.get("language.enforceUnicode")));
// font.setEnforceUnicodeSheet(Language.getInstance().isSelectedLanguageIsUnicode());
// font.setBidirectional(Language.isBidirectional(options.languageCode));
// }
@ -507,7 +507,7 @@ File Minecraft::getWorkingDirectory(const std::wstring& applicationName) {
}
// #elif defined(_MACOS)
// workingDirectory = new File(userHome, "Library/Application
//Support/" + applicationName);
// Support/" + applicationName);
#else
workingDirectory = new File(userHome, applicationName + L'/');
#endif
@ -1079,7 +1079,7 @@ std::shared_ptr<MultiplayerLocalPlayer> Minecraft::createExtraLocalPlayer(
// loaded "Mass Effect World". Move this check to
// ClientConnection::handleMovePlayer
// // 4J-PB - can't call this when this function is called
//from the qnet thread (GetGameStarted will be false)
// from the qnet thread (GetGameStarted will be false)
// if(app.GetGameStarted())
// {
// ui.CloseUIScenes(idx);
@ -1839,7 +1839,7 @@ void Minecraft::run_middle() {
timer->advanceTime();
}
__int64 beforeTickTime = System::nanoTime();
//__int64 beforeTickTime = System::nanoTime();
for (int i = 0; i < timer->ticks; i++) {
bool bLastTimerTick = (i == (timer->ticks - 1));
// 4J-PB - the tick here can run more than once, and this is a
@ -1923,7 +1923,7 @@ void Minecraft::run_middle() {
// SparseDataStorage::tick();
// // 4J added
}
__int64 tickDuraction = System::nanoTime() - beforeTickTime;
//__int64 tickDuraction = System::nanoTime() - beforeTickTime;
MemSect(31);
checkGlError(L"Pre render");
MemSect(0);
@ -1981,13 +1981,12 @@ void Minecraft::run_middle() {
// capture the save thumbnail
app.CaptureSaveThumbnail();
break;
default:
break;
}
}
}
}
#ifdef __linux__
#ifdef _ENABLEIGGY
// On Linux, Iggy Flash UI is not available. If no players were
// rendered (menu / title-screen state), call GameRenderer
// directly so mc->screen draws.
@ -1998,6 +1997,7 @@ void Minecraft::run_middle() {
gameRenderer->render(timer->a, true);
}
#endif
// If there's an unoccupied quadrant, then clear that to black
if (unoccupiedQuadrant > -1) {
// render a logo
@ -2029,6 +2029,17 @@ void Minecraft::run_middle() {
}
glFlush();
/* 4J - removed
if (!Display::isActive())
{
if (fullscreen)
{
this->toggleFullScreen();
}
Sleep(10);
}
*/
/* 4J - removed
if (!Display::isActive())
{
@ -4596,8 +4607,8 @@ void Minecraft::main() {
// if(Item::items[i] != NULL)
// {
// wprintf(L"<xs:enumeration
//value=\"%d\"><xs:annotation><xs:documentation>%ls</xs:documentation></xs:annotation></xs:enumeration>\n",
//i, app.GetString( Item::items[i]->getDescriptionId() ));
// value=\"%d\"><xs:annotation><xs:documentation>%ls</xs:documentation></xs:annotation></xs:enumeration>\n",
// i, app.GetString( Item::items[i]->getDescriptionId() ));
// }
//}
@ -4608,8 +4619,8 @@ void Minecraft::main() {
// if(Tile::tiles[i] != NULL)
// {
// wprintf(L"<xs:enumeration
//value=\"%d\"><xs:annotation><xs:documentation>%ls</xs:documentation></xs:annotation></xs:enumeration>\n",
//i, app.GetString( Tile::tiles[i]->getDescriptionId() ));
// value=\"%d\"><xs:annotation><xs:documentation>%ls</xs:documentation></xs:annotation></xs:enumeration>\n",
// i, app.GetString( Tile::tiles[i]->getDescriptionId() ));
// }
// }
//__debugbreak();
@ -4704,9 +4715,10 @@ int Minecraft::maxSupportedTextureSize() {
// for (int texSize = 16384; texSize > 0; texSize >>= 1) {
// GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, texSize,
//texSize, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); final
//int width = GL11.glGetTexLevelParameteri(GL11.GL_PROXY_TEXTURE_2D, 0,
//GL11.GL_TEXTURE_WIDTH); if (width != 0) { return texSize;
// texSize, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
// final int width = GL11.glGetTexLevelParameteri(GL11.GL_PROXY_TEXTURE_2D,
// 0, GL11.GL_TEXTURE_WIDTH); if (width != 0) { return
// texSize;
// }
// }
// return -1;
@ -4716,7 +4728,7 @@ void Minecraft::delayTextureReload() { reloadTextures = true; }
__int64 Minecraft::currentTimeMillis() {
return System::currentTimeMillis(); //(Sys.getTime() * 1000) /
//Sys.getTimerResolution();
// Sys.getTimerResolution();
}
/*void Minecraft::handleMouseDown(int button, bool down)

View file

@ -21,7 +21,7 @@ UIComponent_DebugUIMarketingGuide::UIComponent_DebugUIMarketingGuide(int iPad, v
value[0].number = (F64)4;
#elif defined __PSVITA__
value[0].number = (F64)5;
#elif defined _WINDOWS64
#elif defined _WINDOWS64 || defined __linux__
value[0].number = (F64)0;
#endif
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetPlatform , 1 , value );
@ -30,4 +30,4 @@ UIComponent_DebugUIMarketingGuide::UIComponent_DebugUIMarketingGuide(int iPad, v
std::wstring UIComponent_DebugUIMarketingGuide::getMoviePath()
{
return L"DebugUIMarketingGuide";
}
}

View file

@ -323,11 +323,13 @@ void UIComponent_Tooltips::_SetTooltip(unsigned int iToolTipId, const std::wstri
value[0].type = IGGY_DATATYPE_number;
value[0].number = iToolTipId;
const std::u16string convLabel = convWstringToU16string(label);
value[1].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[1].string16 = stringVal;
value[2].type = IGGY_DATATYPE_boolean;

View file

@ -32,13 +32,15 @@ void UIControl_Base::tick()
//app.DebugPrintf("Calling SetLabel - '%ls'\n", m_label.c_str());
m_bLabelChanged = false;
const std::u16string convLabel = convWstringToU16string(m_label);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)m_label.c_str();
stringVal.length = m_label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_setLabelFunc , 1 , value );
@ -54,13 +56,15 @@ void UIControl_Base::setLabel(const std::wstring &label, bool instant, bool forc
{
m_bLabelChanged = false;
const std::u16string convLabel = convWstringToU16string(m_label);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)m_label.c_str();
stringVal.length = m_label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_setLabelFunc , 1 , value );
@ -92,10 +96,13 @@ void UIControl_Base::setAllPossibleLabels(int labelCount, wchar_t labels[][256])
IggyDataValue *value = new IggyDataValue[labelCount];
IggyStringUTF16 * stringVal = new IggyStringUTF16[labelCount];
for(unsigned int i = 0; i < labelCount; ++i)
{
stringVal[i].string = (IggyUTF16 *)labels[i];
stringVal[i].length = wcslen(labels[i]);
std::vector<std::u16string> conv;
conv.reserve(labelCount);
for (int i = 0; i < labelCount; ++i) {
conv.push_back(convWstringToU16string(labels[i]));
stringVal[i].string = conv[i].c_str();
stringVal[i].length = (S32)conv[i].length();
value[i].type = IGGY_DATATYPE_string_UTF16;
value[i].string16 = stringVal[i];
}

View file

@ -18,9 +18,11 @@ void UIControl_BitmapIcon::setTextureName(const std::wstring &iconName)
IggyDataValue result;
IggyDataValue value[1];
const std::u16string convName = convWstringToU16string(iconName);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)iconName.c_str();
stringVal.length = iconName.length();
stringVal.string = convName.c_str();
stringVal.length = convName.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcSetTextureName , 1 , value );

View file

@ -22,13 +22,15 @@ void UIControl_Button::init(const std::wstring &label, int id)
m_label = label;
m_id = id;
const std::u16string convLabel = convWstringToU16string(label);
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;

View file

@ -98,9 +98,11 @@ void UIControl_ButtonList::addItem(const std::wstring &label, int data)
IggyDataValue result;
IggyDataValue value[2];
const std::u16string convLabel = convWstringToU16string(label);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
@ -151,9 +153,11 @@ void UIControl_ButtonList::setButtonLabel(int iButtonId, const std::wstring &lab
value[0].type = IGGY_DATATYPE_number;
value[0].number = iButtonId;
const std::u16string convLabel = convWstringToU16string(label);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[1].type = IGGY_DATATYPE_string_UTF16;
value[1].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcSetButtonLabel, 2 , value );

View file

@ -27,13 +27,15 @@ void UIControl_CheckBox::init(const std::wstring &label, int id, bool checked)
m_id = id;
m_bChecked = checked;
const std::u16string convLabel = convWstringToU16string(label);
IggyDataValue result;
IggyDataValue value[3];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;

View file

@ -39,9 +39,11 @@ void UIControl_DLCList::addItem(const std::wstring &label, bool showTick, int iI
IggyDataValue result;
IggyDataValue value[3];
const std::u16string convLabel = convWstringToU16string(label);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16 *)label.c_str();
stringVal.length = (S32)label.length();
stringVal.string = convLabel.c_str();
stringVal.length = (S32)convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;

View file

@ -22,12 +22,14 @@ bool UIControl_DynamicLabel::setupControl(UIScene *scene, IggyValuePath *parent,
void UIControl_DynamicLabel::addText(const std::wstring &text, bool bLastEntry)
{
const std::u16string convText = convWstringToU16string(text);
IggyDataValue result;
IggyDataValue value[2];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)text.c_str();
stringVal.length = text.length();
stringVal.string = convText.c_str();
stringVal.length = convText.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
@ -95,4 +97,4 @@ S32 UIControl_DynamicLabel::GetRealHeight()
iRealHeight = (S32)result.number;
}
return iRealHeight;
}
}

View file

@ -21,13 +21,15 @@ void UIControl_Label::init(const std::wstring &label)
{
m_label = label;
const std::u16string convLabel = convWstringToU16string(label);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 1 , value );
}
@ -35,6 +37,7 @@ void UIControl_Label::init(const std::wstring &label)
void UIControl_Label::init(const std::string &label)
{
m_label = convStringToWstring(label);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF8;

View file

@ -53,15 +53,19 @@ void UIControl_LeaderboardList::setupTitles(const std::wstring &rank, const std:
IggyDataValue result;
IggyDataValue value[2];
const std::u16string convRank = convWstringToU16string(rank);
IggyStringUTF16 stringVal0;
stringVal0.string = (IggyUTF16*)rank.c_str();
stringVal0.length = rank.length();
stringVal0.string = convRank.c_str();
stringVal0.length = convRank.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal0;
const std::u16string convGamertag = convWstringToU16string(gamertag);
IggyStringUTF16 stringVal1;
stringVal1.string = (IggyUTF16*)gamertag.c_str();
stringVal1.length = gamertag.length();
stringVal1.string = convGamertag.c_str();
stringVal1.length = convGamertag.length();
value[1].type = IGGY_DATATYPE_string_UTF16;
value[1].string16 = stringVal1;
@ -125,18 +129,22 @@ void UIControl_LeaderboardList::addDataSet(bool bLast, int iId, int iRank, const
value[2].type = IGGY_DATATYPE_number;
value[2].number = iRank;
const std::u16string convGamertag = convWstringToU16string(gamertag);
IggyStringUTF16 stringVal0;
stringVal0.string = (IggyUTF16*)gamertag.c_str();
stringVal0.length = gamertag.length();
stringVal0.string = convGamertag.c_str();
stringVal0.length = convGamertag.length();
value[3].type = IGGY_DATATYPE_string_UTF16;
value[3].string16 = stringVal0;
value[4].type = IGGY_DATATYPE_boolean;
value[4].boolval = bDisplayMessage;
const std::u16string convCol0 = convWstringToU16string(col0);
IggyStringUTF16 stringVal1;
stringVal1.string = (IggyUTF16*)col0.c_str();
stringVal1.length = col0.length();
stringVal1.string = convCol0.c_str();
stringVal1.length = convCol0.length();
value[5].type = IGGY_DATATYPE_string_UTF16;
value[5].string16 = stringVal1;
@ -146,9 +154,11 @@ void UIControl_LeaderboardList::addDataSet(bool bLast, int iId, int iRank, const
}
else
{
const std::u16string convCol1 = convWstringToU16string(col1);
IggyStringUTF16 stringVal2;
stringVal2.string = (IggyUTF16*)col1.c_str();
stringVal2.length = col1.length();
stringVal2.string = convCol1.c_str();
stringVal2.length = convCol1.length();
value[6].type = IGGY_DATATYPE_string_UTF16;
value[6].string16 = stringVal2;
}
@ -159,9 +169,11 @@ void UIControl_LeaderboardList::addDataSet(bool bLast, int iId, int iRank, const
}
else
{
const std::u16string convCol2 = convWstringToU16string(col2);
IggyStringUTF16 stringVal3;
stringVal3.string = (IggyUTF16*)col2.c_str();
stringVal3.length = col2.length();
stringVal3.string = convCol2.c_str();
stringVal3.length = convCol2.length();
value[7].type = IGGY_DATATYPE_string_UTF16;
value[7].string16 = stringVal3;
}
@ -172,9 +184,11 @@ void UIControl_LeaderboardList::addDataSet(bool bLast, int iId, int iRank, const
}
else
{
const std::u16string convCol3 = convWstringToU16string(col3);
IggyStringUTF16 stringVal4;
stringVal4.string = (IggyUTF16*)col3.c_str();
stringVal4.length = col3.length();
stringVal4.string = convCol3.c_str();
stringVal4.length = convCol3.length();
value[8].type = IGGY_DATATYPE_string_UTF16;
value[8].string16 = stringVal4;
}
@ -185,9 +199,11 @@ void UIControl_LeaderboardList::addDataSet(bool bLast, int iId, int iRank, const
}
else
{
const std::u16string convCol4 = convWstringToU16string(col4);
IggyStringUTF16 stringVal5;
stringVal5.string = (IggyUTF16*)col4.c_str();
stringVal5.length = col4.length();
stringVal5.string = convCol4.c_str();
stringVal5.length = convCol4.length();
value[9].type = IGGY_DATATYPE_string_UTF16;
value[9].string16 = stringVal5;
}
@ -198,9 +214,11 @@ void UIControl_LeaderboardList::addDataSet(bool bLast, int iId, int iRank, const
}
else
{
const std::u16string convCol5 = convWstringToU16string(col5);
IggyStringUTF16 stringVal6;
stringVal6.string = (IggyUTF16*)col5.c_str();
stringVal6.length = col5.length();
stringVal6.string = convCol5.c_str();
stringVal6.length = convCol5.length();
value[10].type = IGGY_DATATYPE_string_UTF16;
value[10].string16 = stringVal6;
}
@ -211,9 +229,11 @@ void UIControl_LeaderboardList::addDataSet(bool bLast, int iId, int iRank, const
}
else
{
const std::u16string convCol6 = convWstringToU16string(col6);
IggyStringUTF16 stringVal7;
stringVal7.string = (IggyUTF16*)col6.c_str();
stringVal7.length = col6.length();
stringVal7.string = convCol6.c_str();
stringVal7.length = convCol6.length();
value[11].type = IGGY_DATATYPE_string_UTF16;
value[11].string16 = stringVal7;
}
@ -235,4 +255,4 @@ void UIControl_LeaderboardList::SetTouchFocus(S32 iX, S32 iY, bool bRepeat)
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie(), &result, getIggyValuePath(), m_funcSetTouchFocus, 3 , value );
}
#endif
#endif

View file

@ -19,9 +19,11 @@ void UIControl_PlayerList::addItem(const std::wstring &label, int iPlayerIcon, i
IggyDataValue result;
IggyDataValue value[4];
const std::u16string convLabel = convWstringToU16string(label);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = (S32)label.length();
stringVal.string = convLabel.c_str();
stringVal.length = (S32)convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;

View file

@ -31,13 +31,15 @@ void UIControl_Progress::init(const std::wstring &label, int id, int min, int ma
m_max = max;
m_current = current;
const std::u16string convLabel = convWstringToU16string(label);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 1 , value );
@ -81,4 +83,4 @@ void UIControl_Progress::showBar(bool show)
value[0].boolval = show;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_showBarFunc , 1 , value );
}
}
}

View file

@ -59,9 +59,11 @@ void UIControl_SaveList::addItem(const std::string &label, const std::wstring &i
value[1].type = IGGY_DATATYPE_number;
value[1].number = m_itemCount;
const std::u16string convName = convWstringToU16string(iconName);
IggyStringUTF16 stringVal2;
stringVal2.string = (IggyUTF16*)iconName.c_str();
stringVal2.length = iconName.length();
stringVal2.string = convName.c_str();
stringVal2.length = convName.length();
value[2].type = IGGY_DATATYPE_string_UTF16;
value[2].string16 = stringVal2;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_addNewItemFunc , 3 , value );
@ -72,18 +74,22 @@ void UIControl_SaveList::addItem(const std::wstring &label, const std::wstring &
IggyDataValue result;
IggyDataValue value[3];
const std::u16string convLabel = convWstringToU16string(label);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = (S32)label.length();
stringVal.string = convLabel.c_str();
stringVal.length = (S32)convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = m_itemCount;
const std::u16string convName = convWstringToU16string(iconName);
IggyStringUTF16 stringVal2;
stringVal2.string = (IggyUTF16*)iconName.c_str();
stringVal2.length = iconName.length();
stringVal2.string = convName.c_str();
stringVal2.length = convName.length();
value[2].type = IGGY_DATATYPE_string_UTF16;
value[2].string16 = stringVal2;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_addNewItemFunc , 3 , value );
@ -97,9 +103,11 @@ void UIControl_SaveList::setTextureName(int iId, const std::wstring &iconName)
value[0].type = IGGY_DATATYPE_number;
value[0].number = iId;
const std::u16string convName = convWstringToU16string(iconName);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)iconName.c_str();
stringVal.length = iconName.length();
stringVal.string = convName.c_str();
stringVal.length = convName.length();
value[1].type = IGGY_DATATYPE_string_UTF16;
value[1].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_funcSetTextureName , 2 , value );

View file

@ -30,13 +30,15 @@ void UIControl_Slider::init(const std::wstring &label, int id, int min, int max,
m_max = max;
m_current = current;
const std::u16string convLabel = convWstringToU16string(label);
IggyDataValue result;
IggyDataValue value[5];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;

View file

@ -31,13 +31,15 @@ void UIControl_SpaceIndicatorBar::init(const std::wstring &label, int id, __int6
m_min = min;
m_max = max;
const std::u16string convLabel = convWstringToU16string(label);
IggyDataValue result;
IggyDataValue value[1];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_initFunc , 1 , value );
@ -119,4 +121,4 @@ void UIControl_SpaceIndicatorBar::setSaveGameOffset(float offset)
value[0].type = IGGY_DATATYPE_number;
value[0].number = m_currentOffset;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath() , m_setSaveGameOffsetFunc , 1 , value );
}
}

View file

@ -25,13 +25,15 @@ void UIControl_TextInput::init(const std::wstring &label, int id)
m_label = label;
m_id = id;
const std::u16string convLabel = convWstringToU16string(label);
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;

View file

@ -28,13 +28,15 @@ void UIControl_TexturePackList::init(const std::wstring &label, int id)
m_label = label;
m_id = id;
const std::u16string convLabel = convWstringToU16string(label);
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].string16 = stringVal;
value[1].type = IGGY_DATATYPE_number;
@ -57,6 +59,8 @@ void UIControl_TexturePackList::init(const std::wstring &label, int id)
void UIControl_TexturePackList::addPack(int id, const std::wstring &textureName)
{
const std::u16string convName = convWstringToU16string(textureName);
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
@ -65,8 +69,8 @@ void UIControl_TexturePackList::addPack(int id, const std::wstring &textureName)
value[1].type = IGGY_DATATYPE_string_UTF16;
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)textureName.c_str();
stringVal.length = textureName.length();
stringVal.string = convName.c_str();
stringVal.length = convName.length();
value[1].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( m_parentScene->getMovie() , &result, getIggyValuePath(), m_addPackFunc ,2 , value );
}

View file

@ -89,6 +89,7 @@ static void RADLINK WarningCallback(void *user_callback_data, Iggy *player, Iggy
use for debugging, otherwise debugging errors in the
ActionScript 3 code in your Flash content will be very
difficult! */
app.DebugPrintf(app.USER_SR, "[Iggy] ");
app.DebugPrintf(app.USER_SR, message);
app.DebugPrintf(app.USER_SR, "\n");
break;
@ -173,7 +174,7 @@ UIController::UIController()
#endif
// 4J Stu - This is a bit of a hack until we change the Minecraft initialisation to store the proper screen size for other platforms
#if defined _WINDOWS64 || defined _DURANGO || defined __ORBIS__
#if defined _WINDOWS64 || defined _DURANGO || defined __ORBIS__ || defined(__linux__)
m_fScreenWidth = 1920.0f;
m_fScreenHeight = 1080.0f;
m_bScreenWidthSetup = true;
@ -425,7 +426,7 @@ void UIController::loadSkins()
platformSkinPath = L"skinPS3.swf";
#elif defined __PSVITA__
platformSkinPath = L"skinVita.swf";
#elif defined _WINDOWS64
#elif defined(_WINDOWS64) || defined(__linux__)
if(m_fScreenHeight==1080.0f)
{
platformSkinPath = L"skinHDWin.swf";
@ -477,7 +478,7 @@ void UIController::loadSkins()
m_iggyLibraries[eLibrary_Default] = loadSkin(L"skin.swf", L"skin.swf");
#endif
#if ( defined(_WINDOWS64) || defined(_DURANGO) || defined(__ORBIS__) )
#if ( defined(_WINDOWS64) || defined(_DURANGO) || defined(__ORBIS__) || defined(__linux__))
#if defined(_WINDOWS64)
// 4J Stu - Load the 720/480 skins so that we have something to fallback on during development
@ -511,14 +512,16 @@ void UIController::loadSkins()
IggyLibrary UIController::loadSkin(const std::wstring &skinPath, const std::wstring &skinName)
{
IggyLibrary lib = IGGY_INVALID_LIBRARY;
// 4J Stu - We need to load the platformskin before the normal skin, as the normal skin requires some elements from the platform skin
if(!skinPath.empty() && app.hasArchiveFile(skinPath))
{
byteArray baFile = app.getArchiveFile(skinPath);
lib = IggyLibraryCreateFromMemoryUTF16( (IggyUTF16 *)skinName.c_str() , (void *)baFile.data, baFile.length, NULL );
const std::u16string convSkinName = convWstringToU16string(skinName);
lib = IggyLibraryCreateFromMemoryUTF16( convSkinName.data() , (void *)baFile.data, baFile.length, NULL );
delete[] baFile.data;
#ifdef _DEBUG
#ifdef _DEBUG
IggyMemoryUseInfo memoryInfo;
rrbool res;
int iteration = 0;
@ -558,7 +561,7 @@ void UIController::ReloadSkin()
m_iggyLibraries[i] = IGGY_INVALID_LIBRARY;
}
#ifdef _WINDOWS64
#if defined _WINDOWS64 || defined __linux__
// 4J Stu - Don't load on a thread on windows. I haven't investigated this in detail, so a quick fix
reloadSkinThreadProc(this);
#else
@ -605,7 +608,7 @@ int UIController::reloadSkinThreadProc(void* lpParam)
controller->m_groups[eUIGroup_Fullscreen]->ReloadAll();
// 4J Stu - Don't do this on windows, as we never navigated forwards to start with
#ifndef _WINDOW64
#if ! (defined _WINDOWS64 || defined __linux__)
controller->NavigateBack(0, false, eUIScene_COUNT, eUILayer_Tooltips);
#endif
LeaveCriticalSection(&ms_reloadSkinCS);
@ -1200,6 +1203,8 @@ void UIController::setupCustomDrawGameState()
RenderManager.StartFrame();
#elif defined __PSVITA__
RenderManager.StartFrame();
#elif defined __linux__
RenderManager.StartFrame();
#elif defined __ORBIS__
RenderManager.StartFrame(false);
// Set up a viewport for the render that matches Iggy's own viewport, apart form using an opengl-style z-range (Iggy uses a DX-style range on PS4), so
@ -2538,7 +2543,7 @@ void UIController::setFontCachingCalculationBuffer(int length)
draw call is not large enough, Iggy will crash or otherwise behave
incorrectly.
*/
#if defined __ORBIS__ || defined _DURANGO || defined _WIN64
#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __linux__
static const int CHAR_SIZE = 24;
#else
static const int CHAR_SIZE = 16;

View file

@ -507,7 +507,9 @@ IggyName UIScene::registerFastName(const std::wstring &name)
}
else
{
var = IggyPlayerCreateFastName ( getMovie() , (IggyUTF16 *)name.c_str() , -1 );
const std::u16string convName = convWstringToU16string(name);
var = IggyPlayerCreateFastName ( getMovie() , (IggyUTF16 *)convName.c_str() , -1 );
m_fastNames[name] = var;
}
return var;
@ -718,10 +720,21 @@ void UIScene::_customDrawSlotControl(CustomDrawData *region, int iPad, std::shar
float scaleX = bwidth / 16.0f;
float scaleY = bheight / 16.0f;
// 4jcraft: make sure we cull the back to not make transparent blocks (like
// leaves) look weird
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
// 4jcraft: needed for transparency in the item renders (like in the
// crafting menu)
if (fAlpha < 1) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
glEnable(GL_RESCALE_NORMAL);
glPushMatrix();
Lighting::turnOnGui();
glRotatef(120, 1, 0, 0);
Lighting::turnOn();
glPopMatrix();
float pop = item->popTime;
@ -768,6 +781,10 @@ void UIScene::_customDrawSlotControl(CustomDrawData *region, int iPad, std::shar
Lighting::turnOff();
glDisable(GL_RESCALE_NORMAL);
glDisable(GL_CULL_FACE);
if (fAlpha < 1) {
glDisable(GL_BLEND);
}
}
// 4J Stu - Not threadsafe
@ -992,8 +1009,7 @@ bool UIScene::allowRepeat(int key)
void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
{
if(wcscmp((wchar_t *)call->function_name.string,L"handlePress")==0)
{
if(std::char_traits<char16_t>::compare(call->function_name.string, u"handlePress", 12) == 0) {
if(call->num_arguments != 2)
{
app.DebugPrintf("Callback for handlePress did not have the correct number of arguments\n");
@ -1012,7 +1028,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
}
handlePress(call->arguments[0].number, call->arguments[1].number);
}
else if(wcscmp((wchar_t *)call->function_name.string,L"handleFocusChange")==0)
else if(std::char_traits<char16_t>::compare(call->function_name.string, u"handleFocusChange", 18) == 0)
{
if(call->num_arguments != 2)
{
@ -1032,7 +1048,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
}
_handleFocusChange(call->arguments[0].number, call->arguments[1].number);
}
else if(wcscmp((wchar_t *)call->function_name.string,L"handleInitFocus")==0)
else if(std::char_traits<char16_t>::compare(call->function_name.string, u"handleInitFocus", 16) == 0)
{
if(call->num_arguments != 2)
{
@ -1052,7 +1068,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
}
_handleInitFocus(call->arguments[0].number, call->arguments[1].number);
}
else if(wcscmp((wchar_t *)call->function_name.string,L"handleCheckboxToggled")==0)
else if(std::char_traits<char16_t>::compare(call->function_name.string, u"handleCheckboxToggled", 22) == 0)
{
if(call->num_arguments != 2)
{
@ -1072,7 +1088,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
}
handleCheckboxToggled(call->arguments[0].number, call->arguments[1].boolval);
}
else if(wcscmp((wchar_t *)call->function_name.string,L"handleSliderMove")==0)
else if(std::char_traits<char16_t>::compare(call->function_name.string, u"handleSliderMove", 17) == 0)
{
if(call->num_arguments != 2)
{
@ -1092,7 +1108,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
}
handleSliderMove(call->arguments[0].number, call->arguments[1].number);
}
else if(wcscmp((wchar_t *)call->function_name.string,L"handleAnimationEnd")==0)
else if(std::char_traits<char16_t>::compare(call->function_name.string, u"handleAnimationEnd", 19) == 0)
{
if(call->num_arguments != 0)
{
@ -1104,7 +1120,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
}
handleAnimationEnd();
}
else if(wcscmp((wchar_t *)call->function_name.string,L"handleSelectionChanged")==0)
else if(std::char_traits<char16_t>::compare(call->function_name.string, u"handleSelectionChanged", 23) == 0)
{
if(call->num_arguments != 1)
{
@ -1124,7 +1140,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
}
handleSelectionChanged(call->arguments[0].number);
}
else if(wcscmp((wchar_t *)call->function_name.string,L"handleRequestMoreData")==0)
else if(std::char_traits<char16_t>::compare(call->function_name.string, u"handleRequestMoreData", 22) == 0)
{
if(call->num_arguments == 0)
{
@ -1151,7 +1167,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call)
handleRequestMoreData(call->arguments[0].number, call->arguments[1].boolval);
}
}
else if(wcscmp((wchar_t *)call->function_name.string,L"handleTouchBoxRebuild")==0)
else if(std::char_traits<char16_t>::compare(call->function_name.string, u"handleTouchBoxRebuild", 22) == 0)
{
handleTouchBoxRebuild();
}
@ -1246,3 +1262,25 @@ bool UIScene::isReadyToDelete()
{
return true;
}
int UIScene::parseSlotId(const char16_t *s) {
// must be nonnull, must start with 'slot_', first char after the underscore must be a digit
if (!s ||
(s[0] != u's' || s[1] != u'l' || s[2] != u'o' || s[3] != u't' ||
s[4] != u'_') ||
(s[5] < u'0' || s[5] > u'9')) {
return -1;
}
int i = 5;
int id = 0;
// keep consuming digits until we reach a non-digit. each digit scales the existing id value
// by 10 plus the actual digit value. (this is referred to as a 'number' by the way)
while (s[i] >= u'0' && s[i] <= u'9') {
id = id * 10 + (s[i] - u'0');
i++;
}
return id;
}

View file

@ -269,4 +269,6 @@ protected:
size_t GetCallbackUniqueId();
virtual bool isReadyToDelete();
static int parseSlotId(const char16_t *s);
};

View file

@ -222,15 +222,14 @@ void UIScene_AbstractContainerMenu::customDraw(IggyCustomDrawCallbackRegion *reg
if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return;
std::shared_ptr<ItemInstance> item = nullptr;
if(wcscmp((wchar_t *)region->name,L"pointerIcon")==0)
if(std::char_traits<char16_t>::compare(region->name, u"pointerIcon", 11) == 0)
{
m_cacheSlotRenders = false;
item = pMinecraft->localplayers[m_iPad]->inventory->getCarried();
}
else
{
int slotId = -1;
swscanf((wchar_t*)region->name,L"slot_%d",&slotId);
int slotId = parseSlotId(region->name);
if (slotId == -1)
{
app.DebugPrintf("This is not the control we are looking for\n");

View file

@ -360,9 +360,11 @@ void UIScene_AnvilMenu::setCostLabel(const std::wstring &label, bool canAfford)
IggyDataValue result;
IggyDataValue value[2];
const std::u16string convLabel = convWstringToU16string(label);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;

View file

@ -436,11 +436,10 @@ void UIScene_CraftingMenu::customDraw(IggyCustomDrawCallbackRegion *region)
if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return;
std::shared_ptr<ItemInstance> item = nullptr;
int slotId = -1;
float alpha = 1.0f;
bool decorations = true;
bool inventoryItem = false;
swscanf((wchar_t*)region->name,L"slot_%d",&slotId);
int slotId = parseSlotId(region->name);
if (slotId == -1)
{
app.DebugPrintf("This is not the control we are looking for\n");

View file

@ -642,9 +642,11 @@ void UIScene_Credits::setNextLabel(const std::wstring &label, ECreditTextTypes s
IggyDataValue result;
IggyDataValue value[3];
const std::u16string convLabel = convWstringToU16string(label);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;

View file

@ -120,6 +120,7 @@ void UIScene_DebugOverlay::customDraw(IggyCustomDrawCallbackRegion *region)
if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return;
int itemId = -1;
// 4jcraft TODO: UB on our platform since this casts char16_t* to wchar_t*
swscanf((wchar_t*)region->name,L"item_%d",&itemId);
if (itemId == -1 || itemId > Item::ITEM_NUM_COUNT || Item::items[itemId] == NULL)
{

View file

@ -250,7 +250,7 @@ void UIScene_EnchantingMenu::customDraw(IggyCustomDrawCallbackRegion *region)
if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return;
if(wcscmp((wchar_t *)region->name,L"EnchantmentBook")==0)
if(std::char_traits<char16_t>::compare(region->name, u"EnchantmentBook", 15) == 0)
{
// Setup GDraw, normal game render states and matrices
CustomDrawData *customDrawRegion = ui.setupCustomDraw(this,region);
@ -263,8 +263,7 @@ void UIScene_EnchantingMenu::customDraw(IggyCustomDrawCallbackRegion *region)
}
else
{
int slotId = -1;
swscanf((wchar_t*)region->name,L"slot_Button%d",&slotId);
int slotId = parseSlotId(region->name);
if(slotId >= 0)
{
// Setup GDraw, normal game render states and matrices

View file

@ -126,9 +126,11 @@ void UIScene_EndPoem::tick()
IggyDataValue result;
IggyDataValue value[3];
const std::u16string convLabel = convWstringToU16string(label);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
@ -268,4 +270,4 @@ void UIScene_EndPoem::updateNoise()
found=(int)noiseString.find(tag,found+1);
}
}
}

View file

@ -182,8 +182,7 @@ void UIScene_HUD::customDraw(IggyCustomDrawCallbackRegion *region)
Minecraft *pMinecraft = Minecraft::GetInstance();
if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return;
int slot = -1;
swscanf((wchar_t*)region->name,L"slot_%d",&slot);
int slot = parseSlotId(region->name);
if (slot == -1)
{
app.DebugPrintf("This is not the control we are looking for\n");
@ -534,9 +533,10 @@ void UIScene_HUD::SetDragonLabel(const std::wstring &label)
{
IggyDataValue result;
IggyDataValue value[1];
const std::u16string convLabel = convWstringToU16string(label);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetDragonLabel , 1 , value );
@ -564,9 +564,10 @@ void UIScene_HUD::SetSelectedLabel(const std::wstring &label)
IggyDataValue result;
IggyDataValue value[1];
const std::u16string convLabel = convWstringToU16string(label);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetSelectedLabel , 1 , value );
@ -745,8 +746,9 @@ void UIScene_HUD::SetDisplayName(const std::wstring &displayName)
IggyDataValue result;
IggyDataValue value[1];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)displayName.c_str();
stringVal.length = displayName.length();
const std::u16string convName = convWstringToU16string(displayName);
stringVal.string = convName.c_str();
stringVal.length = convName.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetDisplayName , 1 , value );

View file

@ -305,10 +305,15 @@ void UIScene_HowToPlay::StartPage( EHowToPlayPage ePage )
value[0].type = IGGY_DATATYPE_number;
value[0].number = gs_pageToFlashMapping[(int)ePage];
std::vector<std::u16string> conv;
conv.reserve(paragraphs.size());
for(unsigned int i = 0; i < paragraphs.size(); ++i)
{
stringVal[i].string = (IggyUTF16 *)paragraphs[i].c_str();
stringVal[i].length = paragraphs[i].length();
conv.push_back(convWstringToU16string(paragraphs[i]));
stringVal[i].string = conv[i].c_str();
stringVal[i].length = conv[i].length();
value[i+1].type = IGGY_DATATYPE_string_UTF16;
value[i+1].string16 = stringVal[i];
}

View file

@ -2,7 +2,7 @@
#include "UI.h"
#include "UIScene_Intro.h"
#ifdef __linux__
#ifndef _ENABLEIGGY
static int s_introTickCount = 0;
#endif
@ -12,7 +12,7 @@ UIScene_Intro::UIScene_Intro(int iPad, void *initData, UILayer *parentLayer) : U
initialiseMovie();
m_bIgnoreNavigate = false;
m_bAnimationEnded = false;
#ifdef __linux__
#ifndef _ENABLEIGGY
s_introTickCount = 0;
#endif
@ -36,8 +36,6 @@ UIScene_Intro::UIScene_Intro(int iPad, void *initData, UILayer *parentLayer) : U
int platformIdx = 4;
#elif defined(__PSVITA__)
int platformIdx = 5;
#elif defined(__linux__)
int platformIdx = 0;
#endif
IggyDataValue result;
@ -173,7 +171,7 @@ void UIScene_Intro::handleGainFocus(bool navBack)
}
}
#ifdef __linux__
#ifndef _ENABLEIGGY
void UIScene_Intro::tick()
{
// Call base tick first (processes Iggy ticking)

View file

@ -45,12 +45,11 @@ public:
virtual void handleAnimationEnd();
virtual void handleGainFocus(bool navBack);
#ifdef __linux__
virtual void tick();
#endif
#ifdef __PSVITA__
virtual void handleTouchInput(unsigned int iPad, S32 x, S32 y, int iId, bool bPressed, bool bRepeat, bool bReleased);
#endif
#ifndef _ENABLEIGGY
virtual void tick();
#endif
};

View file

@ -229,7 +229,7 @@ void UIScene_InventoryMenu::customDraw(IggyCustomDrawCallbackRegion *region)
Minecraft *pMinecraft = Minecraft::GetInstance();
if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return;
if(wcscmp((wchar_t *)region->name,L"player")==0)
if(std::char_traits<char16_t>::compare(region->name, u"player", 6) == 0)
{
// Setup GDraw, normal game render states and matrices
CustomDrawData *customDrawRegion = ui.setupCustomDraw(this,region);
@ -309,9 +309,10 @@ void UIScene_InventoryMenu::updateEffectsDisplay()
value[0].type = IGGY_DATATYPE_number;
value[0].number = icon;
const std::u16string convString = convWstringToU16string(effectString);
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)effectString.c_str();
stringVal.length = effectString.length();
stringVal.string = convString.c_str();
stringVal.length = convString.length();
value[1].type = IGGY_DATATYPE_string_UTF16;
value[1].string16 = stringVal;

View file

@ -26,8 +26,9 @@ UIScene_Keyboard::UIScene_Keyboard(int iPad, void *initData, UILayer *parentLaye
// Initialise function keyboard Buttons and set alternative symbol button string
std::wstring label = L"Abc";
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
const std::u16string convLabel = convWstringToU16string(label);
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
IggyDataValue result;
IggyDataValue value[1];
@ -178,4 +179,4 @@ void UIScene_Keyboard::KeyboardDonePressed()
// ToDo: Keyboard can now pass on its final string value and close itself down
navigateBack();
}
}

View file

@ -961,11 +961,11 @@ int UIScene_LeaderboardsMenu::SetLeaderboardTitleIcons()
void UIScene_LeaderboardsMenu::customDraw(IggyCustomDrawCallbackRegion *region)
{
int slotId = -1;
swscanf((wchar_t*)region->name,L"slot_%d",&slotId);
int slotId = parseSlotId(region->name);
if (slotId == -1)
{
//app.DebugPrintf("This is not the control we are looking for\n");
//assert(0);
app.DebugPrintf("This is not the control we are looking for\n");
}
else
{

View file

@ -426,7 +426,7 @@ void UIScene_MainMenu::RunAction(int iPad)
void UIScene_MainMenu::customDraw(IggyCustomDrawCallbackRegion *region)
{
if(wcscmp((wchar_t *)region->name,L"Splash")==0)
if(std::char_traits<char16_t>::compare(region->name, u"Splash", 6) == 0)
{
PIXBeginNamedEvent(0,"Custom draw splash");
customDrawSplash(region);
@ -1806,7 +1806,7 @@ void UIScene_MainMenu::tick()
{
UIScene::tick();
#ifdef __linux__
#ifndef _ENABLEIGGY
{
static int s_mainMenuTickCount = 0;
s_mainMenuTickCount++;

View file

@ -716,6 +716,7 @@ void UIScene_SkinSelectMenu::InputActionOK(unsigned int iPad)
void UIScene_SkinSelectMenu::customDraw(IggyCustomDrawCallbackRegion *region)
{
int characterId = -1;
// 4jcraft TODO: undefined behavior
swscanf((wchar_t*)region->name,L"Character%d",&characterId);
if (characterId == -1)
{
@ -1364,14 +1365,16 @@ void UIScene_SkinSelectMenu::setLeftLabel(const std::wstring &label)
{
if(label.compare(m_leftLabel) != 0)
{
m_leftLabel = label;
m_leftLabel = label;
const std::u16string convLabel = convWstringToU16string(label);
IggyDataValue result;
IggyDataValue value[1];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
@ -1383,14 +1386,16 @@ void UIScene_SkinSelectMenu::setCentreLabel(const std::wstring &label)
{
if(label.compare(m_centreLabel) != 0)
{
m_centreLabel = label;
m_centreLabel = label;
const std::u16string convLabel = convWstringToU16string(label);
IggyDataValue result;
IggyDataValue value[1];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;
@ -1404,12 +1409,14 @@ void UIScene_SkinSelectMenu::setRightLabel(const std::wstring &label)
{
m_rightLabel = label;
const std::u16string convLabel = convWstringToU16string(label);
IggyDataValue result;
IggyDataValue value[1];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)label.c_str();
stringVal.length = label.length();
stringVal.string = convLabel.c_str();
stringVal.length = convLabel.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;

View file

@ -148,8 +148,7 @@ void UIScene_TradingMenu::customDraw(IggyCustomDrawCallbackRegion *region)
if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return;
std::shared_ptr<ItemInstance> item = nullptr;
int slotId = -1;
swscanf((wchar_t*)region->name,L"slot_%d",&slotId);
int slotId = parseSlotId(region->name);
if(slotId < MerchantMenu::USE_ROW_SLOT_END)
{
@ -255,12 +254,14 @@ void UIScene_TradingMenu::setTradeRedBox(int index, bool show)
void UIScene_TradingMenu::setOfferDescription(const std::wstring &name, std::vector<std::wstring> &unformattedStrings)
{
const std::u16string convName = convWstringToU16string(name);
IggyDataValue result;
IggyDataValue value[1];
IggyStringUTF16 stringVal;
stringVal.string = (IggyUTF16*)name.c_str();
stringVal.length = name.length();
stringVal.string = convName.c_str();
stringVal.length = convName.length();
value[0].type = IGGY_DATATYPE_string_UTF16;
value[0].string16 = stringVal;

View file

@ -238,46 +238,32 @@ typedef struct _JoinMenuInitData
// More Options
typedef struct _LaunchMoreOptionsMenuInitData
{
bool bOnlineGame;
bool bInviteOnly;
bool bAllowFriendsOfFriends;
bool bOnlineGame = true;
bool bInviteOnly = false;
bool bAllowFriendsOfFriends = true;
bool bGenerateOptions;
bool bStructures;
bool bFlatWorld;
bool bBonusChest;
bool bGenerateOptions = false;
bool bStructures = false;
bool bFlatWorld = false;
bool bBonusChest = false;
bool bPVP;
bool bTrust;
bool bFireSpreads;
bool bTNT;
bool bPVP = true;
bool bTrust = false;
bool bFireSpreads = true;
bool bTNT = true;
bool bHostPrivileges;
bool bResetNether;
bool bHostPrivileges = false;
bool bResetNether = false;
bool bOnlineSettingChangedBySystem;
bool bOnlineSettingChangedBySystem = false;
int iPad;
int iPad = -1;
std::uint32_t dwTexturePack;
std::uint32_t dwTexturePack = 0;
std::wstring seed;
int worldSize;
bool bDisableSaving;
_LaunchMoreOptionsMenuInitData()
{
memset((void*)this,0,sizeof(_LaunchMoreOptionsMenuInitData));
bOnlineGame = true;
bAllowFriendsOfFriends = true;
bPVP = true;
bFireSpreads = true;
bTNT = true;
iPad = -1;
worldSize = 3;
seed = L"";
bDisableSaving = false;
}
std::wstring seed = L"";
int worldSize = 3;
bool bDisableSaving = false;
}
LaunchMoreOptionsMenuInitData;

View file

@ -1,275 +0,0 @@
// gdraw_glfw.c - Linux/GLFW port of gdraw_wgl.c
// Original: copyright 2011-2012 RAD Game Tools
// Port: Implements the Iggy graphics driver layer for GL on Linux via GLFW.
#define GDRAW_ASSERTS
#include "../../../Windows64/Iggy/include/iggy.h"
#include "../../../Windows64/Iggy/include/gdraw.h"
#include "gdraw_glfw.h"
#include <GL/gl.h>
#include <GL/glext.h>
#include <SDL2/SDL.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
#define true 1
#define false 0
// Iggy GDraw support functions - normally in the Iggy library, stubbed here
void* IggyGDrawMallocAnnotated(SINTa size, const char* file, int line) {
(void)file;
(void)line;
return malloc((size_t)size);
}
void IggyGDrawFree(void* ptr) { free(ptr); }
void IggyGDrawSendWarning(Iggy* f, char const* message, ...) {
(void)f;
va_list args;
va_start(args, message);
fprintf(stderr, "[Iggy GDraw Warning] ");
vfprintf(stderr, message, args);
fprintf(stderr, "\n");
va_end(args);
}
void IggyDiscardVertexBufferCallback(void* owner, void* buf) {
(void)owner;
(void)buf;
}
///////////////////////////////////////////////////////////////////////////////
//
// Extensions (we map to GL 2.0 function names for a uniform interface
// across platforms)
//
// NOTE: glActiveTexture and glCompressedTexImage2D are omitted here because
// on Linux they are core GL 1.3+ functions already declared in <GL/gl.h>.
// The shared code calls them by name and the real functions are used directly.
//
#define GDRAW_GL_EXTENSION_LIST \
/* identifier import procname */ \
/* GL_ARB_vertex_buffer_object */ \
GLE(GenBuffers, "GenBuffersARB", GENBUFFERSARB) \
GLE(DeleteBuffers, "DeleteBuffersARB", DELETEBUFFERSARB) \
GLE(BindBuffer, "BindBufferARB", BINDBUFFERARB) \
GLE(BufferData, "BufferDataARB", BUFFERDATAARB) \
GLE(MapBuffer, "MapBufferARB", MAPBUFFERARB) \
GLE(UnmapBuffer, "UnmapBufferARB", UNMAPBUFFERARB) \
GLE(VertexAttribPointer, "VertexAttribPointerARB", VERTEXATTRIBPOINTERARB) \
GLE(EnableVertexAttribArray, "EnableVertexAttribArrayARB", \
ENABLEVERTEXATTRIBARRAYARB) \
GLE(DisableVertexAttribArray, "DisableVertexAttribArrayARB", \
DISABLEVERTEXATTRIBARRAYARB) \
/* GL_ARB_shader_objects */ \
GLE(CreateShader, "CreateShaderObjectARB", CREATESHADEROBJECTARB) \
GLE(DeleteShader, "DeleteObjectARB", DELETEOBJECTARB) \
GLE(ShaderSource, "ShaderSourceARB", SHADERSOURCEARB) \
GLE(CompileShader, "CompileShaderARB", COMPILESHADERARB) \
GLE(GetShaderiv, "GetObjectParameterivARB", GETOBJECTPARAMETERIVARB) \
GLE(GetShaderInfoLog, "GetInfoLogARB", GETINFOLOGARB) \
GLE(CreateProgram, "CreateProgramObjectARB", CREATEPROGRAMOBJECTARB) \
GLE(DeleteProgram, "DeleteObjectARB", DELETEOBJECTARB) \
GLE(AttachShader, "AttachObjectARB", ATTACHOBJECTARB) \
GLE(LinkProgram, "LinkProgramARB", LINKPROGRAMARB) \
GLE(GetUniformLocation, "GetUniformLocationARB", GETUNIFORMLOCATIONARB) \
GLE(UseProgram, "UseProgramObjectARB", USEPROGRAMOBJECTARB) \
GLE(GetProgramiv, "GetObjectParameterivARB", GETOBJECTPARAMETERIVARB) \
GLE(GetProgramInfoLog, "GetInfoLogARB", GETINFOLOGARB) \
GLE(Uniform1i, "Uniform1iARB", UNIFORM1IARB) \
GLE(Uniform4f, "Uniform4fARB", UNIFORM4FARB) \
GLE(Uniform4fv, "Uniform4fvARB", UNIFORM4FVARB) \
/* GL_ARB_vertex_shader */ \
GLE(BindAttribLocation, "BindAttribLocationARB", BINDATTRIBLOCATIONARB) \
/* Missing from WGL but needed by shared code */ \
GLE(Uniform1f, "Uniform1fARB", UNIFORM1FARB) \
/* GL_EXT_framebuffer_object */ \
GLE(GenRenderbuffers, "GenRenderbuffersEXT", GENRENDERBUFFERSEXT) \
GLE(DeleteRenderbuffers, "DeleteRenderbuffersEXT", DELETERENDERBUFFERSEXT) \
GLE(BindRenderbuffer, "BindRenderbufferEXT", BINDRENDERBUFFEREXT) \
GLE(RenderbufferStorage, "RenderbufferStorageEXT", RENDERBUFFERSTORAGEEXT) \
GLE(GenFramebuffers, "GenFramebuffersEXT", GENFRAMEBUFFERSEXT) \
GLE(DeleteFramebuffers, "DeleteFramebuffersEXT", DELETEFRAMEBUFFERSEXT) \
GLE(BindFramebuffer, "BindFramebufferEXT", BINDFRAMEBUFFEREXT) \
GLE(CheckFramebufferStatus, "CheckFramebufferStatusEXT", \
CHECKFRAMEBUFFERSTATUSEXT) \
GLE(FramebufferRenderbuffer, "FramebufferRenderbufferEXT", \
FRAMEBUFFERRENDERBUFFEREXT) \
GLE(FramebufferTexture2D, "FramebufferTexture2DEXT", \
FRAMEBUFFERTEXTURE2DEXT) \
GLE(GenerateMipmap, "GenerateMipmapEXT", GENERATEMIPMAPEXT) \
/* GL_EXT_framebuffer_blit */ \
GLE(BlitFramebuffer, "BlitFramebufferEXT", BLITFRAMEBUFFEREXT) \
/* GL_EXT_framebuffer_multisample */ \
GLE(RenderbufferStorageMultisample, "RenderbufferStorageMultisampleEXT", \
RENDERBUFFERSTORAGEMULTISAMPLEEXT) \
/* <end> */
#define gdraw_GLx_(id) gdraw_GL_##id
#define GDRAW_GLx_(id) GDRAW_GL_##id
#define GDRAW_SHADERS "gdraw_gl_shaders.inl"
// On Linux, GLhandleARB is void* (not GLuint) but the shader functions
// actually return/take GLuint values. Use GLuint as our handle type,
// matching the Mac pattern from gdraw_gl_shared.inl.
#define GDrawGLProgram GLuint
typedef GLuint GLhandle;
typedef gdraw_gl_resourcetype gdraw_resourcetype;
// Extensions
#define GLE(id, import, procname) static PFNGL##procname##PROC gl##id;
GDRAW_GL_EXTENSION_LIST
#undef GLE
static void load_extensions(void) {
#define GLE(id, import, procname) \
gl##id = (PFNGL##procname##PROC)SDL_GL_GetProcAddress("gl" import);
GDRAW_GL_EXTENSION_LIST
#undef GLE
}
static void clear_renderstate_platform_specific(void) {
glDisable(GL_ALPHA_TEST);
}
static void error_msg_platform_specific(const char* msg) {
fprintf(stderr, "[GDraw GL] %s\n", msg);
}
///////////////////////////////////////////////////////////////////////////////
//
// Shared code
//
#define GDRAW_MULTISAMPLING
// Override RR_BREAK() to avoid SIGTRAP from GL debug checks on Linux
#ifdef RR_BREAK
#undef RR_BREAK
#endif
#define RR_BREAK() \
do { \
fprintf(stderr, "[GDraw] RR_BREAK suppressed (GL error)\n"); \
} while (0)
#include "../../../Windows64/Iggy/gdraw/gdraw_gl_shared.inl"
///////////////////////////////////////////////////////////////////////////////
//
// Initialization and platform-specific functionality
//
GDrawFunctions* gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples) {
static const TextureFormatDesc tex_formats[] = {
{IFT_FORMAT_rgba_8888, 1, 1, 4, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE},
{IFT_FORMAT_rgba_4444_LE, 1, 1, 2, GL_RGBA4, GL_RGBA,
GL_UNSIGNED_SHORT_4_4_4_4},
{IFT_FORMAT_rgba_5551_LE, 1, 1, 2, GL_RGB5_A1, GL_RGBA,
GL_UNSIGNED_SHORT_5_5_5_1},
{IFT_FORMAT_la_88, 1, 1, 2, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA,
GL_UNSIGNED_BYTE},
{IFT_FORMAT_la_44, 1, 1, 1, GL_LUMINANCE4_ALPHA4, GL_LUMINANCE_ALPHA,
GL_UNSIGNED_BYTE},
{IFT_FORMAT_i_8, 1, 1, 1, GL_INTENSITY8, GL_ALPHA, GL_UNSIGNED_BYTE},
{IFT_FORMAT_i_4, 1, 1, 1, GL_INTENSITY4, GL_ALPHA, GL_UNSIGNED_BYTE},
{IFT_FORMAT_l_8, 1, 1, 1, GL_LUMINANCE8, GL_LUMINANCE,
GL_UNSIGNED_BYTE},
{IFT_FORMAT_l_4, 1, 1, 1, GL_LUMINANCE4, GL_LUMINANCE,
GL_UNSIGNED_BYTE},
{IFT_FORMAT_DXT1, 4, 4, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 0,
GL_UNSIGNED_BYTE},
{IFT_FORMAT_DXT3, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 0,
GL_UNSIGNED_BYTE},
{IFT_FORMAT_DXT5, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0,
GL_UNSIGNED_BYTE},
{0, 0, 0, 0, 0, 0, 0},
};
GDrawFunctions* funcs;
const char* s;
GLint n;
// check for the extensions we need
s = (const char*)glGetString(GL_EXTENSIONS);
if (s == NULL) {
fprintf(stderr,
"[GDraw GL] glGetString(GL_EXTENSIONS) returned NULL - GL "
"context not current?\n");
assert(s != NULL);
return NULL;
}
// check for the extensions we won't work without
if (!hasext(s, "GL_ARB_multitexture") ||
!hasext(s, "GL_ARB_texture_compression") ||
!hasext(s, "GL_ARB_texture_mirrored_repeat") ||
!hasext(s, "GL_ARB_texture_non_power_of_two") ||
!hasext(s, "GL_ARB_vertex_buffer_object") ||
!hasext(s, "GL_EXT_framebuffer_object") ||
!hasext(s, "GL_ARB_shader_objects") ||
!hasext(s, "GL_ARB_vertex_shader") ||
!hasext(s, "GL_ARB_fragment_shader")) {
fprintf(stderr, "[GDraw GL] Required GL extensions not available\n");
return NULL;
}
// if user requests multisampling and HW doesn't support it, bail
if (!hasext(s, "GL_EXT_framebuffer_multisample") && msaa_samples > 1)
return NULL;
load_extensions();
funcs = create_context(w, h);
if (!funcs) return NULL;
gdraw->tex_formats = tex_formats;
// check for optional extensions
gdraw->has_mapbuffer = true; // part of core VBO extension on regular GL
gdraw->has_depth24 = true; // we just assume.
gdraw->has_texture_max_level = true; // core on regular GL
if (hasext(s, "GL_EXT_packed_depth_stencil"))
gdraw->has_packed_depth_stencil = true;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &n);
gdraw->has_conditional_non_power_of_two = n < 8192;
// clamp number of multisampling levels to max supported
if (msaa_samples > 1) {
glGetIntegerv(GL_MAX_SAMPLES, &n);
gdraw->multisampling = RR_MIN(msaa_samples, n);
}
opengl_check();
fprintf(stderr,
"[GDraw GL] Context created successfully (%dx%d, msaa=%d)\n", w, h,
msaa_samples);
return funcs;
}
///////////////////////////////////////////////////////////////////////////////
//
// 4J-specific custom draw functions
//
void gdraw_GL_BeginCustomDraw_4J(IggyCustomDrawCallbackRegion* region,
F32* matrix) {
// Same as BeginCustomDraw but uses different depth param
clear_renderstate();
gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection,
depth_from_id(0), 1);
}
void gdraw_GL_CalculateCustomDraw_4J(IggyCustomDrawCallbackRegion* region,
F32* matrix) {
gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, 0.0f, 0);
}

View file

@ -1,59 +0,0 @@
#ifndef __RAD_INCLUDE_GDRAW_GLFW_H__
#define __RAD_INCLUDE_GDRAW_GLFW_H__
#include "../../../Windows64/Iggy/include/gdraw.h"
#include "../../../Windows64/Iggy/include/iggy.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum gdraw_gl_resourcetype {
GDRAW_GL_RESOURCE_rendertarget,
GDRAW_GL_RESOURCE_texture,
GDRAW_GL_RESOURCE_vertexbuffer,
GDRAW_GL_RESOURCE__count,
} gdraw_gl_resourcetype;
struct IggyCustomDrawCallbackRegion;
extern int gdraw_GL_SetResourceLimits(gdraw_gl_resourcetype type,
S32 num_handles, S32 num_bytes);
extern GDrawFunctions* gdraw_GL_CreateContext(S32 min_w, S32 min_h,
S32 msaa_samples);
extern void gdraw_GL_DestroyContext(void);
extern void gdraw_GL_SetTileOrigin(
S32 vx, S32 vy,
unsigned int
framebuffer); // framebuffer=FBO handle, or 0 for main frame buffer
extern void gdraw_GL_NoMoreGDrawThisFrame(void);
extern GDrawTexture* gdraw_GL_WrappedTextureCreate(S32 gl_texture_handle,
S32 width, S32 height,
int has_mipmaps);
extern void gdraw_GL_WrappedTextureChange(GDrawTexture* tex,
S32 new_gl_texture_handle,
S32 new_width, S32 new_height,
int new_has_mipmaps);
extern void gdraw_GL_WrappedTextureDestroy(GDrawTexture* tex);
extern void gdraw_GL_BeginCustomDraw(
struct IggyCustomDrawCallbackRegion* region, float* matrix);
extern void gdraw_GL_EndCustomDraw(struct IggyCustomDrawCallbackRegion* region);
extern void gdraw_GL_CalculateCustomDraw_4J(
struct IggyCustomDrawCallbackRegion* region, float* matrix);
extern void gdraw_GL_BeginCustomDraw_4J(
struct IggyCustomDrawCallbackRegion* region, float* matrix);
extern GDrawTexture* gdraw_GL_MakeTextureFromResource(
unsigned char* resource_file, S32 resource_len,
IggyFileTextureRaw* texture);
extern void gdraw_GL_DestroyTextureFromResource(GDrawTexture* tex);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,240 @@
// Rewrite of gdraw_GLFW to gdraw_SDL
// I hope iggy gets fully implemented rrlllly quickly <3
#define GDRAW_ASSERTS
#include "../../../Windows64/Iggy/include/iggy.h"
#include "../../../Windows64/Iggy/include/gdraw.h"
#include "gdraw_sdl.h"
#include <GL/gl.h>
#include <GL/glext.h>
#include <SDL2/SDL.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
#define true 1
#define false 0
// Say hi to sdl
#ifndef _ENABLEIGGY
void *IggyGDrawMallocAnnotated(SINTa size, const char *file, int line)
{
(void)file; (void)line;
return malloc((size_t)size);
}
void IggyGDrawFree(void *ptr)
{
free(ptr);
}
void IggyGDrawSendWarning(Iggy *f, char const *message, ...)
{
(void)f;
va_list args;
va_start(args, message);
fprintf(stderr, "[Iggy GDraw Warning] ");
vfprintf(stderr, message, args);
fprintf(stderr, "\n");
va_end(args);
}
void IggyDiscardVertexBufferCallback(void *owner, void *buf)
{
(void)owner; (void)buf;
}
#endif
// glActiveTexture and glCompressedTexImage2D are core GL 1.3+ on Linux and
// are declared directly in <GL/gl.h>, so they are omitted from this list.
#define GDRAW_GL_EXTENSION_LIST \
/* identifier import procname */ \
/* GL_ARB_vertex_buffer_object */ \
GLE(GenBuffers, "GenBuffersARB", GENBUFFERSARB) \
GLE(DeleteBuffers, "DeleteBuffersARB", DELETEBUFFERSARB) \
GLE(BindBuffer, "BindBufferARB", BINDBUFFERARB) \
GLE(BufferData, "BufferDataARB", BUFFERDATAARB) \
GLE(MapBuffer, "MapBufferARB", MAPBUFFERARB) \
GLE(UnmapBuffer, "UnmapBufferARB", UNMAPBUFFERARB) \
GLE(VertexAttribPointer, "VertexAttribPointerARB", VERTEXATTRIBPOINTERARB) \
GLE(EnableVertexAttribArray, "EnableVertexAttribArrayARB", ENABLEVERTEXATTRIBARRAYARB) \
GLE(DisableVertexAttribArray, "DisableVertexAttribArrayARB", DISABLEVERTEXATTRIBARRAYARB) \
/* GL_ARB_shader_objects */ \
GLE(CreateShader, "CreateShaderObjectARB", CREATESHADEROBJECTARB) \
GLE(DeleteShader, "DeleteObjectARB", DELETEOBJECTARB) \
GLE(ShaderSource, "ShaderSourceARB", SHADERSOURCEARB) \
GLE(CompileShader, "CompileShaderARB", COMPILESHADERARB) \
GLE(GetShaderiv, "GetObjectParameterivARB", GETOBJECTPARAMETERIVARB) \
GLE(GetShaderInfoLog, "GetInfoLogARB", GETINFOLOGARB) \
GLE(CreateProgram, "CreateProgramObjectARB", CREATEPROGRAMOBJECTARB) \
GLE(DeleteProgram, "DeleteObjectARB", DELETEOBJECTARB) \
GLE(AttachShader, "AttachObjectARB", ATTACHOBJECTARB) \
GLE(LinkProgram, "LinkProgramARB", LINKPROGRAMARB) \
GLE(GetUniformLocation, "GetUniformLocationARB", GETUNIFORMLOCATIONARB) \
GLE(UseProgram, "UseProgramObjectARB", USEPROGRAMOBJECTARB) \
GLE(GetProgramiv, "GetObjectParameterivARB", GETOBJECTPARAMETERIVARB) \
GLE(GetProgramInfoLog, "GetInfoLogARB", GETINFOLOGARB) \
GLE(Uniform1i, "Uniform1iARB", UNIFORM1IARB) \
GLE(Uniform4f, "Uniform4fARB", UNIFORM4FARB) \
GLE(Uniform4fv, "Uniform4fvARB", UNIFORM4FVARB) \
/* GL_ARB_vertex_shader */ \
GLE(BindAttribLocation, "BindAttribLocationARB", BINDATTRIBLOCATIONARB) \
/* Missing from WGL but needed by shared code */ \
GLE(Uniform1f, "Uniform1fARB", UNIFORM1FARB) \
/* GL_EXT_framebuffer_object */ \
GLE(GenRenderbuffers, "GenRenderbuffersEXT", GENRENDERBUFFERSEXT) \
GLE(DeleteRenderbuffers, "DeleteRenderbuffersEXT", DELETERENDERBUFFERSEXT) \
GLE(BindRenderbuffer, "BindRenderbufferEXT", BINDRENDERBUFFEREXT) \
GLE(RenderbufferStorage, "RenderbufferStorageEXT", RENDERBUFFERSTORAGEEXT) \
GLE(GenFramebuffers, "GenFramebuffersEXT", GENFRAMEBUFFERSEXT) \
GLE(DeleteFramebuffers, "DeleteFramebuffersEXT", DELETEFRAMEBUFFERSEXT) \
GLE(BindFramebuffer, "BindFramebufferEXT", BINDFRAMEBUFFEREXT) \
GLE(CheckFramebufferStatus, "CheckFramebufferStatusEXT", CHECKFRAMEBUFFERSTATUSEXT) \
GLE(FramebufferRenderbuffer, "FramebufferRenderbufferEXT", FRAMEBUFFERRENDERBUFFEREXT) \
GLE(FramebufferTexture2D, "FramebufferTexture2DEXT", FRAMEBUFFERTEXTURE2DEXT) \
GLE(GenerateMipmap, "GenerateMipmapEXT", GENERATEMIPMAPEXT) \
/* GL_EXT_framebuffer_blit */ \
GLE(BlitFramebuffer, "BlitFramebufferEXT", BLITFRAMEBUFFEREXT) \
/* GL_EXT_framebuffer_multisample */ \
GLE(RenderbufferStorageMultisample, "RenderbufferStorageMultisampleEXT",RENDERBUFFERSTORAGEMULTISAMPLEEXT) \
/* <end> */
#define gdraw_GLx_(id) gdraw_GL_##id
#define GDRAW_GLx_(id) GDRAW_GL_##id
#define GDRAW_SHADERS "gdraw_gl_shaders.inl"
// On Linux, GLhandleARB is void* but shader functions use GLuint values.
// Use GLuint as our handle type, matching the Mac pattern from gdraw_gl_shared.inl.
#define GDrawGLProgram GLuint
typedef GLuint GLhandle;
typedef gdraw_gl_resourcetype gdraw_resourcetype;
// Declare extension function pointers
#define GLE(id, import, procname) static PFNGL##procname##PROC gl##id;
GDRAW_GL_EXTENSION_LIST
#undef GLE
static void load_extensions(void)
{
#define GLE(id, import, procname) \
gl##id = (PFNGL##procname##PROC) SDL_GL_GetProcAddress("gl" import);
GDRAW_GL_EXTENSION_LIST
#undef GLE
}
static void clear_renderstate_platform_specific(void)
{
glDisable(GL_ALPHA_TEST);
}
static void error_msg_platform_specific(const char *msg)
{
fprintf(stderr, "[GDraw SDL] %s\n", msg);
}
#define GDRAW_MULTISAMPLING
// Suppress SIGTRAP from GL debug assertions on Linux
#ifdef RR_BREAK
#undef RR_BREAK
#endif
#define RR_BREAK() \
do { fprintf(stderr, "[GDraw] RR_BREAK suppressed (GL error)\n"); } while(0)
#include "../../../Windows64/Iggy/gdraw/gdraw_gl_shared.inl"
// Context creation and management
GDrawFunctions *gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples)
{
static const TextureFormatDesc tex_formats[] = {
{ IFT_FORMAT_rgba_8888, 1, 1, 4, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_rgba_4444_LE, 1, 1, 2, GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 },
{ IFT_FORMAT_rgba_5551_LE, 1, 1, 2, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 },
{ IFT_FORMAT_la_88, 1, 1, 2, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_la_44, 1, 1, 1, GL_LUMINANCE4_ALPHA4, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_i_8, 1, 1, 1, GL_INTENSITY8, GL_ALPHA, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_i_4, 1, 1, 1, GL_INTENSITY4, GL_ALPHA, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_l_8, 1, 1, 1, GL_LUMINANCE8, GL_LUMINANCE, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_l_4, 1, 1, 1, GL_LUMINANCE4, GL_LUMINANCE, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_DXT1, 4, 4, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 0, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_DXT3, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 0, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_DXT5, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0, GL_UNSIGNED_BYTE },
{ 0, 0, 0, 0, 0, 0, 0 },
};
GDrawFunctions *funcs;
const char *s;
GLint n;
// A current SDL2 GL context must be active before calling this, if it doesn't exist, just throw an warning-
s = (const char *) glGetString(GL_EXTENSIONS);
if (!s) {
fprintf(stderr, "[GDraw SDL] glGetString(GL_EXTENSIONS) returned NULL - "
"SDL GL context not current?\n");
assert(s != NULL);
return NULL;
}
// Verify required extensions
if (!hasext(s, "GL_ARB_multitexture") ||
!hasext(s, "GL_ARB_texture_compression") ||
!hasext(s, "GL_ARB_texture_mirrored_repeat") ||
!hasext(s, "GL_ARB_texture_non_power_of_two") ||
!hasext(s, "GL_ARB_vertex_buffer_object") ||
!hasext(s, "GL_EXT_framebuffer_object") ||
!hasext(s, "GL_ARB_shader_objects") ||
!hasext(s, "GL_ARB_vertex_shader") ||
!hasext(s, "GL_ARB_fragment_shader"))
{
fprintf(stderr, "[GDraw SDL] Required GL extensions not available\n");
return NULL;
}
if (!hasext(s, "GL_EXT_framebuffer_multisample") && msaa_samples > 1)
return NULL;
load_extensions();
funcs = create_context(w, h);
if (!funcs)
return NULL;
gdraw->tex_formats = tex_formats;
gdraw->has_mapbuffer = true; // core in ARB_vertex_buffer_object
gdraw->has_depth24 = true;
gdraw->has_texture_max_level = true; // core GL
if (hasext(s, "GL_EXT_packed_depth_stencil"))
gdraw->has_packed_depth_stencil = true;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &n);
gdraw->has_conditional_non_power_of_two = (n < 8192);
if (msaa_samples > 1) {
glGetIntegerv(GL_MAX_SAMPLES, &n);
gdraw->multisampling = RR_MIN(msaa_samples, n);
}
opengl_check();
fprintf(stderr, "[GDraw SDL] Context created successfully (%dx%d, msaa=%d)\n",
w, h, msaa_samples);
return funcs;
}
void gdraw_GL_BeginCustomDraw_4J(IggyCustomDrawCallbackRegion *region, F32 *matrix)
{
clear_renderstate();
gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, depth_from_id(0), 0);
}
void gdraw_GL_CalculateCustomDraw_4J(IggyCustomDrawCallbackRegion *region, F32 *matrix)
{
gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, 0.0f, 0);
}

View file

@ -0,0 +1,37 @@
#ifndef __RAD_INCLUDE_GDRAW_SDL_H__
#define __RAD_INCLUDE_GDRAW_SDL_H__
#include "../../../Windows64/Iggy/include/gdraw.h"
#include "../../../Windows64/Iggy/include/iggy.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum gdraw_gl_resourcetype
{
GDRAW_GL_RESOURCE_rendertarget,
GDRAW_GL_RESOURCE_texture,
GDRAW_GL_RESOURCE_vertexbuffer,
GDRAW_GL_RESOURCE__count,
} gdraw_gl_resourcetype;
struct IggyCustomDrawCallbackRegion;
extern int gdraw_GL_SetResourceLimits(gdraw_gl_resourcetype type, S32 num_handles, S32 num_bytes);
extern GDrawFunctions *gdraw_GL_CreateContext(S32 min_w, S32 min_h, S32 msaa_samples);
extern void gdraw_GL_DestroyContext(void);
extern void gdraw_GL_SetTileOrigin(S32 vx, S32 vy, unsigned int framebuffer);
extern void gdraw_GL_NoMoreGDrawThisFrame(void);
extern GDrawTexture *gdraw_GL_WrappedTextureCreate(S32 gl_texture_handle, S32 width, S32 height, int has_mipmaps);
extern void gdraw_GL_WrappedTextureChange(GDrawTexture *tex, S32 new_gl_texture_handle, S32 new_width, S32 new_height, int new_has_mipmaps);
extern void gdraw_GL_WrappedTextureDestroy(GDrawTexture *tex);
extern void gdraw_GL_BeginCustomDraw(struct IggyCustomDrawCallbackRegion *region, float *matrix);
extern void gdraw_GL_EndCustomDraw(struct IggyCustomDrawCallbackRegion *region);
extern void gdraw_GL_CalculateCustomDraw_4J(struct IggyCustomDrawCallbackRegion *region, float *matrix);
extern void gdraw_GL_BeginCustomDraw_4J(struct IggyCustomDrawCallbackRegion *region, float *matrix);
extern GDrawTexture *gdraw_GL_MakeTextureFromResource(unsigned char *resource_file, S32 resource_len, IggyFileTextureRaw *texture);
extern void gdraw_GL_DestroyTextureFromResource(GDrawTexture *tex);
#ifdef __cplusplus
}
#endif
#endif // __RAD_INCLUDE_GDRAW_SDL_H__

View file

@ -0,0 +1,726 @@
// gdraw.h - author: Sean Barrett - copyright 2009 RAD Game Tools
//
// This is the graphics rendering abstraction that Iggy is implemented
// on top of.
#ifndef __RAD_INCLUDE_GDRAW_H__
#define __RAD_INCLUDE_GDRAW_H__
#include "../../../Windows64/Miles/include/rrcore.h"
#define IDOC
RADDEFSTART
//idoc(parent,GDrawAPI_Buffers)
#ifndef IGGY_GDRAW_SHARED_TYPEDEF
#define IGGY_GDRAW_SHARED_TYPEDEF
typedef struct GDrawFunctions GDrawFunctions;
typedef struct GDrawTexture GDrawTexture;
#endif//IGGY_GDRAW_SHARED_TYPEDEF
IDOC typedef struct GDrawVertexBuffer GDrawVertexBuffer;
/* An opaque handle to an internal GDraw vertex buffer. */
//idoc(parent,GDrawAPI_Base)
IDOC typedef struct gswf_recti
{
S32 x0,y0; // Minimum corner of the rectangle
S32 x1,y1; // Maximum corner of the rectangle
} gswf_recti;
/* A 2D rectangle with integer coordinates specifying its minimum and maximum corners. */
IDOC typedef struct gswf_rectf
{
F32 x0,y0; // Minimum corner of the rectangle
F32 x1,y1; // Maximum corner of the rectangle
} gswf_rectf;
/* A 2D rectangle with floating-point coordinates specifying its minimum and maximum corners. */
IDOC typedef struct gswf_matrix
{
union {
F32 m[2][2]; // 2x2 transform matrix
struct {
F32 m00; // Alternate name for m[0][0], for coding convenience
F32 m01; // Alternate name for m[0][1], for coding convenience
F32 m10; // Alternate name for m[1][0], for coding convenience
F32 m11; // Alternate name for m[1][1], for coding convenience
};
};
F32 trans[2]; // 2D translation vector (the affine component of the matrix)
} gswf_matrix;
/* A 2D transform matrix plus a translation offset. */
#define GDRAW_STATS_batches 1
#define GDRAW_STATS_blits 2
#define GDRAW_STATS_alloc_tex 4
#define GDRAW_STATS_frees 8
#define GDRAW_STATS_defrag 16
#define GDRAW_STATS_rendtarg 32
#define GDRAW_STATS_clears 64
IDOC typedef struct GDrawStats
{
S16 nonzero_flags; // which of the fields below are non-zero
U16 num_batches; // number of batches, e.g. DrawPrim, DrawPrimUP
U16 num_blits; // number of blit operations (resolve, msaa resolve, blend readback)
U16 freed_objects; // number of cached objects freed
U16 defrag_objects; // number of cached objects defragmented
U16 alloc_tex; // number of textures/buffers allocated
U16 rendertarget_changes; // number of rendertarget changes
U16 num_clears;
//0 mod 8
U32 drawn_indices; // number of indices drawn (3 times number of triangles)
U32 drawn_vertices; // number of unique vertices referenced
U32 num_blit_pixels;// number of pixels in blit operations
U32 alloc_tex_bytes;// number of bytes in textures/buffers allocated
U32 freed_bytes; // number of bytes in freed cached objects
U32 defrag_bytes; // number of bytes in defragmented cached objects
U32 cleared_pixels; // number of pixels cleared by clear operation
U32 reserved;
//0 mod 8
} GDrawStats;
/* A structure with statistics information to show in resource browser/Telemetry */
////////////////////////////////////////////////////////////
//
// Queries
//
//idoc(parent,GDrawAPI_Queries)
IDOC typedef enum gdraw_bformat
{
GDRAW_BFORMAT_vbib, // Platform uses vertex and index buffers
GDRAW_BFORMAT_wii_dlist, // Platform uses Wii-style display lists
GDRAW_BFORMAT_vbib_single_format, // Platform uses vertex and index buffers, but doesn't support multiple vertex formats in a single VB
GDRAW_BFORMAT__count,
} gdraw_bformat;
/* Specifies what data format GDraw expects in MakeVertexBuffer_* and DrawIndexedTriangles.
Most supported platforms prefer Vertex and Index buffers so that's what we use,
but this format turns out to be somewhat awkward for Wii, so we use the native
graphics processor display list format on that platform. */
IDOC typedef struct GDrawInfo
{
S32 num_stencil_bits; // number of (possibly emulated) stencil buffer bits
U32 max_id; // number of unique values that can be easily encoded in zbuffer
U32 max_texture_size; // edge length of largest square texture supported by hardware
U32 buffer_format; // one of $gdraw_bformat
rrbool shared_depth_stencil; // does 0'th framebuffer share depth & stencil with others? (on GL it can't?)
rrbool always_mipmap; // if GDraw can generate mipmaps nearly for free, then set this flag
rrbool conditional_nonpow2; // non-pow2 textures supported, but only using clamp and without mipmaps
rrbool has_rendertargets; // if true, then there is no rendertarget stack support
rrbool no_nonpow2; // non-pow2 textures aren't supported at all
} GDrawInfo; // must be a multiple of 8
/* $GDrawInfo contains the information that Iggy needs to know about
what a GDraw implementation supports and what limits it places on
certain important values. */
IDOC typedef void RADLINK gdraw_get_info(GDrawInfo *d);
/* Iggy queries this at the beginning of rendering to get information
about the viewport and the device capabilities. */
////////////////////////////////////////////////////////////
//
// Drawing State
//
//idoc(parent,GDrawAPI_DrawingState)
IDOC typedef enum gdraw_blend
{
GDRAW_BLEND_none, // Directly copy
GDRAW_BLEND_alpha, // Use the source alpha channel to modulate its contribution
GDRAW_BLEND_multiply, // Multiply colors componentwise
GDRAW_BLEND_add, // Add the source and destination together
GDRAW_BLEND_filter, // Uses a secondary $gdraw_filter specification to determine how to blend
GDRAW_BLEND_special, // Uses a secondary $gdraw_blendspecial specification to determine how to blend
GDRAW_BLEND__count,
} gdraw_blend;
/* Identifier indicating the type of blending operation to use when rendering.*/
IDOC typedef enum gdraw_blendspecial
{
GDRAW_BLENDSPECIAL_layer, // s
GDRAW_BLENDSPECIAL_multiply, // s*d
GDRAW_BLENDSPECIAL_screen, // sa*da - (da-d)*(sa-s)
GDRAW_BLENDSPECIAL_lighten, // max(sa*d,s*da)
GDRAW_BLENDSPECIAL_darken, // min(sa*d,s*da)
GDRAW_BLENDSPECIAL_add, // min(d+s,1.0)
GDRAW_BLENDSPECIAL_subtract, // max(d-s,0.0)
GDRAW_BLENDSPECIAL_difference, // abs(sa*d-s*da)
GDRAW_BLENDSPECIAL_invert, // sa*(da-d)
GDRAW_BLENDSPECIAL_overlay, // d < da/2.0 ? (2.0*s*d) : (sa*da - 2.0*(da-d)*(sa-s))
GDRAW_BLENDSPECIAL_hardlight, // s < sa/2.0 ? (2.0*s*d) : (sa*da - 2.0*(da-d)*(sa-s))
// these do extra-special math on the output alpha
GDRAW_BLENDSPECIAL_erase, // d*(1.0-sa)
GDRAW_BLENDSPECIAL_alpha_special, // d*sa
GDRAW_BLENDSPECIAL__count,
} gdraw_blendspecial;
/* Specifies a type of "special" blend mode, which is defined as one
that has to read from the framebuffer to compute its effect.
These modes are only used with a 1-to-1 textured quad containing
the exact output data in premultiplied alpha. They all need to
read from the framebuffer to compute their effect, so a GDraw
implementation will usually need a custom path to handle that.
Users will not warn in advance whether you're going to need this
operation, so implementations either need to always render to a
texture in case it happens, or copy the framebuffer to a texture
when it does.
Note that $(gdraw_blendspecial::GDRAW_BLENDSPECIAL_erase) and
$(gdraw_blendspecial::GDRAW_BLENDSPECIAL_alpha_special) are unique
among $gdraw_blendspecial modes in that they may not actually need
to be implemented with the destination input as a texture if
the destination buffer doesn't have an alpha channel. */
// (@OPTIMIZE: the last filter in each chain could be combined with
// the final blend, although only worth doing if the final blend is
// ALPHA/ADD/MULTIPLY--it's usually ALPHA though so worth doing!)
IDOC typedef enum gdraw_filter
{
GDRAW_FILTER_blur, // Blurs the source image
GDRAW_FILTER_colormatrix, // Transform RGB pixel values by a matrix
GDRAW_FILTER_bevel, // Bevels the source image
GDRAW_FILTER_dropshadow, // Adds a dropshadow underneath the source image
GDRAW_FILTER__count,
} gdraw_filter;
/* Specifies a type of post-processing graphics filter.
These modes are only used to implement filter effects, and will
always be blending from a temporary buffer to another temporary
buffer with no blending, so in general they should not require
any additional input.
*/
IDOC typedef enum gdraw_texture
{
GDRAW_TEXTURE_none, // No texture applied
GDRAW_TEXTURE_normal, // Texture is bitmap or linear gradient
GDRAW_TEXTURE_alpha, // Texture is an alpha-only font bitmap
GDRAW_TEXTURE_radial, // Texture is a radial gradient
GDRAW_TEXTURE_focal_gradient, // Texture is a "focal" radial gradient
GDRAW_TEXTURE_alpha_test, // Texture is an alpha-only font bitmap, alpha test for alpha >= 0.5
GDRAW_TEXTURE__count,
} gdraw_texture;
/* Specifies how to apply a texture while rendering. */
IDOC typedef enum gdraw_wrap
{
GDRAW_WRAP_clamp, // Texture coordinates clamped to edges
GDRAW_WRAP_repeat, // Texture repeats periodically
GDRAW_WRAP_mirror, // Repeat periodically, mirror on odd repetititions
GDRAW_WRAP_clamp_to_border, // only used internally by some GDraws
GDRAW_WRAP__count,
} gdraw_wrap;
/* Specifies what to do with texture coordinates outside [0,1]. */
typedef struct GDrawRenderState
{
S32 id; // Object "identifier" used for high-quality AA mode
U32 test_id:1; // Whether to test zbuffer == id
U32 set_id:1; // Whether to set zbuffer == id
U32 use_world_space:1; // Whether primitive is defined in object space or world space
U32 scissor:1; // Whether rendering will be clipped to $(GDrawRenderState::scissor_rect)
U32 identical_state:1; // Whether state is identical to the one used for the previous draw call
U32 unused:27;
//aligned 0 mod 8
U8 texgen0_enabled; // Whether to use texgen for tex0
U8 tex0_mode; // One of $gdraw_texture
U8 wrap0; // One of $gdraw_wrap
U8 nearest0; // Whether to sample texture 0 nearest neighbor
U8 blend_mode; // One of $gdraw_blend
U8 special_blend; // One of $gdraw_blendspecial (used only if $(GDrawRenderState::blend_mode) == $(gdraw_blend::GDRAW_BLEND_special)
U8 filter; // One of $gdraw_filter (used only if $(GDrawRenderState::blend_mode) == $(gdraw_blend::GDRAW_BLEND_filter)
U8 filter_mode; // Used to select the right compositing operation for the $(gdraw_filter::GDRAW_FILTER_bevel) and $(gdraw_filter::GDRAW_FILTER_dropshadow) modes
//aligned 0 mod 8
U8 stencil_test; // Only draw if these stencil bits are "set"
U8 stencil_set; // "Set" these stencil bits (note that actual implementation initializes stencil to 1, and "set" makes them 0)
U8 reserved[2]; // Currently unused (used to make padding to 4/8-byte boundary for following pointer explicit)
S32 blur_passes; // For filters that include blurring, this is the number of box filter passes to run
//align 0 mod 8
S16 *cxf_add; // Color transform addition (discourage additive alpha!)
GDrawTexture *tex[3]; // One or more textures to apply -- need 3 for gradient dropshadow.
//0 mod 8
F32 *edge_matrix; // Screen to object space matrix (for edge antialiasing)
gswf_matrix *o2w; // Object-to-world matrix
// --- Everything below this point must be manually initialized
//0 mod 8
F32 color[4]; // Color of the object
//0 mod 8
gswf_recti scissor_rect; // The rectangle to which rendering will be clipped if $(GDrawRenderState::scissor) is set
//0 mod 8
// --- Everything below this point might be uninitialized if it's not used for this particular render state
F32 s0_texgen[4]; // "s" (x) row of texgen matrix
F32 t0_texgen[4]; // "t" (y) row of texgen matrix
//0 mod 8
F32 focal_point[4]; // Data used for $(gdraw_texgen_mode::GDRAW_TEXTURE_focal_gradient)
//0 mod 8
F32 blur_x,blur_y; // The size of the box filter, where '1' is the identity and 2 adds half a pixel on each side
//0 mod 8
F32 shader_data[20]; // Various data that depends on filter (e.g. drop shadow direction, color)
} GDrawRenderState;
/* Encapsulation of the entire drawing state that affects a rendering command. */
IDOC typedef void RADLINK gdraw_set_view_size_and_world_scale(S32 w, S32 h, F32 x_world_to_pixel, F32 y_world_to_pixel);
/* Sets the size of the rendering viewport and the world to pixel scaling.
Iggy calls this function with the full size that the viewport would
be if it were rendered untiled, even if it will eventually be
rendered as a collection of smaller tiles.
The world scale is used to compensate non-square pixel aspect ratios
when rendering wide lines. Both scale factors are 1 unless Iggy is
running on a display with non-square pixels. */
typedef void RADLINK gdraw_set_3d_transform(F32 *mat); /* mat[3][4] */
IDOC typedef void RADLINK gdraw_render_tile_begin(S32 tx0, S32 ty0, S32 tx1, S32 ty1, S32 pad, GDrawStats *stats);
/* Begins rendering of a sub-region of the rendered image. */
IDOC typedef void RADLINK gdraw_render_tile_end(GDrawStats *stats);
/* Ends rendering of a sub-region of the rendered image. */
IDOC typedef void RADLINK gdraw_rendering_begin(void);
/* Begins rendering; takes control of the graphics API. */
IDOC typedef void RADLINK gdraw_rendering_end(void);
/* Ends rendering; gives up control of the graphics API. */
////////////////////////////////////////////////////////////
//
// Drawing
//
//idoc(parent,GDrawAPI_Drawing)
IDOC typedef void RADLINK gdraw_clear_stencil_bits(U32 bits);
/* Clears the 'bits' parts of the stencil value in the entire framebuffer to the default value. */
IDOC typedef void RADLINK gdraw_clear_id(void);
/* Clears the 'id' buffer, which is typically the z-buffer but can also be the stencil buffer. */
IDOC typedef void RADLINK gdraw_filter_quad(GDrawRenderState *r, S32 x0, S32 y0, S32 x1, S32 y1, GDrawStats *stats);
/* Draws a special quad in viewport-relative pixel space.
May be normal, may be displaced by filters, etc. and require multiple passes,
may apply special blending (and require extra resolves/rendertargets)
for filter/blend.,
The x0,y0,x1,y1 always describes the "input" box. */
IDOC typedef struct GDrawPrimitive
{
F32 *vertices; // Pointer to an array of $gswf_vertex_xy, $gswf_vertex_xyst, or $gswf_vertex_xyoffs
U16 *indices; // Pointer to an array of 16-bit indices into $(GDrawPrimitive::vertices)
S32 num_vertices; // Count of elements in $(GDrawPrimitive::vertices)
S32 num_indices; // Count of elements in $(GDrawPrimitive::indices)
S32 vertex_format; // One of $gdraw_vformat, specifying the type of element in $(GDrawPrimitive::vertices)
U32 uniform_count;
F32 *uniforms;
U8 drawprim_mode;
} GDrawPrimitive;
/* Specifies the vertex and index data necessary to draw a batch of graphics primitives. */
IDOC typedef void RADLINK gdraw_draw_indexed_triangles(GDrawRenderState *r, GDrawPrimitive *prim, GDrawVertexBuffer *buf, GDrawStats *stats);
/* Draws a collection of indexed triangles, ignoring special filters or blend modes.
If buf is NULL, then the pointers in 'prim' are machine pointers, and
you need to make a copy of the data (note currently all triangles
implementing strokes (wide lines) go this path).
If buf is non-NULL, then use the appropriate vertex buffer, and the
pointers in prim are actually offsets from the beginning of the
vertex buffer -- i.e. offset = (char*) prim->whatever - (char*) NULL;
(note there are separate spaces for vertices and indices; e.g. the
first mesh in a given vertex buffer will normally have a 0 offset
for the vertices and a 0 offset for the indices)
*/
IDOC typedef void RADLINK gdraw_set_antialias_texture(S32 width, U8 *rgba);
/* Specifies the 1D texture data to be used for the antialiasing gradients.
'rgba' specifies the pixel values in rgba byte order. This will only be called
once during initialization. */
////////////////////////////////////////////////////////////
//
// Texture and Vertex Buffers
//
//idoc(parent,GDrawAPI_Buffers)
IDOC typedef enum gdraw_texture_format
{
// Platform-independent formats
GDRAW_TEXTURE_FORMAT_rgba32, // 32bpp RGBA data in platform-preferred byte order (returned by $gdraw_make_texture_begin as $gdraw_texture_type)
GDRAW_TEXTURE_FORMAT_font, // Alpha-only data with at least 4 bits/pixel. Data is submitted as 8 bits/pixel, conversion (if necessary) done by GDraw.
// First platform-specific format index (for reference)
GDRAW_TEXTURE_FORMAT__platform = 16,
// In the future, we will support platform-specific formats and add them to this list.
} gdraw_texture_format;
/* Describes the format of a texture submitted to GDraw. */
IDOC typedef enum gdraw_texture_type
{
GDRAW_TEXTURE_TYPE_rgba, // Raw 4-channel packed texels, in OpenGL-standard order
GDRAW_TEXTURE_TYPE_bgra, // Raw 4-channel packed texels, in Direct3D-standard order
GDRAW_TEXTURE_TYPE_argb, // Raw 4-channel packed texels, in Flash native order
GDRAW_TEXTURE_TYPE__count,
} gdraw_texture_type;
/* Describes the channel layout of a RGBA texture submitted to GDraw. */
IDOC typedef struct GDraw_MakeTexture_ProcessingInfo
{
U8 *texture_data; // Pointer to the texture image bits
S32 num_rows; // Number of rows to upload in the current chunk
S32 stride_in_bytes; // Distance between a given pixel and the first pixel in the next row
S32 texture_type; // One of $gdraw_texture_type
U32 temp_buffer_bytes; // Size of temp buffer in bytes
U8 *temp_buffer; // Temp buffer for GDraw to work in (used during mipmap creation)
void *p0,*p1,*p2,*p3,*p4,*p5,*p6,*p7; // Pointers for GDraw to store data across "passes" (never touched by Iggy)
U32 i0, i1, i2, i3, i4, i5, i6, i7; // Integers for GDraw to store data across "passes" (never touched by Iggy)
} GDraw_MakeTexture_ProcessingInfo;
/* $GDraw_MakeTexture_ProcessingInfo is used when building a texture. */
IDOC typedef struct GDraw_Texture_Description {
S32 width; // Width of the texture in pixels
S32 height; // Height of the texture in pixels
U32 size_in_bytes; // Size of the texture in bytes
} GDraw_Texture_Description;
/* $GDraw_Texture_Description contains information about a texture. */
IDOC typedef U32 gdraw_maketexture_flags;
#define GDRAW_MAKETEXTURE_FLAGS_mipmap 1 IDOC // Generates mip-maps for the texture
#define GDRAW_MAKETEXTURE_FLAGS_updatable 2 IDOC // Set if the texture might be updated subsequent to its initial submission
#define GDRAW_MAKETEXTURE_FLAGS_never_flush 4 IDOC // Set to request that the texture never be flushed from the GDraw cache
/* Flags that control the submission and management of GDraw textures. */
IDOC typedef void RADLINK gdraw_set_texture_unique_id(GDrawTexture *tex, void *old_unique_id, void *new_unique_id);
/* Changes unique id of a texture, only used for TextureSubstitution */
IDOC typedef rrbool RADLINK gdraw_make_texture_begin(void *unique_id,
S32 width, S32 height, gdraw_texture_format format, gdraw_maketexture_flags flags,
GDraw_MakeTexture_ProcessingInfo *output_info, GDrawStats *stats);
/* Begins specifying a new texture.
$:unique_id Unique value specified by Iggy that you can use to identify a reference to the same texture even if its handle has been discarded
$:return Error code if there was a problem, IGGY_RESULT_OK otherwise
*/
IDOC typedef rrbool RADLINK gdraw_make_texture_more(GDraw_MakeTexture_ProcessingInfo *info);
/* Continues specifying a new texture.
$:info The same handle initially passed to $gdraw_make_texture_begin
$:return True if specification can continue, false if specification must be aborted
*/
IDOC typedef GDrawTexture * RADLINK gdraw_make_texture_end(GDraw_MakeTexture_ProcessingInfo *info, GDrawStats *stats);
/* Ends specification of a new texture.
$:info The same handle initially passed to $gdraw_make_texture_begin
$:return Handle for the newly created texture, or NULL if an error occured
*/
IDOC typedef rrbool RADLINK gdraw_update_texture_begin(GDrawTexture *tex, void *unique_id, GDrawStats *stats);
/* Begins updating a previously submitted texture.
$:unique_id Must be the same value initially passed to $gdraw_make_texture_begin
$:return True on success, false otherwise and the texture must be recreated
*/
IDOC typedef void RADLINK gdraw_update_texture_rect(GDrawTexture *tex, void *unique_id, S32 x, S32 y, S32 stride, S32 w, S32 h, U8 *data, gdraw_texture_format format);
/* Updates a rectangle in a previously submitted texture.
$:format Must be the $gdraw_texture_format that was originally passed to $gdraw_make_texture_begin for this texture.
*/
IDOC typedef void RADLINK gdraw_update_texture_end(GDrawTexture *tex, void *unique_id, GDrawStats *stats);
/* Ends an update to a previously submitted texture.
$:unique_id Must be the same value initially passed to $gdraw_make_texture_begin (and hence $gdraw_update_texture_begin)
*/
IDOC typedef void RADLINK gdraw_describe_texture(GDrawTexture *tex, GDraw_Texture_Description *desc);
/* Returns a texture description for a given GDraw texture. */
IDOC typedef GDrawTexture * RADLINK gdraw_make_texture_from_resource(U8 *resource_file, S32 file_len, void *texture);
/* Loads a texture from a resource file and returns a wrapped pointer. */
IDOC typedef void RADLINK gdraw_free_texture_from_resource(GDrawTexture *tex);
/* Frees a texture created with gdraw_make_texture_from_resource. */
IDOC typedef struct gswf_vertex_xy
{
F32 x,y; // Position of the vertex
} gswf_vertex_xy;
/* A 2D point with floating-point position. */
IDOC typedef struct gswf_vertex_xyoffs
{
F32 x,y; // Position of the vertex
S16 aa; // Stroke/aa texcoord
S16 dx, dy; // Vector offset from the position, used for anti-aliasing (signed 11.5 fixed point)
S16 unused;
} gswf_vertex_xyoffs;
/* A 2D point with floating-point position, additional integer parameter, and integer anti-aliasing offset vector. */
IDOC typedef struct gswf_vertex_xyst
{
F32 x,y; // Position of the vertex
F32 s,t; // Explicit texture coordinates for rectangles
} gswf_vertex_xyst;
/* A 2D point with floating-point position and texture coordinates. */
typedef int gdraw_verify_size_xy [sizeof(gswf_vertex_xy ) == 8 ? 1 : -1];
typedef int gdraw_verify_size_xyoffs[sizeof(gswf_vertex_xyoffs) == 16 ? 1 : -1];
typedef int gdraw_verify_size_xyst [sizeof(gswf_vertex_xyst ) == 16 ? 1 : -1];
IDOC typedef enum gdraw_vformat
{
GDRAW_vformat_v2, // Indicates vertices of type $gswf_vertex_xy (8 bytes per vertex)
GDRAW_vformat_v2aa, // Indicates vertices of type $gswf_vertex_xyoffs (16 bytes per vertex)
GDRAW_vformat_v2tc2, // Indicates vertices of type $gswf_vertex_xyst (16 bytes per vertex)
GDRAW_vformat__basic_count,
GDRAW_vformat_ihud1 = GDRAW_vformat__basic_count, // primary format for ihud, currently v2tc2mat4 (20 bytes per vertex)
GDRAW_vformat__count,
GDRAW_vformat_mixed, // Special value that denotes a VB containing data in multiple vertex formats. Never used when drawing!
} gdraw_vformat;
/* Identifies one of the vertex data types. */
IDOC typedef struct GDraw_MakeVertexBuffer_ProcessingInfo
{
U8 *vertex_data; // location to write vertex data
U8 *index_data; // location to write index data
S32 vertex_data_length; // size of buffer to write vertex data
S32 index_data_length; // size of buffer to write index data
void *p0,*p1,*p2,*p3,*p4,*p5,*p6,*p7; // Pointers for GDraw to store data across "passes" (never touched by Iggy)
U32 i0, i1, i2, i3, i4, i5, i6, i7; // Integers for GDraw to store data across "passes" (never touched by Iggy)
} GDraw_MakeVertexBuffer_ProcessingInfo;
/* $GDraw_MakeVertexBuffer_ProcessingInfo is used when building a vertex buffer. */
IDOC typedef struct GDraw_VertexBuffer_Description {
S32 size_in_bytes; // Size of the vertex buffer in bytes
} GDraw_VertexBuffer_Description;
/* $GDraw_VertexBuffer_Description contains information about a vertex buffer. */
IDOC typedef rrbool RADLINK gdraw_make_vertex_buffer_begin(void *unique_id, gdraw_vformat vformat, S32 vdata_len_in_bytes, S32 idata_len_in_bytes, GDraw_MakeVertexBuffer_ProcessingInfo *info, GDrawStats *stats);
/* Begins specifying a new vertex buffer.
$:unique_id Unique value that identifies this texture, across potentially multiple flushes and re-creations of its $GDrawTexture handle in GDraw
$:vformat One of $gdraw_vformat, denoting the format of the vertex data submitted
$:return false if there was a problem, true if ok
*/
IDOC typedef rrbool RADLINK gdraw_make_vertex_buffer_more(GDraw_MakeVertexBuffer_ProcessingInfo *info);
/* Continues specifying a new vertex buffer.
$:info The same handle initially passed to $gdraw_make_vertex_buffer_begin
$:return True if specification can continue, false if specification must be aborted
*/
IDOC typedef GDrawVertexBuffer * RADLINK gdraw_make_vertex_buffer_end(GDraw_MakeVertexBuffer_ProcessingInfo *info, GDrawStats *stats);
/* Ends specification of a new vertex buffer.
$:info The same handle initially passed to $gdraw_make_texture_begin
$:return Handle for the newly created vertex buffer
*/
IDOC typedef void RADLINK gdraw_describe_vertex_buffer(GDrawVertexBuffer *buffer, GDraw_VertexBuffer_Description *desc);
/* Returns a description for a given GDrawVertexBuffer */
IDOC typedef rrbool RADLINK gdraw_try_to_lock_texture(GDrawTexture *tex, void *unique_id, GDrawStats *stats);
/* Tells GDraw that a $GDrawTexture is going to be referenced.
$:unique_id Must be the same value initially passed to $gdraw_make_texture_begin
*/
IDOC typedef rrbool RADLINK gdraw_try_to_lock_vertex_buffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats);
/* Tells GDraw that a $GDrawVertexBuffer is going to be referenced.
$:unique_id Must be the same value initially passed to $gdraw_make_vertex_buffer_begin
*/
IDOC typedef void RADLINK gdraw_unlock_handles(GDrawStats *stats);
/* Indicates that the user of GDraw will not try to reference anything without locking it again.
Note that although a call to $gdraw_unlock_handles indicates that
all $GDrawTexture and $GDrawVertexBuffer handles that have had a
"unique_id" specified will no longer be referenced by the user of
GDraw, it does not affect those $GDrawTexture handles that were
created by $gdraw_start_texture_draw_buffer with a unique_id of 0.
*/
IDOC typedef void RADLINK gdraw_free_vertex_buffer(GDrawVertexBuffer *vb, void *unique_id, GDrawStats *stats);
/* Free a vertex buffer and invalidate the handle
$:unique_id Must be the same value initially passed to $gdraw_make_vertex_buffer_begin
*/
IDOC typedef void RADLINK gdraw_free_texture(GDrawTexture *t, void *unique_id, GDrawStats *stats);
/* Free a texture and invalidate the handle.
$:unique_id Must be the same value initially passed to $gdraw_make_texture_begin, or 0 for a texture created by $gdraw_end_texture_draw_buffer
*/
////////////////////////////////////////////////////////////
//
// Render targets
//
//idoc(parent,GDrawAPI_Targets)
IDOC typedef U32 gdraw_texturedrawbuffer_flags;
#define GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_color 1 IDOC // Tells GDraw that you will need the color channel when rendering a texture
#define GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_alpha 2 IDOC // Tells GDraw that you will need the alpha channel when rendering a texture
#define GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_stencil 4 IDOC // Tells GDraw that you will need the stencil channel when rendering a texture
#define GDRAW_TEXTUREDRAWBUFFER_FLAGS_needs_id 8 IDOC // Tells GDraw that you will need the id channel when rendering a texture
/* Flags that control rendering to a texture. */
IDOC typedef rrbool RADLINK gdraw_texture_draw_buffer_begin(gswf_recti *region, gdraw_texture_format format, gdraw_texturedrawbuffer_flags flags, void *unique_id, GDrawStats *stats);
/* Starts rendering all GDraw commands to a new texture.
Creates a rendertarget with destination alpha, initializes to all 0s and prepares to render into it
*/
IDOC typedef GDrawTexture * RADLINK gdraw_texture_draw_buffer_end(GDrawStats *stats);
/* Ends rendering GDraw commands to a texture, and returns the texture created.
You can get the size of the resulting texture with $gdraw_query_texture_size.
*/
////////////////////////////////////////////////////////////
//
// Masking
//
//idoc(parent,GDrawAPI_Masking)
IDOC typedef void RADLINK gdraw_draw_mask_begin(gswf_recti *region, S32 mask_bit, GDrawStats *stats);
/* Start a masking operation on the given region for the specified mask bit.
For most drivers, no special preparation is necessary to start masking, so this is a no-op.
*/
IDOC typedef void RADLINK gdraw_draw_mask_end(gswf_recti *region, S32 mask_bit, GDrawStats *stats);
/* End a masking operation on the given region for the specified mask bit.
For most drivers, no special preparation is necessary to end masking, so this is a no-op.
*/
////////////////////////////////////////////////////////////
//
// GDraw API Function table
//
//idoc(parent,GDrawAPI_Base)
IDOC struct GDrawFunctions
{
// queries
gdraw_get_info *GetInfo;
// drawing state
gdraw_set_view_size_and_world_scale * SetViewSizeAndWorldScale;
gdraw_render_tile_begin * RenderTileBegin;
gdraw_render_tile_end * RenderTileEnd;
gdraw_set_antialias_texture * SetAntialiasTexture;
// drawing
gdraw_clear_stencil_bits * ClearStencilBits;
gdraw_clear_id * ClearID;
gdraw_filter_quad * FilterQuad;
gdraw_draw_indexed_triangles * DrawIndexedTriangles;
gdraw_make_texture_begin * MakeTextureBegin;
gdraw_make_texture_more * MakeTextureMore;
gdraw_make_texture_end * MakeTextureEnd;
gdraw_make_vertex_buffer_begin * MakeVertexBufferBegin;
gdraw_make_vertex_buffer_more * MakeVertexBufferMore;
gdraw_make_vertex_buffer_end * MakeVertexBufferEnd;
gdraw_try_to_lock_texture * TryToLockTexture;
gdraw_try_to_lock_vertex_buffer * TryToLockVertexBuffer;
gdraw_unlock_handles * UnlockHandles;
gdraw_free_texture * FreeTexture;
gdraw_free_vertex_buffer * FreeVertexBuffer;
gdraw_update_texture_begin * UpdateTextureBegin;
gdraw_update_texture_rect * UpdateTextureRect;
gdraw_update_texture_end * UpdateTextureEnd;
// rendertargets
gdraw_texture_draw_buffer_begin * TextureDrawBufferBegin;
gdraw_texture_draw_buffer_end * TextureDrawBufferEnd;
gdraw_describe_texture * DescribeTexture;
gdraw_describe_vertex_buffer * DescribeVertexBuffer;
// new functions are always added at the end, so these have no structure
gdraw_set_texture_unique_id * SetTextureUniqueID;
gdraw_draw_mask_begin * DrawMaskBegin;
gdraw_draw_mask_end * DrawMaskEnd;
gdraw_rendering_begin * RenderingBegin;
gdraw_rendering_end * RenderingEnd;
gdraw_make_texture_from_resource * MakeTextureFromResource;
gdraw_free_texture_from_resource * FreeTextureFromResource;
gdraw_set_3d_transform * Set3DTransform;
};
/* The function interface called by Iggy to render graphics on all
platforms.
So that Iggy can integrate with the widest possible variety of
rendering scenarios, all of its renderer-specific drawing calls
go through this table of function pointers. This allows you
to dynamically configure which of RAD's supplied drawing layers
you wish to use, or to integrate it directly into your own
renderer by implementing your own versions of the drawing
functions Iggy requires.
*/
RADDEFEND
#endif

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -936,11 +936,8 @@ return -1;
PIXEndNamedEvent();
// Render game graphics.
// On Linux, always call run_middle() so mc->screen (TitleScreen etc.)
// renders even when the game session has not yet started (Iggy Flash UI
// is unavailable).
pMinecraft->run_middle();
if (app.GetGameStarted()) {
pMinecraft->run_middle();
app.SetAppPaused(
g_NetworkManager.IsLocalGame() &&
g_NetworkManager.GetPlayerCount() == 1 &&

View file

@ -6,12 +6,36 @@
#include "../../Textures/Textures.h"
// GDraw GL backend for Linux
#include "Iggy/gdraw/gdraw_glfw.h"
#define _ENABLEIGGY
#include "Iggy/gdraw/gdraw_sdl.h"
ConsoleUIController ui;
static void restoreFixedFunctionStateAfterIggy() {
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.1f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glClientActiveTexture(GL_TEXTURE1);
glActiveTexture(GL_TEXTURE1);
glDisable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glClientActiveTexture(GL_TEXTURE0);
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
}
void ConsoleUIController::init(S32 w, S32 h) {
#ifdef _ENABLEIGGY
// Shared init
@ -22,22 +46,19 @@ void ConsoleUIController::init(S32 w, S32 h) {
if (!gdraw_funcs) {
app.DebugPrintf("Failed to initialise GDraw GL!\n");
fprintf(stderr,
"[Linux_UIController] Failed to initialise GDraw GL!\n");
// nott fatal for now
} else {
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_vertexbuffer, 5000,
16 * 1024 * 1024);
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_texture, 5000,
128 * 1024 * 1024);
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_rendertarget, 10,
32 * 1024 * 1024);
IggySetGDraw(gdraw_funcs);
app.FatalLoadError();
}
postInit();
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_vertexbuffer, 5000,
16 * 1024 * 1024);
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_texture, 5000,
128 * 1024 * 1024);
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_rendertarget, 10,
32 * 1024 * 1024);
IggySetGDraw(gdraw_funcs);
#endif
postInit();
}
void ConsoleUIController::render() {
@ -45,11 +66,15 @@ void ConsoleUIController::render() {
if (!gdraw_funcs) return;
gdraw_GL_SetTileOrigin(0, 0, 0);
if (!app.GetGameStarted() && gdraw_funcs->ClearID) {
gdraw_funcs->ClearID();
}
// render
renderScenes();
gdraw_GL_NoMoreGDrawThisFrame();
restoreFixedFunctionStateAfterIggy();
#endif
}
@ -113,4 +138,4 @@ void ConsoleUIController::shutdown() {
gdraw_funcs = nullptr;
}
#endif
}
}

View file

@ -30,6 +30,9 @@
#include "winapi_stubs.h"
#include "d3d11_stubs.h"
#include "xbox_stubs.h"
#ifndef _ENABLEIGGY
#include "iggy_stubs.h"
#endif
#endif // STUBS_H

View file

@ -3,7 +3,7 @@
#pragma once
#include "../../Windows64/Iggy/include/iggy.h"
#include "../Iggy/include/iggy.h"
#define STUBBED \
{ \

View file

@ -299,6 +299,7 @@ typedef XUID GameSessionUID;
// Linux build: avoid pulling in Windows64 platform headers (they cause
// symbol/class redefinitions). Use Orbis-compatible stubs and Linux controller.
#include "../Platform/Linux/Linux_App.h"
#include "../Platform/Linux/Iggy/include/iggy.h"
#include "../Platform/Orbis/Sentient/SentientTelemetryCommon.h"
#include "../Platform/Orbis/Sentient/DynamicConfigurations.h"
#include "../Platform/Orbis/GameConfig/Minecraft.spa.h"

View file

@ -28,7 +28,7 @@
#include "../../Minecraft.World/Level/LevelChunk.h"
#include "../../Minecraft.World/WorldGen/Biomes/Biome.h"
#define RENDER_HUD 1
#define RENDER_HUD 0
// #ifndef _XBOX
// #undef RENDER_HUD
@ -496,7 +496,8 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
int y0 = 0;
// 4J-PB - no hardcore in xbox
// if
// (minecraft.level.getLevelData().isHardcore()) { y0 = 5;
// (minecraft.level.getLevelData().isHardcore()) {
// y0 = 5;
// }
blit(xo, yo, 16 + bg * 9, 9 * 0, 9, 9);
if (blink) {
@ -571,7 +572,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
////////////////////////////
if (bDisplayGui) {
// glDisable(GL_BLEND); 4J - removed - we want
//to be able to fade our gui
// to be able to fade our gui
glEnable(GL_RESCALE_NORMAL);

View file

@ -41,14 +41,11 @@ if host_machine.system() == 'linux'
'find "'
+ meson.current_source_dir() / 'Platform/Linux'
+ '" \\( -name "*.cpp" -o -name "*.c" \\) ',
check : true,
check : true,
).stdout().strip().split('\n')
endif
client = executable('Minecraft.Client',
client_sources + platform_sources + localisation[1],
include_directories : include_directories('Platform'),
dependencies : [
client_dependencies = [
render_dep,
input_dep,
profile_dep,
@ -60,7 +57,26 @@ client = executable('Minecraft.Client',
thread_dep,
thread_dep,
dependency('zlib'),
],
]
if get_option('enable_vsync')
global_cpp_defs += '-DENABLE_VSYNC'
endif
if get_option('enable_shiggy')
shiggy_dep = dependency(
'shiggy',
fallback : ['shiggy', 'shiggy_dep'],
)
global_cpp_defs += '-D_ENABLEIGGY'
client_dependencies += shiggy_dep
endif
client = executable('Minecraft.Client',
client_sources + platform_sources + localisation[1],
include_directories : include_directories('Platform', 'Platform/Linux/Iggy/include'),
dependencies : client_dependencies,
cpp_args : global_cpp_args + global_cpp_defs + [
'-DUNICODE', '-D_UNICODE',
'-include', meson.current_source_dir() / 'Platform/stdafx.h',

View file

@ -41,6 +41,38 @@ std::wstring convStringToWstring(const std::string& converting) {
return converted;
}
std::u16string convWstringToU16string(const std::wstring& converting) {
std::u16string out;
out.reserve(converting.size());
if constexpr (sizeof(wchar_t) == sizeof(char16_t)) {
// wchar_t is UTF-16: direct copy
out.assign(converting.begin(), converting.end());
} else {
// wchar_t is UTF-32: encode to UTF-16
for (wchar_t wc : converting) {
uint32_t cp = static_cast<uint32_t>(wc);
if (cp <= 0xFFFF) {
// Avoid producing UTF-16 surrogate code points directly
if (cp >= 0xD800 && cp <= 0xDFFF) {
out.push_back(u'\uFFFD'); // replacement char
} else {
out.push_back(static_cast<char16_t>(cp));
}
} else if (cp <= 0x10FFFF) {
cp -= 0x10000;
out.push_back(static_cast<char16_t>(0xD800 + (cp >> 10)));
out.push_back(static_cast<char16_t>(0xDC00 + (cp & 0x3FF)));
} else {
out.push_back(u'\uFFFD'); // invalid code point
}
}
}
return out;
}
// Convert for filename std::wstrings to a straight character pointer for Xbox
// APIs. The returned string is only valid until this function is called again,
// and it isn't thread-safe etc. as I'm just storing the returned name in a
@ -122,4 +154,4 @@ std::wstring parseXMLSpecials(const std::wstring& in) {
out = replaceAll(out, L"&lt;", L"<");
out = replaceAll(out, L"&gt;", L">");
return out;
}
}

View file

@ -30,6 +30,7 @@ T _fromHEXString(const std::wstring& s) {
}
std::wstring convStringToWstring(const std::string& converting);
std::u16string convWstringToU16string(const std::wstring& converting);
const char* wstringtofilename(const std::wstring& name);
std::wstring filenametowstring(const char* name);

View file

@ -1,5 +1,6 @@
project('4jcraft-chucklegrounds', ['cpp', 'c'],
version : '0.1.0',
meson_version: '>= 1.1',
default_options : [
'warning_level=0',
'buildtype=debug', # for now
@ -38,12 +39,6 @@ global_cpp_defs = [
'-DDEBUG',
]
if get_option('enable_vsync')
global_cpp_defs += '-DENABLE_VSYNC'
message('v-sync enabled')
endif
if host_machine.system() == 'linux'
global_cpp_defs += [
'-Dlinux',

View file

@ -1,4 +1,9 @@
option('enable_vsync',
type : 'boolean',
value : true,
description : 'Toggles weather V-Sync will be toggle on or off.')
description : 'Toggles V-Sync and adds options to unlock maximum in-game framerate.')
option('enable_shiggy',
type : 'boolean',
value : true,
description : 'Toggles shimmed PS4 Iggy binaries and UI for x86_64 Linux.')

6
subprojects/shiggy.wrap Normal file
View file

@ -0,0 +1,6 @@
[wrap-git]
url = https://github.com/4jcraft/shiggy.git
revision = main
[provide]
shiggy_dep = shiggy