Jump to content

Render text in a square


uriid1

Recommended Posts

Hello.
I'm doing something like a GUI, and I need to draw text inside a square or rectangle.
I tried to implement this using dxCreateRenderTarget, but it allows you to create a render target element not in the specified coordinates, as I reported in the issue on github.

Maybe there are ideas on how it could be implemented yet?
Maybe there is some shader...

spacer.png

Edited by uriid1
Link to comment
  • Moderators
38 minutes ago, uriid1 said:

I tried to implement this using dxCreateRenderTarget, but it allows you to create a render target element not in the specified coordinates, as I reported in the issue on github.

You capture it in the left-top-corner of your screen and use dxDrawImage to draw it at the correct location. Everything you capture will not be drawn (immediately).

That is how it is suppose to work.

Link to comment
9 minutes ago, IIYAMA said:

You capture it in the left-top-corner of your screen and use dxDrawImage to draw it at the correct location. Everything you capture will not be drawn (immediately).

That is how it is suppose to work.

Since the dxCreateRenderTarget draws in the upper-left corner, this creates problems for me.
If the function had the form dxCreateRenderTarget (x, y, w, h, [ ... ]), I wouldn't ask this question :_)

Link to comment
57 minutes ago, uriid1 said:

Since the dxCreateRenderTarget draws in the upper-left corner, this creates problems for me.
If the function had the form dxCreateRenderTarget (x, y, w, h, [ ... ]), I wouldn't ask this question :_)

Sorry, you misunderstand. Do you have any idea about the math involved in drawing pixels onto screen? I had been as naive as you, so don't worry and please listen carefully, lad.

You want to place your text inside of the rectangle pos = (x,y) with size (w, h). Now imagine that you only want to have a partial area, in your case a rectangle pos=(xs,ys), size=(ws,hs) visible of your text. The ONLY WAY to perform text scissoring is the render target, thus we choose it (if you disagree feel free to post an issue on the MTA GitHub, I would appreciate that). We can place a render target on-screen using the dxDrawImage function call, thus I hope you realize that there is a screen coordinate position at which the render target resides at as "raster" plus a size (rx, ry, rw, rh). Render target is our scissor, so (xs,ys) = (rx,ry) and (ws,hs) = (rw,rh). After you call dxSetRenderTarget, all drawing coordinates are turned relative to (rx,ry), thus...

pos of text on render-target = (x,y) - (rx,ry)

size of render-target = size of the area that you want to cut out of your text = (ws,hs)

Do not forget to call dxSetRenderTarget() to get back to drawing onto the main screen space.

Edited by The_GTA
Link to comment
  • Moderators
5 hours ago, uriid1 said:

draws in the upper-left corner, this creates problems for me.

It captures there as a scissor. (as The_GTA explains)

But what problems are you referring to? (Re-writing your script is not one of them ?)

Link to comment
2 hours ago, IIYAMA said:

It captures there as a scissor. (as The_GTA explains)

But what problems are you referring to? (Re-writing your script is not one of them ?)

I know how the function works, of course, in the end I rewrote the resource for its use.

But I still find it inconvenient :F

(terrible fonts are due to the launch of MTA in wine)

spacer.png

Link to comment
7 hours ago, uriid1 said:

I know how the function works, of course, in the end I rewrote the resource for its use.

But I still find it inconvenient :F

(terrible fonts are due to the launch of MTA in wine)

spacer.png

Wait, how were you able to run MTA in wine? Which version are you running?

Edited by vicisdev
Link to comment

I am perplexed by the procedure of this support topic, but it just shows how creative minds are working asynchronously in relation to people trying to help them. I mean there are people who want to help you because they emotionally engage into support but that's OK. I wonder if OP has any more questions?

Link to comment
5 hours ago, vicisdev said:

Wait, how were you able to run MTA in wine? Which version are you running?

wine-6.15 works good

 

2 hours ago, The_GTA said:

I am perplexed by the procedure of this support topic, but it just shows how creative minds are working asynchronously in relation to people trying to help them. I mean there are people who want to help you because they emotionally engage into support but that's OK. I wonder if OP has any more questions?

I am grateful to you for your detailed answer and thank you for helping ;)

Edited by uriid1
  • Like 1
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...