File src/image_main.cpp changed (mode: 100644) (index 18558a6..554d7c1) |
... |
... |
struct RenderImage { |
203 |
203 |
model.ind.p_data = model.ver.p_data; |
model.ind.p_data = model.ver.p_data; |
204 |
204 |
|
|
205 |
205 |
model.world.position_offset = {}; |
model.world.position_offset = {}; |
206 |
|
model.world.position = {-0.5,1,-0.5}; |
|
|
206 |
|
model.world.position = {-0.5,0,-0.5}; |
207 |
207 |
model.world.transform = jm::scale<4>(1.f); |
model.world.transform = jm::scale<4>(1.f); |
208 |
208 |
return res; |
return res; |
209 |
209 |
} |
} |
|
... |
... |
struct Program |
263 |
263 |
res = model.init_mesh(&fw.graphics); |
res = model.init_mesh(&fw.graphics); |
264 |
264 |
jassert_release(res == VK_SUCCESS, vkw::to_string(res)); |
jassert_release(res == VK_SUCCESS, vkw::to_string(res)); |
265 |
265 |
|
|
266 |
|
screen.init(*fw.get_window(), {}, {0,1,0}, {0,0,1}); |
|
|
266 |
|
screen.init(*fw.get_window(), {0,-1, 0}, {0,1,0}, {0,0,1}); |
267 |
267 |
screen.frustum.zNear = 0.01f; |
screen.frustum.zNear = 0.01f; |
268 |
268 |
screen.frustum.zFar = 10; |
screen.frustum.zFar = 10; |
269 |
269 |
|
|
270 |
270 |
button_next = button_prev = button_key_up = button_key_down = {}; |
button_next = button_prev = button_key_up = button_key_down = {}; |
|
271 |
|
button_rm = {}; |
271 |
272 |
is_drawn = false; |
is_drawn = false; |
272 |
273 |
loop.run(fw.graphics, this, [](void *p){ |
loop.run(fw.graphics, this, [](void *p){ |
273 |
274 |
reinterpret_cast<Program*>(p)->update(); |
reinterpret_cast<Program*>(p)->update(); |
|
... |
... |
struct Program |
284 |
285 |
void update() { |
void update() { |
285 |
286 |
auto &w = *fw.get_window(); |
auto &w = *fw.get_window(); |
286 |
287 |
bool is_changed = false; |
bool is_changed = false; |
287 |
|
if (button_next.is_fired(Key::Board::kRight, w)) { |
|
|
288 |
|
if (button_next.is_fired(Key::Board::kRight, w) |
|
289 |
|
or |
|
290 |
|
button_rm.is_fired(Key::Mouse::mR, w)) { |
288 |
291 |
shader_type = ShaderType(shader_type + 1); |
shader_type = ShaderType(shader_type + 1); |
289 |
292 |
if (shader_type == SHADER_TYPE_COUNT) |
if (shader_type == SHADER_TYPE_COUNT) |
290 |
293 |
shader_type = ShaderType(); |
shader_type = ShaderType(); |
291 |
294 |
is_changed = true; |
is_changed = true; |
292 |
295 |
} |
} |
293 |
|
if (button_next.is_fired(Key::Board::kLeft, w)) { |
|
|
296 |
|
if (button_prev.is_fired(Key::Board::kLeft, w)) { |
294 |
297 |
if (shader_type == 0) |
if (shader_type == 0) |
295 |
298 |
shader_type = ShaderType(SHADER_TYPE_COUNT - 1); |
shader_type = ShaderType(SHADER_TYPE_COUNT - 1); |
296 |
299 |
else |
else |
|
... |
... |
struct Program |
302 |
305 |
case 3: shader_key = 7; is_changed = true; break; |
case 3: shader_key = 7; is_changed = true; break; |
303 |
306 |
case 7: shader_key = 15; is_changed = true; break; |
case 7: shader_key = 15; is_changed = true; break; |
304 |
307 |
} |
} |
305 |
|
|
|
306 |
308 |
} |
} |
307 |
309 |
if (button_key_up.is_fired(Key::Board::kDown, w)) { |
if (button_key_up.is_fired(Key::Board::kDown, w)) { |
308 |
310 |
switch(shader_key) { |
switch(shader_key) { |
|
... |
... |
struct Program |
312 |
314 |
} |
} |
313 |
315 |
|
|
314 |
316 |
loop.draw = w.is_damaged; |
loop.draw = w.is_damaged; |
|
317 |
|
|
|
318 |
|
if (w.scroll_diff.y != 0) { |
|
319 |
|
auto &pos = screen.camera.position.y; |
|
320 |
|
pos *= 1 + w.scroll_diff.y / 12; |
|
321 |
|
pos = jl::max(pos,-screen.frustum.zFar); |
|
322 |
|
pos = jl::min(pos,-screen.frustum.zNear); |
|
323 |
|
loop.draw = true; |
|
324 |
|
} |
|
325 |
|
if (w.is_on(Key::Mouse::mL) and not w.cursor_diff.all_equal(0)) { |
|
326 |
|
screen.camera.position.x += w.cursor_diff.x / 200; |
|
327 |
|
screen.camera.position.z -= w.cursor_diff.y / 200; |
|
328 |
|
loop.draw = true; |
|
329 |
|
} |
|
330 |
|
|
315 |
331 |
if (not loop.is_drawn) |
if (not loop.is_drawn) |
316 |
332 |
is_drawn = false; |
is_drawn = false; |
317 |
333 |
|
|
|
... |
... |
struct Program |
352 |
368 |
jen::Button button_prev; |
jen::Button button_prev; |
353 |
369 |
jen::Button button_key_up; |
jen::Button button_key_up; |
354 |
370 |
jen::Button button_key_down; |
jen::Button button_key_down; |
|
371 |
|
jen::Button button_rm; |
355 |
372 |
jrf::Image src_image; |
jrf::Image src_image; |
356 |
373 |
jrf::Image result_image; |
jrf::Image result_image; |
357 |
374 |
bool is_drawn; |
bool is_drawn; |