diff --git a/Src/Graphics/New3D/New3D.cpp b/Src/Graphics/New3D/New3D.cpp index aede988..462458f 100644 --- a/Src/Graphics/New3D/New3D.cpp +++ b/Src/Graphics/New3D/New3D.cpp @@ -51,6 +51,7 @@ void CNew3D::SetStep(int stepID) } m_vboDynamic.Create(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW, sizeof(Poly)* 100000); // allocate space for 100k polys ~ 10meg + //m_vboStatic.Create(GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW, 0x80000); // 64meg buffer } bool CNew3D::Init(unsigned xOffset, unsigned yOffset, unsigned xRes, unsigned yRes, unsigned totalXResParam, unsigned totalYResParam) @@ -614,7 +615,7 @@ void CNew3D::RenderViewport(UINT32 addr, int pri) vp->width = m_totalXRes; vp->height = (GLint)((float)vpHeight*m_yRatio); - vp->projectionMatrix.Perspective(fovYDegrees, (GLfloat)vp->width / (GLfloat)vp->height, 0.1f, 1e5); // use actual full screen ratio to get proper X FOV + vp->projectionMatrix.Perspective(fovYDegrees, (GLfloat)vp->width / (GLfloat)vp->height, 0.125f, 1000*128); // use actual full screen ratio to get proper X FOV } else { @@ -974,4 +975,27 @@ float CNew3D::Determinant3x3(const float m[16]) { return m[0] * ((m[5] * m[10]) - (m[6] * m[9])) - m[4] * ((m[1] * m[10]) - (m[2] * m[9])) + m[8] * ((m[1] * m[6]) - (m[2] * m[5])); } +bool CNew3D::IsDynamicModel(UINT32 *data) +{ + if (data == NULL) { + return false; + } + + PolyHeader p(data); + + do { + + if ((p.header[1] & 2) == 0) { // model has rgb colour palette + return true; + } + + if (p.header[6] == 0) { + break; + } + + } while (p.NextPoly()); + + return false; +} + } // New3D diff --git a/Src/Graphics/New3D/New3D.h b/Src/Graphics/New3D/New3D.h index 021c152..26fec86 100644 --- a/Src/Graphics/New3D/New3D.h +++ b/Src/Graphics/New3D/New3D.h @@ -171,6 +171,7 @@ private: void RenderScene(int priority, bool alpha); float Determinant3x3(const float m[16]); + bool IsDynamicModel(UINT32 *data); // check if the model has a colour palette /* * Data @@ -205,6 +206,7 @@ private: std::vector m_polyBuffer; // we actually hold the vertex data here, one buffer to send to opengl, instead of 2000+ small ones. VBO m_vboDynamic; // dynamic data from poly ram, rom polys can go in a different buffer + VBO m_vboStatic; // for ROM models R3DShader m_r3dShader; int m_currentVPPriority; diff --git a/Src/Graphics/New3D/PolyHeader.cpp b/Src/Graphics/New3D/PolyHeader.cpp index 777158f..66367fb 100644 --- a/Src/Graphics/New3D/PolyHeader.cpp +++ b/Src/Graphics/New3D/PolyHeader.cpp @@ -97,15 +97,9 @@ int PolyHeader::NumVerts() int PolyHeader::NumSharedVerts() { - int num = 0; + int sharedVerts[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; - for (int i = 0; i < 4; i++) { - if (SharedVertex(i)) { - num++; - } - } - - return num; + return sharedVerts[header[0] & 0xf]; } bool PolyHeader::SharedVertex(int vertex) diff --git a/Src/Graphics/New3D/VBO.cpp b/Src/Graphics/New3D/VBO.cpp index f2dec29..59e5b6e 100644 --- a/Src/Graphics/New3D/VBO.cpp +++ b/Src/Graphics/New3D/VBO.cpp @@ -4,8 +4,10 @@ namespace New3D { VBO::VBO() { - m_id = 0; - m_target = 0; + m_id = 0; + m_target = 0; + m_capacity = 0; + m_size = 0; } void VBO::Create(GLenum target, GLenum usage, GLsizeiptr size, const void* data) @@ -14,7 +16,9 @@ void VBO::Create(GLenum target, GLenum usage, GLsizeiptr size, const void* data) glBindBuffer(target, m_id); // activate vbo id to use glBufferData(target, size, data, usage); // upload data to video card - m_target = target; + m_target = target; + m_capacity = size; + m_size = 0; Bind(false); // unbind } @@ -24,12 +28,32 @@ void VBO::BufferSubData(GLintptr offset, GLsizeiptr size, const GLvoid* data) glBufferSubData(m_target, offset, size, data); } +bool VBO::AppendData(GLsizeiptr size, const GLvoid* data) +{ + if (m_size + size >= m_capacity) { + return false; + } + + BufferSubData(m_size, size, data); + + m_size += size; + + return true; +} + +void VBO::Reset() +{ + m_size = 0; +} + void VBO::Destroy() { if (m_id) { glDeleteBuffers(1, &m_id); - m_id = 0; - m_target = 0; + m_id = 0; + m_target = 0; + m_capacity = 0; + m_size = 0; } } @@ -43,4 +67,14 @@ void VBO::Bind(bool enable) } } +int VBO::GetSize() +{ + return m_size; +} + +int VBO::GetCapacity() +{ + return m_capacity; +} + } // New3D diff --git a/Src/Graphics/New3D/VBO.h b/Src/Graphics/New3D/VBO.h index 2422632..94e53fe 100644 --- a/Src/Graphics/New3D/VBO.h +++ b/Src/Graphics/New3D/VBO.h @@ -12,12 +12,18 @@ public: void Create (GLenum target, GLenum usage, GLsizeiptr size, const void* data=nullptr); void BufferSubData (GLintptr offset, GLsizeiptr size, const GLvoid* data); + bool AppendData (GLsizeiptr size, const GLvoid* data); + void Reset (); // don't delete data, just go back to start void Destroy (); void Bind (bool enable); + int GetSize (); + int GetCapacity (); private: - GLuint m_id; - GLenum m_target; + GLuint m_id; + GLenum m_target; + int m_capacity; + int m_size; }; } // New3D diff --git a/VS2008/Supermodel.vcxproj.filters b/VS2008/Supermodel.vcxproj.filters index f5fac1f..0ca117b 100644 --- a/VS2008/Supermodel.vcxproj.filters +++ b/VS2008/Supermodel.vcxproj.filters @@ -6,128 +6,125 @@ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - {98c8898a-186a-4900-98dd-f6a434bbb13b} + {716e7bd4-2cd7-4bf1-8d46-99e5447fe781} - {0cd4ef9d-77d4-48b3-95b5-761ed9a698d0} + {5b7aa050-a050-4271-ba54-8bafe77ecc52} - {b3b79a61-ca2c-4222-84be-8315d0ed6d20} + {7c4ab7e8-1911-46a0-8303-0e0c2b5a8992} - {6fab31bc-3503-4749-bbd9-47e14ec68378} + {f8bdc7a0-3568-438b-9219-4ff5f852c9be} - {96e413ec-f801-4f0d-94e6-c113e94a19ff} + {fc1a9c78-7900-45ec-acd1-3c78a71a63b0} - {edd2a4ee-ba57-4029-98d7-88da14c95c9e} + {80014733-535d-48f1-b5de-8339ec2f8641} - {b69ed4ac-0efc-4bde-b635-f3189c446da9} + {c65d0c2f-5e69-4fe0-8b64-46c0a32470eb} - {fc713f3d-dc7a-4c27-b8e4-f76dbd314c4d} + {9113f873-c745-44ac-860a-dcf12d177f5b} - {cf1a006e-89b1-4f05-86a3-54c98dc3218e} + {ae989a55-7782-48d6-9397-2684c7611e23} - {48241026-3be5-46c7-bab5-30bd37a0751f} + {2516aec9-10a4-4816-a580-949fea0f96d7} - {0d058e19-aca1-4862-adfe-4939c0c75cee} + {2f84f9e7-faf7-44fd-b592-fb7554ea8536} - {f7d02fd7-0959-4ec3-8b11-6b2661285106} + {35c6878b-761b-4f4f-becc-b2205dfcee6a} - {b25a2e6d-9203-44af-8b6f-da7646e0c9f4} + {a3992b46-68bc-4ae7-86e3-0349cfea1453} - {8b2daadd-117a-470f-ab9c-970c873afbf5} + {a39fba30-6e23-4591-a1d2-8058cf23bd87} - {4cb6c582-0200-48d2-a07e-fc4a49b0b77d} + {06dd9d6f-d5af-4bf6-af65-defc3b124516} - {1b22e070-6f15-4bcc-b26a-27d55f514777} + {a5006e1b-c633-464f-b47a-bf164f6e36fa} - {d359c5eb-2689-41ab-8f6f-531137f73fff} + {d1903ed6-5792-49e7-8ecd-dca859cadf20} - {6aa677db-f679-4516-8211-b0055064e9e2} + {02f1be5d-5fef-484e-a0e1-54c9d1b76af5} - {2c844c65-7f14-4836-b2d4-e68de381924b} + {c8fbae68-16ff-4305-bd88-452e1d91704a} - {7015b35f-f407-495c-868b-e6e1a1907c7a} + {1e84796b-88ed-4dda-80cd-9f3620fa660b} {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd - {2b2e479b-4368-4ce1-b556-2d2cca8d3263} + {18cd0331-f192-4379-b43b-11cc11acc6b0} - {37354415-42e6-49f2-a1b5-f86d0c6885fe} + {d545e14f-c1e8-4120-9b4d-e01aa20edc0d} - {5d098d97-6ed2-40c5-9e99-aed7294174ad} + {fdb23bd9-e2f7-4e01-bc6b-60653fc200bf} - {aae78ad2-b9a5-445a-bd65-d5bd017b5140} + {89683745-5b0d-46dd-827a-25c5ab3e8607} - {b3eb0314-e074-4dcc-a55d-a5804eec0f36} + {7be2c7f7-461b-43aa-a06e-23327aae2b58} - {47d68a08-5fdb-401e-acfe-dcd74024109d} - - - {85c9ee09-8692-436b-bd9e-b5367ba10049} + {889bfb3f-0590-40cc-b241-68cd808bd78d} - {3bb53185-168c-4301-b77a-9c7371fe7f68} + {5f55bf72-6938-4887-b78c-58b29e674985} - {6b46b30d-8a24-4616-b13b-d195cec9efa9} + {4340a810-7e55-471b-8ac0-0deb48f54a0c} - {967d6d51-efd0-410b-9b7d-a0ad1fddc8ee} + {041ed025-007f-4d62-bd34-6bd9fcb2781f} - {41709c55-01a8-4d08-b80e-b021e6d3b831} + {e963f77a-7472-48b4-a6a1-343f6aa39262} - {647e7c9a-417f-4e4f-8313-1f891e1d8e9a} + {da61a14e-79ce-4c63-9eee-cc521f7e3547} - {f622c6c5-950a-4c79-a079-1363ca1dce72} + {1be82a82-43c3-4450-bbb1-b35bfb634cf0} - {7a26ef17-350c-4548-8395-5db08bcaa6f1} + {8978ff40-460d-40f4-a292-5c19d23efeb0} - {3c244066-c201-4539-86bb-8469c5e017ad} + {0ad02311-aa1b-49ec-a7a0-c3d651366e02} - {a5ab3099-e617-4db7-92d8-eec4b169aad4} + {0bbc6c75-e21a-4e7b-a146-63c9b5b9204b} - {06181ce5-ef91-4531-aa9f-f8578558c1f7} + {5ca8c9ec-6a88-4aef-a947-cbf724f1c932} - - {e3781a4f-f36a-4d2e-a9b1-d957c0e0d63e} + + {2d4b1b91-8639-4dec-8371-8e9df61552ca} - - {53927af6-94d3-4559-810b-ba9eccf286e0} + + {997b8f53-16c1-4835-a1b3-7fac0aa21e61} - - {411177af-bbe6-491c-8fc7-417f00934228} + + {446becc7-6a22-4dee-9f22-14eeeff2638e} @@ -371,51 +368,51 @@ Source Files\Debugger\CPU - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\Legacy3D - - - Source Files\Graphics\Legacy3D - - - Source Files\Graphics\Legacy3D - - - Source Files\Graphics\Legacy3D - Source Files\Graphics Source Files\Graphics + + Source Files\Graphics\Legacy + + + Source Files\Graphics\Legacy + + + Source Files\Graphics\Legacy + + + Source Files\Graphics\Legacy + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + @@ -427,25 +424,25 @@ Source Files\Config - Source Files\Graphics\Legacy3D\Shaders + Source Files\Graphics\Legacy\Shaders - Source Files\Graphics\Legacy3D\Shaders + Source Files\Graphics\Legacy\Shaders - Source Files\Graphics\Legacy3D\Shaders + Source Files\Graphics\Legacy\Shaders - Source Files\Graphics\Legacy3D\Shaders + Source Files\Graphics\Legacy\Shaders - Source Files\Graphics\Legacy3D\Shaders + Source Files\Graphics\Legacy\Shaders - Source Files\Graphics\Legacy3D\Shaders + Source Files\Graphics\Legacy\Shaders - Source Files\Graphics\Legacy3D\Shaders + Source Files\Graphics\Legacy\Shaders @@ -508,15 +505,6 @@ Header Files\CPU\Z80 - - Header Files\Graphics - - - Header Files\Graphics - - - Header Files\Graphics - Header Files\Model3 @@ -724,45 +712,54 @@ Header Files\Debugger\CPU - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\New3D - - - Source Files\Graphics\Legacy3D - - - Source Files\Graphics\Legacy3D - - - Source Files\Graphics\Legacy3D - Source Files\Graphics + + Source Files\Graphics + + + Source Files\Graphics + + + Source Files\Graphics + + + Source Files\Graphics\Legacy + + + Source Files\Graphics\Legacy + + + Source Files\Graphics\Legacy + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New + + + Source Files\Graphics\New +