Jump to content

About DxDrawImage and DxDrawRectangle


DEFCON1

Recommended Posts

Hello MTA community, first let me introduce myself a bit! I'm new to MTA, and I want to get into scripting cool things, because i'm really bored of SA:MP :)

Ok now for my question! Before I start making my script and my images, i would like to know few things because I'm unsure:

- I want to use DxDrawRectangle and DxDrawImage (in a client side script).

- The image which will be displayed have some places with transparency.

- The rectangle will be displayed behind my image.

- I want my rectangle to fill the transparent places of the image.

So my first question is, will I see the rectangle's color where the image is transparent?

My second question: my script will draw a new image every frame, can I draw the rectangle only once (as it will not change often) and display/hiding differents images on top of it without any display problems ?

Also in DxDrawImage I see a parameter 'color', and I'm wondering if I need to set it to 0 so my image's transparency work?

Thanks for your time, i hope this is possible ;)

Link to comment

1. Yes, .png files work with transparency and so does dxDrawImage.

2. No, every DirectX drawing function needs to be used every frame. Alternatively, you can create background rectangle with GUI function (guiCreateStaticImage) which will be displayed until guiSetVisible is called to hide it.

3. You should set it to 0 unless you want to get some effects like this:

https://community.multitheftauto.com/index.php?p= ... ils&id=427

I change gauge colour based on time.

Link to comment

Sorry for bump, everything goes well in my script :D but I don't understand something:

tocolor(0, 0, 255, 255) is true blue color, but why 0xFF0000FF give black color (at least in DxDrawRectangle) ? Isn't it the same blue color? I think that is a bug, but I'm not sure, can anyone tell me what is wrong with this 0xFF0000FF ?

Link to comment

I really think the hex color codes are bugged, well that's not a real problem actually,I will ask something else now ;)

In fact i am doing a speedometer, which uses only images, and I am wondering what is more efficient (please do not answer if you don't really know!) :

- Drawing differents images every frames with the dxDrawImage function in onClientRender, or

- Drawing static images with guiCreateStaticImage and change them with guiStaticImageLoadImage inside a 50ms timer ?

Note that i still need onClientRender for rendering the background rectangle with dxDrawRectangle. The speed is calculated inside the 50ms timer, so isn't called every frame which is better, I THINK! I'm just hesiting on what method from above I should use. Both methods works perfectly fine and are working very similarly, and I don't see any fps lose with either methods (playing on local server, which should not have any effect since it is a client side script, and on my laptop which isn't really a gaming computer). I really think the second method require less cpu usage but I'm unsure, since gui functions are probably not as efficient as the directx functions.

I just care a lot about efficiency of scripts, hope someone will give me advices on what method is better for what i want to achieve ;)

Thanks!

Link to comment

Damn, I forgot to say, it's not a analog speedometer :). It's using digits so it doesn't need to be updated as often as a needle.

Here is the current, not finished look:

vxit.png

I've got few nice comments about it so I release it when finished. It is kind of skinnable.. :)

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...