iMackshun

Drawing Example

Jan 4th, 2020
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. // WII, Uses my vertex struct.
  2. void ModelPart::DrawPart()
  3. {
  4. //Set the texture to be used.
  5. if(modelMaterial->texture){
  6. GX_LoadTexObj(&modelMaterial->texture->_textureObject, GX_TEXMAP0);
  7. }
  8. //Begin the drawing process for the designated amount of vertices.
  9. GX_Begin(GX_TRIANGLES, GX_VTXFMT0, _vertexList.size());
  10. //Loop through all of the vertices and send each attribute, such as the position and stuff.
  11. for(int i = 0; i < _vertexList.size(); i++){
  12. GX_Position3f32(positionArray[_vertexList.at(i).vertexID * positionStride], positionArray[_vertexList.at(i).vertexID * positionStride + 1], positionArray[_vertexList.at(i).vertexID * positionStride + 2]);
  13. GX_Color4u8(255, 255, 255, 255);
  14. GX_TexCoord2f32(uvArray[_vertexList.at(i).uvID * uvStride], 1 - uvArray[_vertexList.at(i).uvID * uvStride + 1]);
  15. }
  16.  
  17. GX_End();
  18. }
  19.  
  20. //3DS, Uses hard coded values.
  21. C3D_ImmDrawBegin(GPU_TRIANGLES);
  22. C3D_ImmSendAttrib(200.0f, 200.0f, 0.5f, 0.0f); // v0=position
  23. C3D_ImmSendAttrib(1.0f, 0.0f, 0.0f, 1.0f); // v1=color
  24.  
  25. C3D_ImmSendAttrib(100.0f, 40.0f, 0.5f, 0.0f);
  26. C3D_ImmSendAttrib(0.0f, 1.0f, 0.0f, 1.0f);
  27.  
  28. C3D_ImmSendAttrib(300.0f, 40.0f, 0.5f, 0.0f);
  29. C3D_ImmSendAttrib(0.0f, 0.0f, 1.0f, 1.0f);
  30. C3D_ImmDrawEnd();
Advertisement
Add Comment
Please, Sign In to add comment