diff --git a/scripts/build-mach.sh b/scripts/build-mach.sh index 7cfdbd7..cc291dc 100755 --- a/scripts/build-mach.sh +++ b/scripts/build-mach.sh @@ -4,12 +4,6 @@ # @ https://github.com/XMhat/MSEngine # Copyright (c) MS-Design, 2006-present. All Rights Reserved. -# Clear the screen -printf '\33c\e[3J' - -# Set the project directory incase we're not in it -cd ~/Assets/MSEngine - # Set ALPHA, BETA or RELEASE type TYPE=BETA @@ -71,12 +65,17 @@ compile() echo } +# Clear the screen +printf '\33c\e[3J' +# Set the project directory incase we're not in it +cd ~/Assets/MSEngine +if [ $? -ne 0 ]; then exit 2; fi # Compile X86-64 version compile $TYPE x86_64-apple-macos10.12 32 -if [ $? -ne 0 ]; then exit 2; fi +if [ $? -ne 0 ]; then exit 3; fi # Compile ARM64 version compile $TYPE arm64-apple-macos11 64 -if [ $? -ne 0 ]; then exit 3; fi +if [ $? -ne 0 ]; then exit 4; fi # If both binaries available? if [ -f bin/build32.mac ] && [ -f bin/build64.mac ]; then @@ -94,4 +93,4 @@ if [ -f bin/build32.mac ] && [ -f bin/build64.mac ]; then fi # Print end of script -echo ${C1}Completed! +echo ${C1}Completed\! diff --git a/src/fbodef.hpp b/src/fbodef.hpp index 53a6ad4..432e5de 100644 --- a/src/fbodef.hpp +++ b/src/fbodef.hpp @@ -17,35 +17,54 @@ namespace P { // Start of public module namespace constexpr static const size_t /* -- Defines to describe a simple triangle ----------------------------- */ stVertexPerTriangle = 3, // Vertices used in a triangle (3 ofc!) - stTwoTriangles = (stVertexPerTriangle * 2), + stTwoTriangles = stVertexPerTriangle * 2, stTrisPerQuad = 2, // Triangles needed to make a quad /* -- Defines for triangle texture co-ordinates data --------------------- */ + // [0]X: The left 2D pixel co-ordinate. Shader converts it to 3D for us. + // [1]Y: The top 2D pixel co-ordinate. Shader converts it to 3D for us. + // [2]Z: Not being used so that co-ordinate is ignored and assumed 0.0f. + // [3]W: Not being used so that co-ordinate is ignored and assumed 1.0f. stCompsPerCoord = 2, // Floats used to define texcoord (XY) - stFloatsPerCoord = (stVertexPerTriangle * stCompsPerCoord), + stFloatsPerCoord = stVertexPerTriangle * stCompsPerCoord, + // Note: If we need to increase this value in the future, it is important + // that the arrays in 'FboItem.hpp' and 'Fbo.hpp' are updated to reflect the + // change. /* -- Defines for triangle position co-ordinates data--------------------- */ + // [0]X: The left 2D pixel co-ordinate. Shader converts it to 3D for us. + // [1]Y: The top 2D pixel co-ordinate. Shader converts it to 3D for us. + // [2]Z: Not being used so that co-ordinate is ignored and assumed 0.0f. + // [3]W: Not being used so that co-ordinate is ignored and assumed 0.0f. stCompsPerPos = 2, // Floats used to define position (XY) - stFloatsPerPos = (stVertexPerTriangle * stCompsPerPos), + stFloatsPerPos = stVertexPerTriangle * stCompsPerPos, + // Note: If we need to increase this value in the future, it is important + // that the arrays in 'FboItem.hpp', 'Font.hpp', 'Texture.hpp" and 'Fbo.hpp' + // are updated to reflect the change. /* -- Defines for colour intensity data ---------------------------------- */ + // [0]R: The RED intensity of the vertice. + // [1]G: The GREEN intensity of the vertice. + // [2]B: The BLUE intensity of the vertice. + // [3]A: The ALPHA intensity of the vertice. stCompsPerColour = 4, // Floats used to define colour (RGBA) - stFloatsPerColour = (stVertexPerTriangle * stCompsPerColour), + stFloatsPerColour = stVertexPerTriangle * stCompsPerColour, /* -- Totals ------------------------------------------------------------- */ - stFloatsPerTri = (stFloatsPerCoord + stFloatsPerPos + stFloatsPerColour), - stFloatsPerQuad = (stFloatsPerTri * stTrisPerQuad), + stFloatsPerTri = stFloatsPerCoord + stFloatsPerPos + stFloatsPerColour, + stFloatsPerQuad = stFloatsPerTri * stTrisPerQuad, /* -- OpenGL buffer structure -------------------------------------------- */ - stFloatsPerVertex = (stCompsPerCoord + stCompsPerPos + stCompsPerColour), - stBytesPerVertex = (sizeof(GLfloat) * stFloatsPerVertex), + stSizeOfGLfloat = sizeof(GLfloat), + stFloatsPerVertex = stCompsPerCoord + stCompsPerPos + stCompsPerColour, + stBytesPerVertex = stFloatsPerVertex * stSizeOfGLfloat, stOffsetTxcData = 0, - stOffsetPosData = (sizeof(GLfloat) * stCompsPerCoord), - stOffsetColData = (sizeof(GLfloat) * (stCompsPerCoord + stCompsPerPos)); + stOffsetPosData = stCompsPerCoord * stSizeOfGLfloat, + stOffsetColData = (stCompsPerCoord + stCompsPerPos) * stSizeOfGLfloat; /* -- Render command item -------------------------------------------------- */ struct FboCmd // Render command structure { /* ----------------------------------------------------------------------- */ - const GLuint uiTUId; // - Texture unit id - const GLuint uiTexId; // - Texture id - const GLuint uiPrgId; // - Shader program id - const GLvoid*const vpTCOffset; // - Texcoord buffer offset - const GLvoid*const vpVOffset; // - vector buffer offset - const GLvoid*const vpCOffset; // - Colour buffer offset + const GLuint uiTUId, // - Texture unit id + uiTexId, // - Texture id + uiPrgId; // - Shader program id + const GLvoid*const vpTCOffset, // - Texcoord buffer offset + *const vpVOffset, // - vector buffer offset + *const vpCOffset; // - Colour buffer offset const GLsizei uiVertices; // Total vertices to draw };/* -- Commands ----------------------------------------------------------- */ typedef vector FboCmdVec; // Render command list diff --git a/src/fboitem.hpp b/src/fboitem.hpp index 93aa898..94b0b5a 100644 --- a/src/fboitem.hpp +++ b/src/fboitem.hpp @@ -66,12 +66,14 @@ class FboItem const GLfloat fX2, const GLfloat fY2) { // Update the first triangle of the quad TriPosData &tdT1 = FboItemGetVDataT1(); - tdT1[0] = fX1; tdT1[1] = fY1; tdT1[2] = fX2; // Triangle 1 - tdT1[3] = fY1; tdT1[4] = fX1; tdT1[5] = fY2; // " + tdT1[0] = fX1; tdT1[1] = fY1; // Triangle 1 / Vertice 1 (XY) V1 V2 + tdT1[2] = fX2; tdT1[3] = fY1; // " / " 2 (XY) |XX/ + tdT1[4] = fX1; tdT1[5] = fY2; // " / " 3 (XY) V3 // Update the second triangle of the quad TriPosData &tdT2 = FboItemGetVDataT2(); - tdT2[0] = fX2; tdT2[1] = fY2; tdT2[2] = fX1; // Triangle 2 - tdT2[3] = fY2; tdT2[4] = fX2; tdT2[5] = fY1; // " + tdT2[0] = fX2; tdT2[1] = fY2; // Triangle 2 / Vertice 1 (XY) V3 + tdT2[2] = fX1; tdT2[3] = fY2; // " / " 2 (XY) /XX| + tdT2[4] = fX2; tdT2[5] = fY1; // " / " 3 (XY) V2 V1 } /* -- Set vertex co-ordinates and dimensions ----------------------------- */ void FboItemSetVertexWH(const GLfloat fX, const GLfloat fY, const GLfloat fW, @@ -86,47 +88,49 @@ class FboItem const GLfloat fX2, const GLfloat fY2, const GLfloat fML, const GLfloat fMR) { // Modify vertex based on horizotal scale normal (left edge) TriPosData &tdT1 = FboItemGetVDataT1(); - tdT1[0] = fX2-((fX2-fX1)*fML); tdT1[1] = fY1; // Triangle 1 - tdT1[2] = tdT1[0]+((fX2-tdT1[0])*fMR); tdT1[3] = fY1; // V0 V1 - tdT1[4] = tdT1[0]; tdT1[5] = fY2; // V2 / + tdT1[0] = fX2-((fX2-fX1)*fML); tdT1[1] = fY1; // T1 / V1 V1 V2 + tdT1[2] = tdT1[0]+((fX2-tdT1[0])*fMR); tdT1[3] = fY1; // T1 / V2 |XX/ + tdT1[4] = tdT1[0]; tdT1[5] = fY2; // T1 / V3 V3 // Modify vertex based on horizotal scale normal (right edge) TriPosData &tdT2 = FboItemGetVDataT2(); - tdT2[0] = fX1-((fX1-fX2)*fMR); tdT2[1] = fY2; // Triangle 2 - tdT2[2] = tdT2[0]+((fX1-tdT2[0])*fML); tdT2[3] = fY2; // / V2 - tdT2[4] = tdT2[0]; tdT2[5] = fY1; // V1 V0 + tdT2[0] = fX1-((fX1-fX2)*fMR); tdT2[1] = fY2; // T2 / V1 V3 + tdT2[2] = tdT2[0]+((fX1-tdT2[0])*fML); tdT2[3] = fY2; // T2 / V2 /XX| + tdT2[4] = tdT2[0]; tdT2[5] = fY1; // T2 / V3 V2 V1 } /* -- Set vertex bounds with modified left and right bounds and get ------ */ const QuadPosData &FboItemSetAndGetVertex(const GLfloat fX1, - const GLfloat fY1, const GLfloat fX2, const GLfloat fY2, - const GLfloat fML, const GLfloat fMR) - { FboItemSetVertex(fX1, fY1, fX2, fY2, fML, fMR); - return FboItemGetVData(); } + const GLfloat fY1, const GLfloat fX2, const GLfloat fY2, const GLfloat fML, + const GLfloat fMR) + { FboItemSetVertex(fX1, fY1, fX2, fY2, fML, fMR); + return FboItemGetVData(); } /* -- Set vertex bounds with angle --------------------------------------- */ void FboItemSetVertex(const GLfloat fX1, const GLfloat fY1, const GLfloat fX2, const GLfloat fY2, const GLfloat fA) - { // UtilDenormalise the angle to radians (M_PI) + { // UtilDenormalise the angle to radians (M_PI) const GLfloat fAR = fA * 2.0f * 3.141592653589793238462643383279502884f, // Calculate centre fXC = (fX2-fX1)/2, fYC = (fY2-fY1)/2, // Rotate vertices fC1 = atan2f(-fYC,fXC)+fAR, fC2 = atan2f(-fYC,-fXC)+fAR, fC3 = atan2f( fYC,fXC)+fAR, fC4 = atan2f( fYC,-fXC)+fAR, - fC5 = sqrtf(-fYC*-fYC+fXC*fXC), fC6 = sqrtf(-fYC*-fYC+-fXC*-fXC), - fC7 = sqrtf( fYC* fYC+fXC*fXC), fC8 = sqrtf( fYC* fYC+-fXC*-fXC), + fXCs = fXC*fXC, fXCsN = -fXC*-fXC, + fYCs = fYC*fYC, fYCsN = -fYC*-fYC, + fC5 = sqrtf(fYCsN+fXCs), fC6 = sqrtf(fYCsN+fXCsN), + fC7 = sqrtf(fYCs+fXCs), fC8 = sqrtf(fYCs+fXCsN), fCa = cosf(fC2)*fC5, fCb = sinf(fC2)*fC5, fCc = cosf(fC1)*fC6, fCd = sinf(fC1)*fC6, fCe = cosf(fC4)*fC7, fCf = sinf(fC4)*fC7, fCg = cosf(fC3)*fC8, fCh = sinf(fC3)*fC8; // Update the first triangle of the quad TriPosData &tdT1 = FboItemGetVDataT1(); - tdT1[0] = fX1+fCa; tdT1[1] = fY1+fCb; // Vertex 1 / Triangle 1 - tdT1[2] = fX1+fCc; tdT1[3] = fY1+fCd; // " 2 / " 1 - tdT1[4] = fX1+fCe; tdT1[5] = fY1+fCf; // " 3 / " 1 + tdT1[0] = fX1+fCa; tdT1[1] = fY1+fCb; // Vertex 1 / Triangle 1 (XY) V1 V2 + tdT1[2] = fX1+fCc; tdT1[3] = fY1+fCd; // " 2 / " 1 (XY) |XX/ + tdT1[4] = fX1+fCe; tdT1[5] = fY1+fCf; // " 3 / " 1 (XY) V3 // Update the second triangle of the quad TriPosData &tdT2 = FboItemGetVDataT2(); - tdT2[0] = fX1+fCg; tdT2[1] = fY1+fCh; // Vertex 1 / Triangle 2 - tdT2[2] = fX1+fCe; tdT2[3] = fY1+fCf; // " 2 / " 2 - tdT2[4] = fX1+fCc; tdT2[5] = fY1+fCd; // " 3 / " 2 + tdT2[0] = fX1+fCg; tdT2[1] = fY1+fCh; // Vertex 1 / Triangle 2 (XY) V3 + tdT2[2] = fX1+fCe; tdT2[3] = fY1+fCf; // " 2 / " 2 (XY) /XX| + tdT2[4] = fX1+fCc; tdT2[5] = fY1+fCd; // " 3 / " 2 (XY) V2 V1 } /* -- Set vertex with coords, dimensions and angle ----------------------- */ void FboItemSetVertexWH(const GLfloat fX, const GLfloat fY, const GLfloat fW, @@ -160,15 +164,15 @@ class FboItem { // Update tex coords for triangle 1 const TriCoordData &tdTS1 = fTC[0]; // Source TriCoordData &tdTD1 = FboItemGetTCDataT1(); // Destination - tdTD1[0] = tdTS1[2]-((tdTS1[2]-tdTS1[0])*fML); tdTD1[1] = tdTS1[1]; - tdTD1[2] = tdTD1[0]+((tdTS1[2]-tdTD1[0])*fMR); tdTD1[3] = tdTS1[3]; - tdTD1[4] = tdTD1[0]; tdTD1[5] = tdTS1[5]; + tdTD1[0] = tdTS1[2]-((tdTS1[2]-tdTS1[0])*fML); tdTD1[1] = tdTS1[1]; // V1V2 + tdTD1[2] = tdTD1[0]+((tdTS1[2]-tdTD1[0])*fMR); tdTD1[3] = tdTS1[3]; // V3V1 + tdTD1[4] = tdTD1[0]; tdTD1[5] = tdTS1[5]; // V2V3 // Update tex coords for triangle 2 const TriCoordData &tdTS2 = fTC[1]; // Source TriCoordData &tdTD2 = FboItemGetTCDataT2(); // Destination - tdTD2[0] = tdTS2[2]-((tdTS2[2]-tdTS2[0])*fMR); tdTD2[1] = tdTS2[1]; - tdTD2[2] = tdTD2[0]+((tdTS2[2]-tdTD2[0])*fML); tdTD2[3] = tdTS2[3]; - tdTD2[4] = tdTD2[0]; tdTD2[5] = tdTS2[5]; + tdTD2[0] = tdTS2[2]-((tdTS2[2]-tdTS2[0])*fMR); tdTD2[1] = tdTS2[1]; // V1V2 + tdTD2[2] = tdTD2[0]+((tdTS2[2]-tdTD2[0])*fML); tdTD2[3] = tdTS2[3]; // V3V1 + tdTD2[4] = tdTD2[0]; tdTD2[5] = tdTS2[5]; // V2V3 } /* -- Set vertex bounds and return it ------------------------------------ */ const QuadCoordData &FboItemSetAndGetCoord(const QuadCoordData &fTC, @@ -202,25 +206,23 @@ class FboItem /* -- Get defaults as lookup table --------------------------------------- */ const Quad &FboItemGetDefaultLookup(void) const { // This is equal to the following calls. It's just easier to memcpy the - // whole table across then doing pointless calculation. Remember that the - // Z is not being used so that co-ordinate is ignored and assumed zero. + // whole table across then doing pointless calculation. // - SetTexCoord(0, 0, 1, 1); // - SetVertex(-1, 1, 1, -1); // - SetRGBA(1, 1, 1, 1); static const Quad qData{{ // QuadCoordData qdCoord (render the entire texture on the triangles) - 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, // Triangle 1/2 (Vertice 1, 2 and 3) - 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, // " 2/2 (X,Y, X,Y X,Y) + 0.0f, 0.0f, 1.0f, 0.0f, // (T1V1,T1V2)[X+Y] V1 V2 V3 + 0.0f, 1.0f, 1.0f, 1.0f, // (T1V3,T2V1)[X+Y] T1 -> |XX/ /XX| <- T2 + 0.0f, 1.0f, 1.0f, 0.0f, // (T2V2,T2V3)[X+Y] V3 V2 V1 // QuadPosData qdPos (render the two triangles full-screen) - -1.0f, 1.0f, 1.0f, 1.0f,-1.0f,-1.0f, // Triangle 1/2 (Vertice 1, 2 and 3) - 1.0f,-1.0f,-1.0f,-1.0f, 1.0f, 1.0f, // " 2/2 (X,Y, X,Y X,Y) + -1.0f, 1.0f, 1.0f, 1.0f, // (T1V1,T1V2)[X+Y] V1 V2 V3 + -1.0f,-1.0f, 1.0f,-1.0f, // (T1V3,T2V1)[X+Y] T1 -> |XX/ /XX| <- T2 + -1.0f,-1.0f, 1.0f, 1.0f, // (T2V2,T2V3)[X+Y] V3 V2 V1 // QuadColData qdColour (all solid white intensity with no alpha) - 1.0f, 1.0f, 1.0f, 1.0f, // Triangle 1/2 (R,G,B,A, Vertice 1/3) - 1.0f, 1.0f, 1.0f, 1.0f, // " ( " " 2/3) - 1.0f, 1.0f, 1.0f, 1.0f, // " ( " " 3/3) - 1.0f, 1.0f, 1.0f, 1.0f, // Triangle 2/2 (R,G,B,A, Vertice 1/3) - 1.0f, 1.0f, 1.0f, 1.0f, // " ( " " 2/3) - 1.0f, 1.0f, 1.0f, 1.0f // " ( " " 3/3) + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, // (T1V1,T1V2)[R+G+B+A] + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, // (T1V3,T2V1)[R+G+B+A] + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f // (T2V2,T2V3)[R+G+B+A] }}; // Return the lookup table return qData; } diff --git a/src/fontglph.hpp b/src/fontglph.hpp index 5b5e9eb..b575915 100644 --- a/src/fontglph.hpp +++ b/src/fontglph.hpp @@ -192,12 +192,12 @@ void GlyphToTexture(const IntPackRect &iprRef, const FT_Bitmap &ftbRef, fBW = DimGetWidth(), fBH = DimGetHeight(); // Get reference to first and second triangles - TriPosData &tdT1 = cdRef[0], &tdT2 = cdRef[1]; + TriCoordData &tcT1 = cdRef[0], &tcT2 = cdRef[1]; // Push opengl tile coords (keep .fW/.fH to zero which is already zero) - tdT1[0] = tdT1[4] = tdT2[2] = fMinX / fBW; // Left - tdT1[1] = tdT1[3] = tdT2[5] = fMinY / fBH; // Top - tdT1[2] = tdT2[0] = tdT2[4] = fMaxX / fBW; // Right - tdT1[5] = tdT2[1] = tdT2[3] = fMaxY / fBH; // Bottom + tcT1[0] = tcT1[4] = tcT2[2] = fMinX / fBW; // Left + tcT1[1] = tcT1[3] = tcT2[5] = fMinY / fBH; // Top + tcT1[2] = tcT2[0] = tcT2[4] = fMaxX / fBW; // Right + tcT1[5] = tcT2[1] = tcT2[3] = fMaxY / fBH; // Bottom } /* -- Do load character function ------------------------------------------- */ template diff --git a/src/luautil.hpp b/src/luautil.hpp index d8de23a..9e04af8 100644 --- a/src/luautil.hpp +++ b/src/luautil.hpp @@ -980,8 +980,8 @@ template // Id number for array index lua_Integer iIndex = 0; // For each table item - for(const string &vItem : ltData) - LuaUtilSetTableIdxStr(lS, -3, ++iIndex, vItem); + for(const string &strItem : ltData) + LuaUtilSetTableIdxStr(lS, -3, ++iIndex, strItem); } /* -- Explode LUA string into table ---------------------------------------- */ static void LuaUtilExplode(lua_State*const lS) diff --git a/src/msengine.hpp b/src/msengine.hpp index c85be08..00abf39 100644 --- a/src/msengine.hpp +++ b/src/msengine.hpp @@ -12,9 +12,9 @@ #define VER_AUTHOR "MS-Design" // Author of engine #define VER_MAJOR 24 // Version major (year) #define VER_MINOR 9 // Version minor (month) -#define VER_BUILD 10 // Version build (day) -#define VER_REV 101 // Version rev (build#) -#define VER_STR_NQ 24,9,10,101 // Version as literal -#define VER_STR "24.9.10.101" // Version as string -#define VER_DATE "Tue Sep 10 22:51:18 2024 +0100" // Compilation date +#define VER_BUILD 12 // Version build (day) +#define VER_REV 1 // Version rev (build#) +#define VER_STR_NQ 24,9,12,1 // Version as literal +#define VER_STR "24.9.12.1" // Version as string +#define VER_DATE "Thu Sep 12 00:17:37 2024 +0100" // Compilation date /* == EoF =========================================================== EoF == */ diff --git a/src/palette.hpp b/src/palette.hpp index 5b2ea5c..34e25ca 100644 --- a/src/palette.hpp +++ b/src/palette.hpp @@ -93,15 +93,16 @@ class Pal : // Members initially public void ShiftBck(const ssize_t stBegin, const ssize_t stEnd, const ssize_t stRot) { // Get starting position and rotate backwards - const PalDataRevIt itStart{ rbegin() + (SizeM1() - stEnd) }; - StdRotate(seq, itStart, itStart + stRot, rbegin() + (Size() - stBegin)); + const PalDataRevIt pdriStart{ rbegin() + (SizeM1() - stEnd) }; + StdRotate(seq, pdriStart, pdriStart + stRot, + rbegin() + (Size() - stBegin)); } /* -- Shift limited palette entries forwards ----------------------------- */ void ShiftFwd(const ssize_t stBegin, const ssize_t stEnd, const ssize_t stRot) { // Get starting position and rotate forwards - const PalDataIt itStart{ begin() + stBegin }; - StdRotate(seq, itStart, itStart + stRot, begin() + stEnd + 1); + const PalDataIt pdiStart{ begin() + stBegin }; + StdRotate(seq, pdiStart, pdiStart + stRot, begin() + stEnd + 1); } /* -- Shift palette entries backwards or forwards ------------------------ */ void Shift(const ssize_t stBegin, const ssize_t stLimit, @@ -115,16 +116,16 @@ class Pal : // Members initially public void Copy(const size_t stDstPos, const PalData &pdSrc, const size_t stSrcPos, const size_t stSrcCount) { // Get source data position and then copy it to output - const PalDataConstIt itBegin{ pdSrc.cbegin() + stSrcPos }; - StdCopy(par_unseq, itBegin, itBegin + stSrcCount, begin() + stDstPos); + const PalDataConstIt pdciIt{ pdSrc.cbegin() + stSrcPos }; + StdCopy(par_unseq, pdciIt, pdciIt + stSrcCount, begin() + stDstPos); } /* -- Fill with specified value ------------------------------------------ */ void Fill(const size_t stIndex, const size_t stCount, const GLfloat fRed=0.0f, const GLfloat fGreen=0.0f, const GLfloat fBlue=0.0f, const GLfloat fAlpha=0.0f) { // Get start and fill in the array - const PalDataIt itStart{ begin() + stIndex }; - StdFill(par_unseq, itStart, itStart + stCount, + const PalDataIt pdiStart{ begin() + stIndex }; + StdFill(par_unseq, pdiStart, pdiStart + stCount, FboColour{ fRed, fGreen, fBlue, fAlpha }); } /* ----------------------------------------------------------------------- */ Pal(void) : // No parameters diff --git a/src/pcmlib.hpp b/src/pcmlib.hpp index d3655b8..d1a959a 100644 --- a/src/pcmlib.hpp +++ b/src/pcmlib.hpp @@ -122,9 +122,8 @@ static void PcmLoadFile(FileMap &fmData, PcmData &pdData) "Size", fmData.MemSize(), "Position", fmData.FileMapTell(), "Plugin", plRef.GetName()); - } // Rewind stream position + } // Rewind stream position and reset all pcm data read to load again fmData.FileMapRewind(); - // Reset all pcm data read to load again pdData.ResetAllData(); } // Could not detect so throw error XC("Unable to determine sound format!", "Identifier", fmData.IdentGet()); @@ -145,7 +144,7 @@ static long PcmVorbisTell(void*const vFmClassPtr) { return static_cast(reinterpret_cast(vFmClassPtr)-> FileMapTell()); } /* -- Return generic ogg callback functions -------------------------------- */ -const ov_callbacks &PcmGetOggCallbacks(void) +static const ov_callbacks &PcmGetOggCallbacks(void) { static const ov_callbacks ovcCallbacks{ PcmVorbisRead, PcmVorbisSeek, PcmVorbisClose, PcmVorbisTell }; return ovcCallbacks; } /* -- Convert vorbis encoded frames to 32-bit floating point PCM audio ----- */ diff --git a/src/pixcon.hpp b/src/pixcon.hpp index 7465926..9411d34 100644 --- a/src/pixcon.hpp +++ b/src/pixcon.hpp @@ -543,7 +543,7 @@ class SysCon : // All members initially private { // Set cursor position SetCursor(1 + iLen, diSizeM1.DimGetHeight()); // Reset again and write the string - WriteLine(UtfDecoder(strIR), diSizeM1.DimGetWidth(), false); + WriteLine(UtfDecoder{ strIR }, diSizeM1.DimGetWidth(), false); } // Actually set cursor position ciCursor.CoordSet(UtilMinimum(diSizeM1.DimGetWidth(), 1 + iLen), diSizeM1.DimGetHeight()); @@ -622,25 +622,26 @@ class SysCon : // All members initially private void RedrawTitleBar(const string &strTL, const string &strTR) { RedrawStatus(0, strTL, strTR); } /* -- Redraw console buffer ---------------------------------------------- */ - void RedrawBuffer(const ConLines &cL, const ConLinesConstRevIt &lS) + void RedrawBuffer(const ConLines &clLines, + const ConLinesConstRevIt &clcriStart) { // Reset cursor position to top left of drawing area SetCursor(0, diSizeM1.DimGetHeight()); // Set default text colour SetColour(15); // Draw until we go off the top of the screen - for(ConLinesConstRevIt lL{ lS }; - lL != cL.rend() && ValidY(CoordGetY()); - ++lL) + for(ConLinesConstRevIt clcriIt{ clcriStart }; + clcriIt != clLines.crend() && ValidY(CoordGetY()); + ++clcriIt) { // Get structure - const ConLine &lD = *lL; + const ConLine &clLine = *clcriIt; // Convert RGB colour to Win32 console id colour - SetColour(lD.cColour); + SetColour(clLine.cColour); // Put text in a utf container and write the data. Note: Although // CoordGetY() could go effectively negative and we're not using a signed // value we can make sure we don't access any OOB memory by just checking // that the co-ordinates while drawing, we don't have to worry about the // integer wrapping at all we are not drawing. - CoordDecY(WriteLineWU(UtfDecoder{ lD.strLine }) - 1); + CoordDecY(WriteLineWU(UtfDecoder{ clLine.strLine }) - 1); } // Clear extra lines we didn't draw too while(CoordGetY() > 1) { CoordSetX(0); CoordDecY(); ClearLine(); } } diff --git a/src/shaders.hpp b/src/shaders.hpp index 61009ec..ee9d2da 100644 --- a/src/shaders.hpp +++ b/src/shaders.hpp @@ -8,10 +8,10 @@ /* ------------------------------------------------------------------------- */ namespace IShaders { // Start of private module namespace /* -- Dependencies --------------------------------------------------------- */ -using namespace ICVarDef::P; using namespace ILog::P; -using namespace IOgl::P; using namespace IShader::P; -using namespace IStd::P; using namespace IString::P; -using namespace Lib::OS::GlFW; +using namespace ICVarDef::P; using namespace IFboDef::P; +using namespace ILog::P; using namespace IOgl::P; +using namespace IShader::P; using namespace IStd::P; +using namespace IString::P; using namespace Lib::OS::GlFW; /* ------------------------------------------------------------------------- */ namespace P { // Start of public module namespace /* == Shader core class ==================================================== */ @@ -38,11 +38,10 @@ static struct ShaderCore final { // Add vertex shader program shS.AddShaderEx(strName, GL_VERTEX_SHADER, // > The vertex shader is for modifying vertice coord data - // Input parameters (ONE TRIANGLE) V1 V2 V3 - "in vec2 texcoord;" // [3][2]=( {xy}, {xy}, {xy} ) - "in vec2 vertex;" // [3][2]=( {xy}, {xy}, {xy} ) - "in vec4 colour;" // [3][4]=({rgba},{rgba},{rgba}) - "out vec4 texcoordout;" // Texcoords sent to frag shader + "in vec$ texcoord;" // Texture coordinates for vertice + "in vec$ vertex;" // Position coordinates for vertice + "in vec$ colour;" // Colour intensity for vertice + "out vec4 texcoordout;" // Tex coords sent to fragment shader "out vec4 colourout;" // Colour multiplier sent to frag shader "uniform vec4 matrix;" // Current 2D matrix "void main(void){" // Entry point @@ -53,7 +52,8 @@ static struct ShaderCore final "texcoordout = tc;" // Set colour from glColorPointer "colourout = c;" // Set colour "gl_Position = v;" // Set vertex position - "}", cpCode); + "}", // End of main function + stCompsPerCoord, stCompsPerPos, stCompsPerColour, cpCode); } /* -- Add vertex shader with template ------------------------------------ */ void AddVertexShaderWith3DTemplate(Shader &shS, const string &strName) @@ -90,8 +90,8 @@ static struct ShaderCore final const char*const cpCode) { // Add vertex shader program AddVertexShaderWith3DTemplate(shS, strName, StrFormat("$" - "v[0] = -1.0+(((matrix[0]+$(v[0]))/matrix[2])*2.0);" // X-coord - "v[1] = -1.0+(((matrix[1]+$(v[1]))/matrix[3])*2.0);", // Y-coord + "v.x = -1.0+(((matrix.x+$(v.x))/matrix.z)*2.0);" // X-coord + "v.y = -1.0+(((matrix.y+$(v.y))/matrix.w)*2.0);", // Y-coord cpCode, strSPRMethod, strSPRMethod).c_str()); } /* -- Add vertex shader with template ------------------------------------ */ diff --git a/src/source.hpp b/src/source.hpp index af5b65d..9e7cf3b 100644 --- a/src/source.hpp +++ b/src/source.hpp @@ -59,20 +59,18 @@ CTOR_MEM_BEGIN_CSLAVE(Sources, Source, ICHelperSafe), /* -- Get source integer ------------------------------------------------- */ template const IntType GetSourceInt(const ALenum eParam) const - { // Store result into this integer + { // Get the specified value and store the result and return a cast of it ALint iValue; - // Get the value AL(cOal->GetSourceInt(uiId, eParam, &iValue), "Get source integer failed!", "Index", uiId, "Param", eParam); - // Return casted value return static_cast(iValue); } /* -- Get/set source triple-float -------------------------------- */ void GetSource3Float(const ALenum eP, ALfloat &fX, ALfloat &fY, ALfloat &fZ) const { AL(cOal->GetSourceVector(uiId, eP, &fX, &fY, &fZ), - "Get source vector failed!", - "Index", uiId, "Param", eP, "X", fX, "Y", fY, "Z", fZ); } + "Get source vector failed!", + "Index", uiId, "Param", eP, "X", fX, "Y", fY, "Z", fZ); } void SetSource3Float(const ALenum eP, const ALfloat fX, const ALfloat fY, const ALfloat fZ) const { AL(cOal->SetSourceVector(uiId, eP, fX, fY, fZ), @@ -335,9 +333,8 @@ static Source *SourceGetFree(void) for(Source*const sCptr : *cSources) { // Is a locked stream? Then it's active and locked! if(sCptr->GetExternal() || sCptr->IsPlaying()) continue; - // Reset source + // Reset source and return it sCptr->ReInit(); - // Return the source return sCptr; } // Couldn't find one return nullptr; @@ -376,11 +373,8 @@ static void SourceAlloc(const size_t stCount) } /* == Set number of sources ================================================ */ static CVarReturn SourceSetCount(const size_t stCount) -{ // Ignore if not initialised - if(!cOal->IsInitialised()) return ACCEPT; - // Reallocate the sources - SourceAlloc(stCount); - // Success +{ // If AL is initialised reallocate the sources and return success + if(cOal->IsInitialised()) SourceAlloc(stCount); return ACCEPT; } /* ------------------------------------------------------------------------- */ diff --git a/src/video.hpp b/src/video.hpp index 2efbea0..de14863 100644 --- a/src/video.hpp +++ b/src/video.hpp @@ -837,13 +837,22 @@ CTOR_MEM_BEGIN_ASYNC(Videos, Video, ICHelperSafe, /* No CLHelper */), viData.bitrate_window, StrToBits(viData.bitrate_window)); // Parse vorbis comments and if not empty? Enumerate and log each one if(cLog->HasLevel(LH_DEBUG)) - { // Write Theora and Vorbis comments - for(const StrNCStrMapPair &sncsmpPair : ssThMetaData) - cLog->LogNLCDebugExSafe("- Theora comment: $ -> $.", - sncsmpPair.first, sncsmpPair.second); - for(const StrNCStrMapPair &sncsmpPair : ssVoMetaData) - cLog->LogNLCDebugExSafe("- Vorbis comment: $ -> $.", - sncsmpPair.first, sncsmpPair.second); + { // Prepare data for lists + typedef pair ListPair; + typedef array Lists; + static const string_view svTheora{ "Theora" }, svVorbis{ "Vorbis" }; + const Lists lLists{ { { svTheora, ssThMetaData }, + { svVorbis, ssVoMetaData } } }; + // Write Theora comments iv available + for(const ListPair lpPair : lLists) + { // Ignore if empty else log metadata for specified list + if(lpPair.second.empty()) continue; + cLog->LogNLCDebugExSafe("- $ comments: $...", + lpPair.first, lpPair.second.size()); + for(const StrNCStrMapPair &sncsmpPair : lpPair.second) + cLog->LogNLCDebugExSafe("-- $: $.", + sncsmpPair.first, sncsmpPair.second); + } } // Set stopped FlagSet(FL_STOP); } diff --git a/src/wincon.hpp b/src/wincon.hpp index 54efebf..154d538 100644 --- a/src/wincon.hpp +++ b/src/wincon.hpp @@ -562,7 +562,7 @@ class SysCon : // Members initially private { // Set cursor position stX = 1 + stLen, stY = stHm1; // Reset again and write the string - WriteLine(UtfDecoder(strIR), stWm2 - stLen, false); + WriteLine(UtfDecoder{ strIR }, stWm2 - stLen, false); } // Set cursor position SetCursor({ static_cast(UtilMinimum(stWm1, 1 + stLen)), static_cast(stHm1) }); @@ -639,24 +639,27 @@ class SysCon : // Members initially private void RedrawTitleBar(const string &strTL, const string &strTR) { RedrawStatus(0, strTL, strTR); } /* -- Redraw console buffer ---------------------------------------------- */ - void RedrawBuffer(const ConLines &cL, const ConLinesConstRevIt &lS) + void RedrawBuffer(const ConLines &clLines, + const ConLinesConstRevIt clcriStart) { // Reset cursor position to top left of drawing area stX = 0; stY = stHm1; // Set default text colour SetColour(FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE); // Draw until we go off the top of the screen - for(ConLinesConstRevIt lL(lS); lL != cL.rend() && ValidY(stY); ++lL) + for(ConLinesConstRevIt clcriIt{ clcriStart }; + clcriIt != clLines.crend() && ValidY(stY); + ++clcriIt) { // Get structure - const ConLine &lD = *lL; + const ConLine &clLine = *clcriIt; // Convert RGB colour to Win32 console id colour - SetColour(wNDXtoW32C[lD.cColour]); + SetColour(wNDXtoW32C[clLine.cColour]); // Put text in a utf container and write the data. Note: Although // stY could go effectively negative and we're not using a signed value // we can make sure we don't access any OOB memory by just checking that // the co-ordinates while drawing, we don't have to worry about the // integer wrapping at all we are not drawing. - stY -= WriteLineWU(UtfDecoder(lD.strLine)) - 1; + stY -= WriteLineWU(UtfDecoder{ clLine.strLine }) - 1; } // Done if there is no lines to clear up to the top if(!ValidY(stY)) return; // Goto beginning so we can clear lines