1
1
using System ;
2
2
using System . Numerics ;
3
3
using System . Text ;
4
+ using System . Text . RegularExpressions ;
4
5
using ImGuiNET ;
5
6
using Veldrid ;
6
7
using Veldrid . Sdl2 ;
@@ -11,8 +12,8 @@ namespace YALCT
11
12
{
12
13
public class RuntimeContext : IDisposable
13
14
{
14
- Sdl2Window window ;
15
- bool windowResized = false ;
15
+ private Sdl2Window window ;
16
+ private bool windowResized = false ;
16
17
17
18
private GraphicsBackend backend ;
18
19
private bool isInitialized ;
@@ -35,6 +36,7 @@ public class RuntimeContext : IDisposable
35
36
private ShaderDescription vertexShaderDesc ;
36
37
private Shader [ ] shaders ;
37
38
private string currentFragmentShader ;
39
+ private int fragmentHeaderLineCount = - 1 ;
38
40
39
41
private ImGuiRenderer imGuiRenderer ;
40
42
private ImGuiController uiController ;
@@ -43,6 +45,18 @@ public class RuntimeContext : IDisposable
43
45
public GraphicsDevice GraphicsDevice => graphicsDevice ;
44
46
public int Width => window . Width ;
45
47
public int Height => window . Height ;
48
+ public Sdl2Window Window => window ;
49
+ public int FragmentHeaderLineCount
50
+ {
51
+ get
52
+ {
53
+ if ( fragmentHeaderLineCount == - 1 )
54
+ {
55
+ fragmentHeaderLineCount = Regex . Split ( fragmentHeaderCode , "\r \n |\r |\n " ) . Length ;
56
+ }
57
+ return fragmentHeaderLineCount ;
58
+ }
59
+ }
46
60
47
61
public RuntimeContext ( GraphicsBackend backend )
48
62
{
@@ -56,7 +70,11 @@ public void Initialize()
56
70
// SDL init
57
71
WindowCreateInfo windowCI = new WindowCreateInfo ( )
58
72
{
73
+ #if DEBUG
59
74
WindowInitialState = WindowState . Maximized ,
75
+ #else
76
+ WindowInitialState = WindowState . BorderlessFullScreen ,
77
+ #endif
60
78
WindowTitle = $ "Yet Another Live Coding Tool ({ backend } )",
61
79
WindowWidth = 200 ,
62
80
WindowHeight = 200
@@ -344,9 +362,7 @@ void main()
344
362
{
345
363
gl_Position = vec4(Position, 1);
346
364
}" ;
347
- private const string fragmentHeaderCode = @"
348
- #version 450
349
-
365
+ public const string fragmentHeaderCode = @"#version 450
350
366
layout(set = 0, binding = 0) uniform RuntimeData
351
367
{
352
368
vec4 mouse;
@@ -355,8 +371,6 @@ void main()
355
371
float deltaTime;
356
372
int frame;
357
373
};
358
-
359
374
layout(location = 0) out vec4 out_Color;" ;
360
-
361
375
}
362
376
}
0 commit comments