dxDrawMaterialPrimitive | Multi Theft Auto: Wiki Skip to content

dxDrawMaterialPrimitive

Client-side
Server-side
Shared
Needs checking

This function was partially migrated from the old wiki. Please review manually:

  • Missing section: Allowed types
  • Missing section: Vertices format

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


This function draws a 2D primitive shape with material applied to it across the screen - rendered for one frame. This should be used in conjunction with onClientRender in order to display continuously. If image file is used, it should ideally have dimensions that are a power of two, to prevent possible blurring. Power of two: 2px, 4px, 8px, 16px, 32px, 64px, 128px, 256px, 512px, 1024px...

Syntax

dxDrawMaterialPrimitive ( )

Code Examples

client
-- Load the texture
local texture = dxCreateTexture("myTexture.png")
-- Function to render a textured triangle
function renderPrimitive()
if texture then
-- Draw the primitive using the "trianglelist" type
-- 3 vertices, each with 4 numbers: {x, y, u, v}
dxDrawMaterialPrimitive("trianglelist", texture, false, {100, 100, 0, 0}, {300, 100, 1, 0}, {200, 300, 0.5, 1})
end
end
-- Add an event handler to render the primitive every frame
addEventHandler("onClientRender", root, renderPrimitive)