enum PrimitiveTopology { PT_POINTS = 0, PT_LINES, PT_LINE_STRIP, PT_TRIANGLES, PT_TRIANGLE_STRIP, PT_TRIANGLE_FAN, PT_QUADS, PT_QUAD_STRIP }; enum GraphicsAPI { DirectX11, DirectX10, DirectX10_1, DirectX9, OpenGL, OpenGLES }; template <GraphicsAPI API> int getPrimitiveTopology(PrimitiveTopology pt) { switch (API) { case DirectX11: case DirectX10: case DirectX10_1: switch(pt) { case PT_POINTS: return D3D_PRIMITIVE_TOPOLOGY_POINTLIST; break; case PT_LINES: return D3D_PRIMITIVE_TOPOLOGY_LINELIST; break; case PT_LINE_STRIP: return D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; break; case PT_TRIANGLES: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; break; case PT_TRIANGLE_STRIP: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; break; case PT_TRIANGLE_FAN: return D3D_PRIMITIVE_TOPOLOGY_UNDEFINED; break; default: assert(0 && "getPrimitiveTopology::DirectX10+ Unknown or unsupported primitive topology !"); return -1; break; } break; case DirectX9: switch(pt) { case PT_POINTS: return D3DPT_POINTLIST; break; case PT_LINES: return D3DPT_LINELIST; break; case PT_LINE_STRIP: return D3DPT_LINESTRIP; break; case PT_TRIANGLES: return D3DPT_TRIANGLELIST; break; case PT_TRIANGLE_STRIP: return D3DPT_TRIANGLESTRIP; break; case PT_TRIANGLE_FAN: return D3DPT_TRIANGLEFAN; break; default: assert(0 && "getPrimitiveTopology::DirectX9 Unknown or unsupported primitive topology !"); return -1; break; } break; case OpenGL: case OpenGLES: switch(pt) { case PT_POINTS: return GL_POINTS; break; case PT_LINES: return GL_LINES; break; case PT_LINE_STRIP: return GL_LINE_STRIP; break; case PT_TRIANGLES: return GL_TRIANGLES; break; case PT_TRIANGLE_STRIP: return GL_TRIANGLE_STRIP; break; case PT_TRIANGLE_FAN: return GL_TRIANGLE_FAN; break; default: assert(0 && "getPrimitiveTopology::OpenGL/ES Unknown or unsupported primitive topology !"); return -1; break; } break; default: assert(0 && "getPrimitiveTopology() Unknown API !"); return -1; break; } }
A good compiler should optimize the dead code.
Also if you want to avoid the dependency on the graphics API headers, here are the necessary enums:
enum D3D_PRIMITIVE_TOPOLOGY { D3D_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, D3D_PRIMITIVE_TOPOLOGY_POINTLIST = 1, D3D_PRIMITIVE_TOPOLOGY_LINELIST = 2, D3D_PRIMITIVE_TOPOLOGY_LINESTRIP = 3, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST = 4, D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = 5 }; enum D3DPRIMITIVETYPE { D3DPT_POINTLIST = 1, D3DPT_LINELIST = 2, D3DPT_LINESTRIP = 3, D3DPT_TRIANGLELIST = 4, D3DPT_TRIANGLESTRIP = 5, D3DPT_TRIANGLEFAN = 6, D3DPT_FORCE_DWORD = 0x7fffffff, }; enum GLPrimitiveTopology { GL_POINTS = 0x0000, GL_LINES = 0x0001, GL_LINE_LOOP = 0x0002, GL_LINE_STRIP = 0x0003, GL_TRIANGLES = 0x0004, GL_TRIANGLE_STRIP = 0x0005, GL_TRIANGLE_FAN = 0x0006, GL_QUADS = 0x0007, GL_QUAD_STRIP = 0x0008, GL_POLYGON = 0x0009, };
If you define the native types yourself, watch out for conflicts !
Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
RépondreSupprimerBest Devops Training in pune
Best Devops Training institute in Chennai
RépondreSupprimerThis information is impressive; I am inspired with your post writing style & how continuously you describe this topic. DevOps Training | Certification in Chennai | DevOps Training | Certification in anna nagar | DevOps Training | Certification in omr | DevOps Training | Certification in porur | DevOps Training | Certification in tambaram | DevOps Training | Certification in velachery
Your very own commitment to getting the message throughout came to be rather powerful and have consistently enabled employees just like me to arrive at their desired goals.
RépondreSupprimerdata science training in chennai
data science training in tambaram
android training in chennai
android training in tambaram
devops training in chennai
devops training in tambaram
artificial intelligence training in chennai
artificial intelligence training in tambaram
Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea
RépondreSupprimerweb designing training in chennai
web designing training in omr
digital marketing training in chennai
digital marketing training in omr
rpa training in chennai
rpa training in omr
tally training in chennai
tally training in omr
Excellent and very cool idea and great content of different kinds of the valuable information's.
RépondreSupprimerBest Tableau Training Institute in Pune
Apache Spark Training Institute in Pune
RépondreSupprimerNice blog! Thanks for sharing this valuable information
RPA Training in Hyderabad
RPA Training in Gurgaon
Hacking WiFi Password means no cost internet. WiFi Password Hacker For PC is going to be the computer software that's well to hack any Online Wifi Password Hack
RépondreSupprimerHitman Pro Crack works as anti-virus software. It detects and removes ransomware from your computer and supports system protection. Hitman Pro Bootable
RépondreSupprimer