darhal Posted August 31, 2015 Share Posted August 31, 2015 Hello All; I m using object_preview resources (by Ren) to draw ped preview but I need the effect to be drawn before the dx drawing but I cant figure it out Ren told me to do some changes on c_main it dont work so here is my code : c_main.lua from line 323 : -- onClientHUDRender addEventHandler( "onClientRender", root, function() isMRTUsed = false if not isMRTShaderSupported or (#refOPTable == 0) then return end for index, this in ipairs( refOPTable ) do -- Draw secondary render target if refOPTable[index] then if refOPTable[index].isSecondRT then isMRTUsed = true end if refOPTable[index].enabled then local instance = this.instance if instance then instance:drawRenderTarget() end end end end if (isMRTUsed == false) and glRenderTarget then destroyElement( glRenderTarget ) glRenderTarget = nil outputDebugString('objPrev : no MRT objects visible - destroyed RT') end end, true, "high+10") My resource thet draw the DX : addEventHandler("onClientRender", root, drawInventory) addEventHandler("onClientRender", root, drawViewingItems) inventoryShown = true removeEventHandler("onClientRender", root, drawUseBar) showCursor(true) local x, y, z = getElementRotation(localPlayer) local rx, ry, rz = getElementRotation(localPlayer) ped = createPed(getElementModel(localPlayer),x ,y ,z, rx, ry, rz) myObject = exports.object_preview:createObjectPreview(ped,0,0,180, 95, 136, 170, 307, false, true, false) Thanks in advance ! Link to comment
Moderators IIYAMA Posted August 31, 2015 Moderators Share Posted August 31, 2015 line 26 of the first code: end, true, "high+10") end, true, "low") Lower = later triggered = on top. Link to comment
darhal Posted August 31, 2015 Author Share Posted August 31, 2015 Well I m sorry but it dont work Link to comment
Moderators IIYAMA Posted August 31, 2015 Moderators Share Posted August 31, 2015 Well, then I am sorry too. But that is how addEventHandlers work. You sure you aren't drawing anything over the GUI? Because if you set that optional argument to true, the dx will be drawing after the gui's have been drawn. Link to comment
darhal Posted August 31, 2015 Author Share Posted August 31, 2015 dxDrawRectangle(35, 24, 744, 551, tocolor(0, 0, 0, 236), true) this is how I draw dx Rectangles this how it Look while drawing all this code : http://imgur.com/MF5K8hg Link to comment
Moderators IIYAMA Posted August 31, 2015 Moderators Share Posted August 31, 2015 You sure you aren't drawing anything over the GUI? Because if you set that optional argument to true, the dx will be drawing after the gui's have been drawn. dxDrawRectangle(35, 24, 744, 551, tocolor(0, 0, 0, 236), [color=#FF0000]true[/color]) syntax dxDrawRectangle ( float startX, float startY, float width, float height [, int color = white, [color=#FF0000]bool postGUI = false[/color], bool subPixelPositioning = false ] ) dxDrawRectangle(35, 24, 744, 551, tocolor(0, 0, 0, 236), [color=#00BF00]false[/color]) Link to comment
darhal Posted August 31, 2015 Author Share Posted August 31, 2015 Well thanks for replying but nothing happen Here is my code that draw inventory : function drawInventory() dxDrawLine(35 - 1, 24 - 1, 35 - 1, 575, tocolor(0, 0, 0, 220), 1, false) dxDrawLine(779, 24 - 1, 35 - 1, 24 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(35 - 1, 575, 779, 575, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(779, 575, 779, 24 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawRectangle(35, 24, 744, 551, tocolor(0, 0, 0, 236), false) dxDrawRectangle(35, 24, 744, 46, tocolor(32, 32, 32, 255), false) dxDrawRectangle(333, 202, 408, 324, tocolor(18, 18, 18, 143), false) dxDrawText("CUP - Inventory", 33 + 1, 24 + 1, 779 + 1, 70 + 1, tocolor(0, 0, 0, 255), 3.00, "default-bold", "center", "center", true, false, false, true, false) dxDrawText("CUP - Inventory", 33, 24, 779, 70, tocolor(255, 255, 255, 255), 3.00, "default-bold", "center", "center", true, false, false, true, false) dxDrawRectangle(47, 92, 260, 449, tocolor(18, 18, 18, 143), false) outLineRectangle(47, 92, 260, 449) dxDrawRectangle(50, 92, 257, 35, tocolor(25, 25, 25, 243), false) outLineRectangle(50, 92, 257, 35) dxDrawText("Player Preview", 49 + 1, 93 + 1, 307 + 1, 127 + 1, tocolor(0, 0, 0, 255), 2.00, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Player Preview", 49, 93, 307, 127, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "center", false, false, false, true, false) dxDrawRectangle(322, 93, 457, 446, tocolor(56, 56, 56, 72), false) outLineRectangle(322, 93, 457, 446) dxDrawRectangle(321, 93, 453, 34, tocolor(34, 34, 34, 209), false) outLineRectangle(321, 93, 453, 34) dxDrawText("Items", 321, 93, 774, 127, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "center", false, false, false, true, false) dxDrawRectangle(323, 136, 451, 56, tocolor(32, 32, 32, 222), false) for i, v in pairs(groupCord) do dxDrawRectangle(v.x, v.y, v.w, v.h, v.color, false) outLineRectangle(v.x, v.y, v.w, v.h) dxDrawImage(v.x, v.y, v.w, v.h, v.path, 0, 0, 0, tocolor(255, 255, 255, 255), false) end dxDrawLine(747 - 1, 198 - 1, 747 - 1, 525, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(774, 198 - 1, 747 - 1, 198 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(747 - 1, 525, 774, 525, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(774, 525, 774, 198 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawRectangle(747, 198, 27, 327, tocolor(4, 4, 4, 143), false) dxDrawRectangle(747, 337, 27, 188, tocolor(85, 151, 7, 242), false) for i, v in pairs(itemsCord) do dxDrawRectangle(v.x, v.y, v.h, v.w, v.color, false) outLineRectangle(v.x, v.y, v.h, v.w) end for i, v in pairs(fastCord) do dxDrawRectangle(v.x, v.y, v.h, v.w, v.color, false) outLineRectangle(v.x, v.y, v.h, v.w) end dxDrawLine(81 - 1, 474 - 1, 81 - 1, 504, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(275, 474 - 1, 81 - 1, 474 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(81 - 1, 504, 275, 504, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(275, 504, 275, 474 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawRectangle(81, 474, 194, 30, openCraftColor, false) dxDrawText("Open Crafting Table", 81 - 1, 473 - 1, 275 - 1, 504 - 1, tocolor(0, 0, 0, 255), 1.20, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Open Crafting Table", 81 + 1, 473 - 1, 275 + 1, 504 - 1, tocolor(0, 0, 0, 255), 1.20, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Open Crafting Table", 81 - 1, 473 + 1, 275 - 1, 504 + 1, tocolor(0, 0, 0, 255), 1.20, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Open Crafting Table", 81 + 1, 473 + 1, 275 + 1, 504 + 1, tocolor(0, 0, 0, 255), 1.20, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Open Crafting Table", 81, 473, 275, 504, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, true, false) --exports.object_preview:setProjection(myObject, 95, 136, 170, 307) if currentDragItem and not isCraftingOpen then dxDrawImage(cX-20, cY-20, 41, 41, currentDragItem.path, 0, 0, 0, tocolor(255, 255, 255, 200), false) end end function showInventory() if cantCloseInventory then return end if not inventoryShown then if groupItemsSave[lastRealGroup] then currentViewingItems = groupItemsSave[lastRealGroup] else currentViewingItems = {} end addEventHandler("onClientRender", root, drawInventory) addEventHandler("onClientRender", root, drawViewingItems) inventoryShown = true removeEventHandler("onClientRender", root, drawUseBar) showCursor(true) local x, y, z = getElementRotation(localPlayer) local rx, ry, rz = getElementRotation(localPlayer) ped = createPed(getElementModel(localPlayer),x ,y ,z, rx, ry, rz) myObject = exports.object_preview:createObjectPreview(ped,0,0,180, 95, 136, 170, 307, false, true, false) elseif inventoryShown then removeEventHandler("onClientRender", root, drawInventory) removeEventHandler("onClientRender", root, drawViewingItems) inventoryShown = false addEventHandler("onClientRender", root, drawUseBar) showCursor(false) destroyElement(ped) exports.object_preview:destroyObjectPreview(myObject) if isCraftingOpen then removeEventHandler("onClientRender", root, drawCrafting) isCraftingOpen = false cCraftProgress = nil cantCloseInventory = false end end end bindKey("i", "down", showInventory) Link to comment
Moderators IIYAMA Posted August 31, 2015 Moderators Share Posted August 31, 2015 These are the two factors that can change the render ordering between two onClientRender handlers. There is only 1 thing left, both are using the same event >"onClientRender"<? If they are, then you are mistaking somewhere else. Link to comment
darhal Posted August 31, 2015 Author Share Posted August 31, 2015 well the renders are in the correct order I use outputChatBox to check but same problem but must my graphic card support MRT shaders for this to work ? Link to comment
Moderators IIYAMA Posted August 31, 2015 Moderators Share Posted August 31, 2015 Did you test it without other gui's arround it? And yes your hardware/software must support it in order to use it. Link to comment
darhal Posted August 31, 2015 Author Share Posted August 31, 2015 drawing just the ped working with any DX or any GUI yes work and when the resource started it said MRT is not supported that mean it will not work or what ? Link to comment
Moderators IIYAMA Posted August 31, 2015 Moderators Share Posted August 31, 2015 I don't know exactly what (Multiple Render Targets) are, but afaik that has nothing to do with rendering 2D MTA(dx functions) layers over each other. But if you have your visuals, it has to do with your or ren's code. Link to comment
darhal Posted August 31, 2015 Author Share Posted August 31, 2015 Strange really lets wait for Ren Post maybe or unitil I find the problem by myself Link to comment
arezu Posted September 1, 2015 Share Posted September 1, 2015 You can fix it by drawing your dx stuff into a render target and changing the depth that you render the texture (also enabling depth checking), the same way I believe Ren's shader does it. Link to comment
darhal Posted September 1, 2015 Author Share Posted September 1, 2015 to be honest I didnt understand one world of what are you saying I m bad at shaders help me by example please Link to comment
LoOs Posted September 1, 2015 Share Posted September 1, 2015 test :# function drawInventory() dxDrawLine(35 - 1, 24 - 1, 35 - 1, 575, tocolor(0, 0, 0, 220), 1, false) dxDrawLine(779, 24 - 1, 35 - 1, 24 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(35 - 1, 575, 779, 575, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(779, 575, 779, 24 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawRectangle(35, 24, 744, 46, tocolor(32, 32, 32, 255), false) dxDrawRectangle(333, 202, 408, 324, tocolor(18, 18, 18, 143), false) dxDrawText("CUP - Inventory", 33 + 1, 24 + 1, 779 + 1, 70 + 1, tocolor(0, 0, 0, 255), 3.00, "default-bold", "center", "center", true, false, false, true, false) dxDrawText("CUP - Inventory", 33, 24, 779, 70, tocolor(255, 255, 255, 255), 3.00, "default-bold", "center", "center", true, false, false, true, false) dxDrawRectangle(47, 92, 260, 449, tocolor(18, 18, 18, 143), false) outLineRectangle(47, 92, 260, 449) dxDrawRectangle(50, 92, 257, 35, tocolor(25, 25, 25, 243), false) outLineRectangle(50, 92, 257, 35) dxDrawText("Player Preview", 49 + 1, 93 + 1, 307 + 1, 127 + 1, tocolor(0, 0, 0, 255), 2.00, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Player Preview", 49, 93, 307, 127, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "center", false, false, false, true, false) dxDrawRectangle(322, 93, 457, 446, tocolor(56, 56, 56, 72), false) outLineRectangle(322, 93, 457, 446) dxDrawRectangle(321, 93, 453, 34, tocolor(34, 34, 34, 209), false) outLineRectangle(321, 93, 453, 34) dxDrawText("Items", 321, 93, 774, 127, tocolor(255, 255, 255, 255), 2.00, "default-bold", "center", "center", false, false, false, true, false) dxDrawRectangle(323, 136, 451, 56, tocolor(32, 32, 32, 222), false) dxDrawRectangle(35, 24, 744, 551, tocolor(0, 0, 0, 236), false) for i, v in pairs(groupCord) do dxDrawRectangle(v.x, v.y, v.w, v.h, v.color, false) outLineRectangle(v.x, v.y, v.w, v.h) dxDrawImage(v.x, v.y, v.w, v.h, v.path, 0, 0, 0, tocolor(255, 255, 255, 255), false) end dxDrawLine(747 - 1, 198 - 1, 747 - 1, 525, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(774, 198 - 1, 747 - 1, 198 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(747 - 1, 525, 774, 525, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(774, 525, 774, 198 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawRectangle(747, 198, 27, 327, tocolor(4, 4, 4, 143), false) dxDrawRectangle(747, 337, 27, 188, tocolor(85, 151, 7, 242), false) for i, v in pairs(itemsCord) do dxDrawRectangle(v.x, v.y, v.h, v.w, v.color, false) outLineRectangle(v.x, v.y, v.h, v.w) end for i, v in pairs(fastCord) do dxDrawRectangle(v.x, v.y, v.h, v.w, v.color, false) outLineRectangle(v.x, v.y, v.h, v.w) end dxDrawLine(81 - 1, 474 - 1, 81 - 1, 504, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(275, 474 - 1, 81 - 1, 474 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(81 - 1, 504, 275, 504, tocolor(0, 0, 0, 255), 1, false) dxDrawLine(275, 504, 275, 474 - 1, tocolor(0, 0, 0, 255), 1, false) dxDrawRectangle(81, 474, 194, 30, openCraftColor, false) dxDrawText("Open Crafting Table", 81 - 1, 473 - 1, 275 - 1, 504 - 1, tocolor(0, 0, 0, 255), 1.20, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Open Crafting Table", 81 + 1, 473 - 1, 275 + 1, 504 - 1, tocolor(0, 0, 0, 255), 1.20, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Open Crafting Table", 81 - 1, 473 + 1, 275 - 1, 504 + 1, tocolor(0, 0, 0, 255), 1.20, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Open Crafting Table", 81 + 1, 473 + 1, 275 + 1, 504 + 1, tocolor(0, 0, 0, 255), 1.20, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Open Crafting Table", 81, 473, 275, 504, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, true, false) --exports.object_preview:setProjection(myObject, 95, 136, 170, 307) if currentDragItem and not isCraftingOpen then dxDrawImage(cX-20, cY-20, 41, 41, currentDragItem.path, 0, 0, 0, tocolor(255, 255, 255, 200), false) end end Link to comment
darhal Posted September 1, 2015 Author Share Posted September 1, 2015 Nice one lol (didnt work) Link to comment
Ren_712 Posted September 1, 2015 Share Posted September 1, 2015 In your resources line 9 you have createObjectPreview function. I noticed that you create a non Multiple Render Target variant ( the last variable is set to 'false'). The visible vehicle is rendered in world space (before MTA stuff), it is not rendered in a separate render target. Change the last flag to true and you'll get MRT effect. You'd cartainly notice that your graphics card doesn't support MRT in shader - you'd be notified in chatbox and debug. Link to comment
darhal Posted September 2, 2015 Author Share Posted September 2, 2015 thank you now you made things clear but if my graphics card dont support MRT it will not work ? (Wwill not be drawn before DX ?) thx in advance Link to comment
Einheit-101 Posted September 2, 2015 Share Posted September 2, 2015 Is it possible to prevent the object_preview from "flickering" as soon as the object preview is created or destroyed? I could offer a video showing this and other issues. Link to comment
Ren_712 Posted September 2, 2015 Share Posted September 2, 2015 Is it possible to prevent the object_preview from "flickering" as soon as the object preview is created or destroyed? I could offer a video showing this and other issues. I also noticed that. I don't really know what seems to be the reason of that - is the effect is applied later, or some variable is not set at startup. Please send PM with link to the video. thank you now you made things clear but if my graphics card dont support MRT it will not work ? (Wwill not be drawn before DX ?) thx in advance When you start the objectPreview resource - if your GFX doesn't support MRT then you will be noted in chatbox - objPrev: 'MRT in shaders not supported!' In this case If you create preview of an object with MRT flag set to true - the object will not be rendered and the function will return false. Link to comment
Einheit-101 Posted September 2, 2015 Share Posted September 2, 2015 Here is the video for all. I could give you my little "example shop" resource if you want, but its nothing special. Link to comment
Ren_712 Posted September 3, 2015 Share Posted September 3, 2015 (edited) Here is the video for all.... I assume that it happens only for an MRT variant. For some graphics cards the alpha of the world object seems to be too low - it needs to exceed a certain value. I increased it. Download the latest version and tell me if it changes anything. Edited September 3, 2015 by Guest Link to comment
LoOs Posted September 3, 2015 Share Posted September 3, 2015 where Code For Weapons ? Link to comment
Ren_712 Posted September 3, 2015 Share Posted September 3, 2015 where Code For Weapons ? You can apply the effect to objects, peds and vehicles. You will find model ids here: https://wiki.multitheftauto.com/wiki/Weapon Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now