I need help with a problem

Blitz3D Forums/Blitz3D Programming/I need help with a problem

Yue(Posted 2012) [#1]
I put a few sliders to change options in a graphical menu, everything works fine if the resolutions are below 1024 x 768 everything works fine, however on screen resolutions above 800 x 600, the sliders stop working.

Now, I'm using Draw3D2 for GUI system and enl problem fixed a command called Origin3D (800,600), however if the command does not use the sliders work properly, however the background image that I have is no longer on the side left of the screen, but it will run towards the center of the screen.

I would appreciate any help on this case.

The code implemented to establish the background is this.


; sliders do not work at resolutions greater than 800 x 600
Origin3D (800,600)
Rect3D(Menu_Fondo%,320,0,80,GraphicsHeight(),1,0)





; If the sliders work, but the menu runs instead of the screen right side.
;Origin3D (800,600)
Rect3D(Menu_Fondo%,320,0,80,GraphicsHeight(),1,0)





Last edited 2012


Yue(Posted 2012) [#2]
Ok no problem.
; No Origin3D (800,600)
GraphicsWidth()/2-80



Kryzon(Posted 2012) [#3]
Just to make things clear, the solution you found works because you're laying out the GUI according to offsets instead of hard-coded values.

The line...
[bbcode]GraphicsWidth()/2-80[/bbcode]...tells your program to position the GUI element at the right side of the screen - under whatever active resolution - and then back 80 pixels.

If you plan on having a lot of GUI in your game, you need to make a better system. This would be possible if you adopted the UV coordinate system: the same used for texture coordinates.

It works with percentages, values going from 0.0 to 1.0.
This way, no matter the texture size (or screen resolution), you can easily find specific points on it like the center for instance: [0.5, 0.5] - this would give you the center of any whatever-sized texture or screen.

So when you're drawing GUI elements and need to find their real on-screen pixel values, you can use auxiliary functions that map UV-space to screen-space:

[bbcode]Function GetRealX#( U# )
Return (GraphicsWidth() * U)
End Function

Function GetRealY#( V# )
Return (GraphicsHeight() * V)
End Function[/bbcode]
And use them like this:

[bbcode]
;---------- Position and scale elements with UV coordinates.----------

menuFondo\width# = 0.10
menuFondo\height# = 1.0 ;The full height of the screen.

;In Draw3D, everything is mid-handled: all images are positioned by their center.
menuFondo\x# = 1.0 - (menuFondo\width / 2.0) ;At the right side of the screen, but perfectly fit.
menuFondo\y# = 0.5


;---------- Render elements with their corresponding pixel coordinates. ----------

;Rect3D( XCenter%, YCenter%, XSize%, YSize%, Fill%, DrawSize% )
Rect3D( GetRealX(menuFondo\x), GetRealY(menuFondo\y), GetRealX(menuFondo\width), GetRealY(menuFondo\height), 1, 0)[/bbcode]

Last edited 2012


Yue(Posted 2012) [#4]
ok, Tanaks :)