@ -26,10 +26,15 @@ namespace ImGuiNET
private bool _ mainWindowOpened ;
private static double s_desiredFrameLength = 1f / 6 0.0f ;
private DateTime _ previousFrameStartTime ;
private float _ scaleFactor ;
private System . Numerics . Vector3 _ positionValue = new System . Numerics . Vector3 ( 5 0 0 ) ;
public unsafe SampleWindow ( )
{
_ nativeWindow = new NativeWindow ( 9 6 0 , 5 4 0 , "ImGui.NET" , GameWindowFlags . Default , OpenTK . Graphics . GraphicsMode . Default , DisplayDevice . Default ) ;
int desiredWidth = 9 6 0 , desiredHeight = 5 4 0 ;
_ nativeWindow = new NativeWindow ( desiredWidth , desiredHeight , "ImGui.NET" , GameWindowFlags . Default , OpenTK . Graphics . GraphicsMode . Default , DisplayDevice . Default ) ;
_ scaleFactor = _ nativeWindow . Width / desiredWidth ;
GraphicsContextFlags flags = GraphicsContextFlags . Default ;
_ graphicsContext = new GraphicsContext ( GraphicsMode . Default , _ nativeWindow . WindowInfo , 3 , 0 , flags ) ;
_ graphicsContext . MakeCurrent ( _ nativeWindow . WindowInfo ) ;
@ -110,7 +115,7 @@ namespace ImGuiNET
IO io = ImGui . GetIO ( ) ;
// Build texture atlas
Alpha8Tex Data texData = io . FontAtlas . GetTexDataAsAlpha8 ( ) ;
FontTexture Data texData = io . FontAtlas . GetTexDataAsAlpha8 ( ) ;
// Create OpenGL texture
s_fontTexture = GL . GenTexture ( ) ;
@ -166,7 +171,7 @@ namespace ImGuiNET
{
IO io = ImGui . GetIO ( ) ;
io . DisplaySize = new System . Numerics . Vector2 ( _ nativeWindow . Width , _ nativeWindow . Height ) ;
io . DisplayFramebufferScale = new System . Numerics . Vector2 ( 1 , 1 ) ;
io . DisplayFramebufferScale = new System . Numerics . Vector2 ( _ scaleFactor ) ;
io . DeltaTime = ( 1f / 6 0f ) ;
UpdateImGuiInput ( io ) ;
@ -214,13 +219,14 @@ namespace ImGuiNET
ImGui . TextColored ( new System . Numerics . Vector4 ( 0 , 1 , 1 , 1 ) , $"Button pressed {_pressCount} times." ) ;
ImGui . InputTextMultiline ( "Input some numbers :" ,
ImGui . InputTextMultiline ( "Input some text :" ,
_ textInputBuffer , ( uint ) _ textInputBufferLength ,
new System . Numerics . Vector2 ( 3 6 0 , 2 4 0 ) ,
InputTextFlags . CharsDecimal ,
InputTextFlags . Default ,
OnTextEdited ) ;
ImGui . SliderFloat ( "SlidableValue" , ref _ sliderVal , - 5 0f , 1 0 0f , $"{_sliderVal.ToString(" # # 0.00 ")}" , 1.0f ) ;
ImGui . DragVector3 ( "Vector3" , ref _ positionValue , - 1 0 0 , 1 0 0 ) ;
if ( ImGui . TreeNode ( "First Item" ) )
{
@ -302,7 +308,7 @@ namespace ImGuiNET
if ( _ nativeWindow . Bounds . Contains ( cursorState . X , cursorState . Y ) )
{
Point windowPoint = _ nativeWindow . PointToClient ( new Point ( cursorState . X , cursorState . Y ) ) ;
io . MousePosition = new System . Numerics . Vector2 ( windowPoint . X , windowPoint . Y ) ;
io . MousePosition = new System . Numerics . Vector2 ( windowPoint . X / io . DisplayFramebufferScale . X , windowPoint . Y / io . DisplayFramebufferScale . Y ) ;
}
else
{
@ -350,14 +356,19 @@ namespace ImGuiNET
// Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
IO io = ImGui . GetIO ( ) ;
float fb_height = io . DisplaySize . Y * io . DisplayFramebufferScale . Y ;
ImGui . ScaleClipRects ( draw_data , io . DisplayFramebufferScale ) ;
// Setup orthographic projection matrix
GL . MatrixMode ( MatrixMode . Projection ) ;
GL . PushMatrix ( ) ;
GL . LoadIdentity ( ) ;
GL . Ortho ( 0.0f , io . DisplaySize . X , io . DisplaySize . Y , 0.0f , - 1.0f , 1.0f ) ;
GL . Ortho (
0.0f ,
io . DisplaySize . X / io . DisplayFramebufferScale . X ,
io . DisplaySize . Y / io . DisplayFramebufferScale . Y ,
0.0f ,
- 1.0f ,
1.0f ) ;
GL . MatrixMode ( MatrixMode . Modelview ) ;
GL . PushMatrix ( ) ;
GL . LoadIdentity ( ) ;
@ -390,7 +401,7 @@ namespace ImGuiNET
GL . BindTexture ( TextureTarget . Texture2D , pcmd - > TextureId . ToInt32 ( ) ) ;
GL . Scissor (
( int ) pcmd - > ClipRect . X ,
( int ) ( fb_height - pcmd - > ClipRect . W ) ,
( int ) ( io . DisplaySize . Y - pcmd - > ClipRect . W ) ,
( int ) ( pcmd - > ClipRect . Z - pcmd - > ClipRect . X ) ,
( int ) ( pcmd - > ClipRect . W - pcmd - > ClipRect . Y ) ) ;
ushort [ ] indices = new ushort [ pcmd - > ElemCount ] ;