-
Notifications
You must be signed in to change notification settings - Fork 19
/
newengine.txt
154 lines (143 loc) · 8.52 KB
/
newengine.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
- can't use:
- Commands.cpp -- require alias, cvar + command buffer support
? make as CCommandSource -- file, mem (+alias) etc; command buffer - in game (not Core)
--------------- OpenAL sound system -------------------
- from UT/ALSound:
FLOAT SoundPriority( UViewport* Viewport, FVector Location, FLOAT Volume, FLOAT Radius )
{
return Volume * (1.0 - (Location - (Viewport->Actor->ViewTarget
? Viewport->Actor->ViewTarget
: Viewport->Actor)->Location).Size()/Radius);
}
--------------- image/shader usage --------------------
- CBasicImage:
* name, width, height, alphaBits (?)
- virtual: Draw(), StretchDraw(), [Stretch]DrawNoAlpha() (or [Stretch]DrawAlpha() ?)
* virtual Reload()
- CImage:CBasicImage (-> CTexture, CGLTexture, ... (other name?))
* CShader:CBasicImage (-> CGLShader?):
- drawing:
* 3D: shaders only, accumulate scene, sort and draw
- 2D **: images and shaders; draw immediately (done); for drawing image, can use static temp shader with 1 stage -- insert image here;
because of immediate drawing, 1 temp shader is enough; temp shaders (templates):
- GUI picture with/without alpha
- skin
- creating 2D image/shader: when have script - create shader; when no script - use image itself (see **)
---------- console cmdline / command system -----------
- Cmd_ForwardToServer(): rename to CL_UnhandledCommand(), set as callback when initializing command system; should be implemented
as callback in CCommandBuffer (name?) class
- CCmdLineEditor -> GConCmdLine
properties:
- editLine[]
- history[]
- cursorPos (for visualization)
- RegisterCompletion - for automated completion
- KeyEvent - edit line, browse history, call completion
? command system
? execution buffer (can add strings, exec files)
! require standard key constants/interface
! when implement new command completion system, can change public cmdAlias_t,cmdFunc_t declarations -> private for "cmd.cpp";
public "cvar_vars", "cmdAlias", "cmdFuncs" -> static
- dedicated server, GConCmdLine:
- convert VK_KEY -> K_KEY and pass to GConCmdLine
- use cursorPos for cursor visualization
- should have capabilities of parsing of quake config files (but store configuration in INI ...)
--------------- Output ---------------------
- CErrorHandler:
- bool isDropError -- when Com_DropError; no such error in Core, so can place DropError() function in Engine; this func
will set "GDropError=true", and call appError(msg)
(?) may implement as:
a) "bool Engine::GDropError" - separate var, and GErr.Reset() will not reset this var (but, really, Reset() should
be called mostly after DropError() !) -- will reset this var manually
b) make derived "class GEngineErrorHandler <- GErrorHandler" with "virtual Reset()" and "bool dropError"; this will
require to set GErr with appInit()
(-) can remove func appNonFatalError() from Core, and, may be, rename appFatalError() to appError(), because no other
errors in Core; small (?) problem: console command "error -drop" -?
(!) isDropError == !fatalError; fatalError=true (now) called from Win32ExceptHandler() only, so, when not used WIN32_SEH,
any GFP will raise error without fatalError==true, and app will not crash -- incorrect!
------------------- GUI --------------------
- make K_CONSOLE, K_MENU, K_CANCEL -- as aliases or vars, do not use '`' or K_ESCAPE
- class CScreenObject {
Draw()
bool HandleEvent() == Key_Event()
bool Close() -- on K_CLOSE etc
Tick() == current Run()
}
- use for Menu, Console, Game (3D with world), Cinematic, Chat, HUD, LoadingSplash, DownloadingInfo
- SCR_StopCinematic(): remove from keys.cpp and cl_input.cpp -> move to CCinematic::HandleEvent()
? screenshot: may perform detection of correct place to perform from client (not inside renderer):
- how backend should perform drawing of 3D and 2D objects:
- 3D - exec frontend, sort surfaces and draw
- 2D - sorting will affect draw order and create incorrect scene, so - can exec immediately too
- currently, all screen objects depends on client or client_static structures - try to cut necessary fields
to separate structure
- time parameters: cls.realtime, cls.frametime
- GUI state: cls.key_dest, cls.loading, cl.cinematicActive, cls.download
------------------- Misc -------------------
- network:
- make channel_t (different name ??) as class, TcpChannel+LoopbackChannel as childs
? channel_t -> CNetStream
? stream readers: reading struc of data, little<->big endian; stream layout should be specified in format,
similar to my "entdelta.cpp" processing (struc offset + data format); may be useful for reading model/map/other data
- subsystems:
- separate client subsystems:
- input
- sound
- GUI
- 3D (scene graph?)
- screen (manage/visualize everything)
- network/game support
- CSubsystem: as class; all should Tick() from MainLoop() (not from client)
- schedule using system->MaxFps value (some subsystems really do not require high FPS)
- server: separate too (game+network; game - 10fps, network - more);
- add "bool inactive" - do not schedule
- global scheduler may create sleep() system calls when everything is fast enough!
------------ New renderer system -----------
- separate renderer (math only) and backend (OpenGL); call hierarchy: mainEngine->renderer->backend->gl
names: ref_gl -> SceneGraph + OpenGLDrv
- remove dependency on "gl.h", "glext.h", "qgl_*.h" etc from scene graph files
- backend should provide "caps" field:
- rect textures (GL_NV_texture_rectangle: clamp, no mipmap)
- rect textures 2 (GL_ARB_texture_non_power_of_two: full-featured textures)
- compressed textures (for disabling by menu)
- fast blend (for soft renderer: can draw console etc with opaque rects)
- fast culling (for soft: when "false" will try to cull everything before sending to backend)
- some lighting info (software, hardware with/without cubemaps etc)
- images.cpp -> renderer (not backend); backend - uploading only
* (abstract) class CImage, visible from GUI/client - implementation in renderer, some service funcs
(uploading, retreiving from screen, rendering to texture) - in backend
? vid_restart: restart backend ? (renderer restarting - unneeded ??); rename cmd ?
? share model/map loading with cmodel (separate into own library, used by server/client/renderer)
- CImage->CShader (CMaterial?); CImage->CGlImage; CMaterial->CGlMaterial
- client rendering:
- screen manager - top level, draw GUI and HUD; can draw 3D in GUI/HUD
- primary world 3D scene manager - entities, sprites/fx, dlights ...; will call renderer->DrawScene()
- NullBackend (builtin?) - empty functions; may be useful for on-fly switching to dedicated server and back to GUI
- BSP: class CBspNode -> class CBspLeaf (some additional fields)
- remove (or relax usage) of surfaceBase_t.type
- UpdateDynamicLightmap() -- for planar only?
- Cull() -- forntend.cpp
- ApplyDlights() -- frontend.cpp
- GetCluster() -- light.cpp
- BuildFlare() -- model.cpp -- for planar only?
- entity:
- function ent.DrawText() -- draw text for entity; can merge multiple DrawText() calls into a single text block;
do not draw, when entity invisible (optional - "bool visibleOnly")
Implementation: gl_text.cpp text buffer will comtain link to entity (to determine visibility; may link to NULL
when always draw), entity will contain number of linked text lines to compute 2D offset for next DrawText()
call (may be returned from DrawTextPos()); all texts will be placed into common text buffer
--------------- Memory manager -------------
- meminfo: implement subsystems (gl, game etc)
- chain helper: CMemoryChain::GetSize() - to get whole chains size
- TMemoryPool<size> - memory pool; like memory chain, but static memory and cannot be larger than "size"
- TMemoryPool::Alloc(size) -- increment internal pointer; check size!
- TMemoryPool::Release() -- reset internal pointer
? zero-fill memory ? (may be, on Release() - zero-fill ALLOCATED memory only)
! can use for GL::AllocDynamicMem()
- AllocTempMem(size) -- alloc memory from large static buffer (for use in functions); may be, use
"TMemoryPool<TEMP_MEM_SIZE> TempPool" for allocs
-------------------- Names -----------------
- BackEnd = Renderer/OpenGLDrv
- FrontEnd = SceneGraph
- Using skeletal animation = skinning; Q2 tech = KeyFrameAnimation
- Engine name - "Unified Engine" ? (may be used for 2D/3D apps, at least Core/GUI/Sound)