Go で書き直した Ikemen
Revision | 4f1dcc84b9671f7e906260907aa954d914972add (tree) |
---|---|
Zeit | 2019-07-19 18:29:52 |
Autor | neatunsou <sisiy4excite@gmai...> |
Commiter | neatunsou |
Windblade氏の更新に対応
@@ -90,19 +90,19 @@ func main() { | ||
90 | 90 | "LifebarFontScale":1, |
91 | 91 | "System":"script/main.lua", |
92 | 92 | "KeyConfig":[{ |
93 | - "Joystick":-1, | |
94 | - "Buttons":["UP","DOWN","LEFT","RIGHT","z","x","c","a","s","d","RETURN","q","w"] | |
95 | - },{ | |
96 | - "Joystick":-1, | |
97 | - "Buttons":["t","g","f","h","j","k","l","u","i","o","RSHIFT","LEFTBRACKET","RIGHTBRACKET"] | |
98 | - }], | |
93 | + "Joystick":-1, | |
94 | + "Buttons":["UP","DOWN","LEFT","RIGHT","z","x","c","a","s","d","RETURN","q","w"] | |
95 | + },{ | |
96 | + "Joystick":-1, | |
97 | + "Buttons":["t","g","f","h","j","k","l","u","i","o","RSHIFT","LEFTBRACKET","RIGHTBRACKET"] | |
98 | + }], | |
99 | 99 | "JoystickConfig":[{ |
100 | - "Joystick":0, | |
101 | - "Buttons":["-7","-8","-5","-6","0","1","4","2","3","5","7","6","8"] | |
102 | - },{ | |
103 | - "Joystick":1, | |
104 | - "Buttons":["-7","-8","-5","-6","0","1","4","2","3","5","7","6","8"] | |
105 | - }], | |
100 | + "Joystick":0, | |
101 | + "Buttons":["-7","-8","-5","-6","0","1","4","2","3","5","7","6","8"] | |
102 | + },{ | |
103 | + "Joystick":1, | |
104 | + "Buttons":["-7","-8","-5","-6","0","1","4","2","3","5","7","6","8"] | |
105 | + }], | |
106 | 106 | "Motif":"data/system.def", |
107 | 107 | "CommonAir":"data/common.air", |
108 | 108 | "CommonCmd":"data/common.cmd", |
@@ -133,26 +133,27 @@ func main() { | ||
133 | 133 | "AllowDebugKeys":true, |
134 | 134 | "PostProcessingShader": 0, |
135 | 135 | "LocalcoordScalingType": 1, |
136 | + "MSAA": false, | |
136 | 137 | "IP":{ |
137 | 138 | } |
138 | 139 | } |
139 | 140 | `, "\n"), "\r\n")) |
140 | 141 | tmp := struct { |
141 | - HelperMax int32 | |
142 | - PlayerProjectileMax int | |
143 | - ExplodMax int | |
144 | - AfterImageMax int32 | |
145 | - MasterVolume int | |
146 | - WavVolume int | |
147 | - BgmVolume int | |
148 | - Attack_LifeToPowerMul float32 `json:"Attack.LifeToPowerMul"` | |
149 | - GetHit_LifeToPowerMul float32 `json:"GetHit.LifeToPowerMul"` | |
150 | - Width int32 | |
151 | - Height int32 | |
152 | - Super_TargetDefenceMul float32 `json:"Super.TargetDefenceMul"` | |
153 | - LifebarFontScale float32 | |
154 | - System string | |
155 | - KeyConfig []struct { | |
142 | + HelperMax int32 | |
143 | + PlayerProjectileMax int | |
144 | + ExplodMax int | |
145 | + AfterImageMax int32 | |
146 | + MasterVolume int | |
147 | + WavVolume int | |
148 | + BgmVolume int | |
149 | + Attack_LifeToPowerMul float32 `json:"Attack.LifeToPowerMul"` | |
150 | + GetHit_LifeToPowerMul float32 `json:"GetHit.LifeToPowerMul"` | |
151 | + Width int32 | |
152 | + Height int32 | |
153 | + Super_TargetDefenceMul float32 `json:"Super.TargetDefenceMul"` | |
154 | + LifebarFontScale float32 | |
155 | + System string | |
156 | + KeyConfig []struct { | |
156 | 157 | Joystick int |
157 | 158 | Buttons []interface{} |
158 | 159 | } |
@@ -160,17 +161,18 @@ func main() { | ||
160 | 161 | Joystick int |
161 | 162 | Buttons []interface{} |
162 | 163 | } |
163 | - NumTag int | |
164 | - TeamLifeShare bool | |
165 | - AIRandomColor bool | |
166 | - Fullscreen bool | |
167 | - AudioDucking bool | |
168 | - AllowDebugKeys bool | |
169 | - PostProcessingShader int32 | |
170 | - LocalcoordScalingType int32 | |
171 | - CommonAir string | |
172 | - CommonCmd string | |
173 | - QuickLaunch int | |
164 | + NumTag int | |
165 | + TeamLifeShare bool | |
166 | + AIRandomColor bool | |
167 | + Fullscreen bool | |
168 | + AudioDucking bool | |
169 | + AllowDebugKeys bool | |
170 | + MSAA bool | |
171 | + PostProcessingShader int32 | |
172 | + LocalcoordScalingType int32 | |
173 | + CommonAir string | |
174 | + CommonCmd string | |
175 | + QuickLaunch int | |
174 | 176 | }{} |
175 | 177 | chk(json.Unmarshal(defcfg, &tmp)) |
176 | 178 | const configFile = "data/config.json" |
@@ -234,6 +236,7 @@ func main() { | ||
234 | 236 | sys.teamLifeShare = tmp.TeamLifeShare |
235 | 237 | sys.fullscreen = tmp.Fullscreen |
236 | 238 | sys.PostProcessingShader = tmp.PostProcessingShader |
239 | + sys.MultisampleAntialiasing = tmp.MSAA | |
237 | 240 | sys.LocalcoordScalingType = tmp.LocalcoordScalingType |
238 | 241 | sys.aiRandomColor = tmp.AIRandomColor |
239 | 242 | sys.allowDebugKeys = tmp.AllowDebugKeys |
@@ -21,7 +21,12 @@ var indices = [4]int32{1, 2, 0, 3} | ||
21 | 21 | |
22 | 22 | // Post-processing |
23 | 23 | var fbo, fbo_texture uint32 |
24 | + | |
25 | +// Clasic AA | |
26 | +var rbo_depth uint32 | |
27 | +// MSAA | |
24 | 28 | var fbo_f, fbo_f_texture uint32 |
29 | + | |
25 | 30 | var postShader uintptr |
26 | 31 | var postVertAttrib int32 |
27 | 32 | var postTexUniform int32 |
@@ -199,33 +204,60 @@ func RenderInit() { | ||
199 | 204 | gl.DeleteObjectARB(vertObj) |
200 | 205 | gl.DeleteObjectARB(fragObj) |
201 | 206 | |
202 | - gl.Enable(gl.MULTISAMPLE) | |
207 | + if sys.MultisampleAntialiasing { | |
208 | + gl.Enable(gl.MULTISAMPLE) | |
209 | + } | |
203 | 210 | |
204 | 211 | gl.ActiveTexture(gl.TEXTURE0) |
205 | 212 | gl.GenTextures(1, &fbo_texture) |
206 | - gl.BindTexture(gl.TEXTURE_2D_MULTISAMPLE, fbo_texture) | |
213 | + | |
214 | + if sys.MultisampleAntialiasing { | |
215 | + gl.BindTexture(gl.TEXTURE_2D_MULTISAMPLE, fbo_texture) | |
216 | + } else { | |
217 | + gl.BindTexture(gl.TEXTURE_2D, fbo_texture) | |
218 | + } | |
219 | + | |
207 | 220 | gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST) |
208 | 221 | gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST) |
209 | 222 | gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE) |
210 | 223 | gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE) |
211 | - gl.TexImage2DMultisample(gl.TEXTURE_2D_MULTISAMPLE, 16, gl.RGBA, sys.scrrect[2], sys.scrrect[3], false) | |
224 | + | |
225 | + if sys.MultisampleAntialiasing { | |
226 | + gl.TexImage2DMultisample(gl.TEXTURE_2D_MULTISAMPLE, 16, gl.RGBA, sys.scrrect[2], sys.scrrect[3], false) | |
227 | + } else { | |
228 | + gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, sys.scrrect[2], sys.scrrect[3], 0, gl.RGBA, gl.UNSIGNED_BYTE, nil) | |
229 | + } | |
230 | + | |
212 | 231 | gl.BindTexture(gl.TEXTURE_2D, 0) |
213 | 232 | |
214 | - gl.GenTextures(1, &fbo_f_texture) | |
215 | - gl.BindTexture(gl.TEXTURE_2D, fbo_f_texture) | |
216 | - gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST) | |
217 | - gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST) | |
218 | - gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE) | |
219 | - gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE) | |
220 | - gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, sys.scrrect[2], sys.scrrect[3], 0, gl.RGBA, gl.UNSIGNED_BYTE, nil) | |
233 | + if sys.MultisampleAntialiasing { | |
234 | + gl.GenTextures(1, &fbo_f_texture) | |
235 | + gl.BindTexture(gl.TEXTURE_2D, fbo_f_texture) | |
236 | + gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST) | |
237 | + gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST) | |
238 | + gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE) | |
239 | + gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE) | |
240 | + gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, sys.scrrect[2], sys.scrrect[3], 0, gl.RGBA, gl.UNSIGNED_BYTE, nil) | |
241 | + } else { | |
242 | + gl.GenRenderbuffers(1, &rbo_depth) | |
243 | + gl.BindRenderbuffer(gl.RENDERBUFFER, rbo_depth) | |
244 | + gl.RenderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, sys.scrrect[2], sys.scrrect[3]) | |
245 | + gl.BindRenderbuffer(gl.RENDERBUFFER, 0) | |
246 | + } | |
221 | 247 | |
222 | 248 | gl.GenFramebuffers(1, &fbo) |
223 | 249 | gl.BindFramebuffer(gl.FRAMEBUFFER, fbo) |
224 | - gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D_MULTISAMPLE, fbo_texture, 0) | |
225 | 250 | |
226 | - gl.GenFramebuffers(1, &fbo_f) | |
227 | - gl.BindFramebuffer(gl.FRAMEBUFFER, fbo_f) | |
228 | - gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, fbo_f_texture, 0) | |
251 | + if sys.MultisampleAntialiasing { | |
252 | + gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D_MULTISAMPLE, fbo_texture, 0) | |
253 | + | |
254 | + gl.GenFramebuffers(1, &fbo_f) | |
255 | + gl.BindFramebuffer(gl.FRAMEBUFFER, fbo_f) | |
256 | + gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, fbo_f_texture, 0) | |
257 | + } else { | |
258 | + gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, fbo_texture, 0) | |
259 | + gl.FramebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, rbo_depth) | |
260 | + } | |
229 | 261 | |
230 | 262 | gl.BindFramebuffer(gl.FRAMEBUFFER, 0) |
231 | 263 | } |
@@ -235,11 +267,14 @@ func bindFB() { | ||
235 | 267 | } |
236 | 268 | |
237 | 269 | func unbindFB() { |
238 | - gl.BindFramebuffer(gl.DRAW_FRAMEBUFFER, fbo_f) | |
239 | - gl.BindFramebuffer(gl.READ_FRAMEBUFFER, fbo) | |
240 | - gl.BlitFramebuffer(0, 0, sys.scrrect[2], sys.scrrect[3], 0, 0, sys.scrrect[2], sys.scrrect[3], gl.COLOR_BUFFER_BIT, gl.LINEAR) | |
270 | + if sys.MultisampleAntialiasing { | |
271 | + gl.BindFramebuffer(gl.DRAW_FRAMEBUFFER, fbo_f) | |
272 | + gl.BindFramebuffer(gl.READ_FRAMEBUFFER, fbo) | |
273 | + gl.BlitFramebuffer(0, 0, sys.scrrect[2], sys.scrrect[3], 0, 0, sys.scrrect[2], sys.scrrect[3], gl.COLOR_BUFFER_BIT, gl.LINEAR) | |
274 | + } | |
241 | 275 | |
242 | 276 | gl.BindFramebuffer(gl.FRAMEBUFFER, 0) |
277 | + | |
243 | 278 | postShader = postShaderSelect[sys.PostProcessingShader] |
244 | 279 | |
245 | 280 | postVertAttrib = gl.GetAttribLocationARB(postShader, gl.Str("VertCoord\x00")) |
@@ -248,7 +283,13 @@ func unbindFB() { | ||
248 | 283 | |
249 | 284 | gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) |
250 | 285 | gl.UseProgramObjectARB(postShader) |
251 | - gl.BindTexture(gl.TEXTURE_2D, fbo_f_texture) | |
286 | + | |
287 | + if sys.MultisampleAntialiasing { | |
288 | + gl.BindTexture(gl.TEXTURE_2D, fbo_f_texture) | |
289 | + } else { | |
290 | + gl.BindTexture(gl.TEXTURE_2D, fbo_texture) | |
291 | + } | |
292 | + | |
252 | 293 | gl.Uniform1iARB(postTexUniform, 0) |
253 | 294 | gl.Uniform2fARB(postTexSizeUniform, float32(sys.scrrect[2]), float32(sys.scrrect[3])) |
254 | 295 | gl.EnableVertexAttribArrayARB(uint32(postVertAttrib)) |
@@ -64,14 +64,15 @@ var sys = System{ | ||
64 | 64 | keyInput: glfw.KeyUnknown, |
65 | 65 | keyString: "", |
66 | 66 | // Localcoord sceenpack |
67 | - luaSpriteScale: 1, | |
68 | - luaSmallPortraitScale: 1, | |
69 | - luaBigPortraitScale: 1, | |
70 | - luaSpriteOffsetX: 0, | |
71 | - lifebarScale: 1, | |
72 | - lifebarOffsetX: 0, | |
67 | + luaSpriteScale: 1, | |
68 | + luaSmallPortraitScale: 1, | |
69 | + luaBigPortraitScale: 1, | |
70 | + luaSpriteOffsetX: 0, | |
71 | + lifebarScale: 1, | |
72 | + lifebarOffsetX: 0, | |
73 | 73 | //Shader vars |
74 | - PostProcessingShader: 0, | |
74 | + MultisampleAntialiasing: false, | |
75 | + PostProcessingShader: 0, | |
75 | 76 | } |
76 | 77 | |
77 | 78 | type TeamMode int32 |
@@ -256,6 +257,7 @@ type System struct { | ||
256 | 257 | LocalcoordScalingType int32 |
257 | 258 | |
258 | 259 | PostProcessingShader int32 |
260 | + MultisampleAntialiasing bool | |
259 | 261 | } |
260 | 262 | |
261 | 263 | func (s *System) init(w, h int32) *lua.LState { |