@@ -223,6 +223,7 @@ void GL4ElementalRenderer::BeginPaint(int render_target_w,
|
||||
|
||||
glUseProgram(program_);
|
||||
glBindVertexArray(vao_);
|
||||
glProgramUniform1f(program_, 2, 0.0f);
|
||||
}
|
||||
|
||||
void GL4ElementalRenderer::EndPaint() {
|
||||
@@ -250,15 +251,6 @@ void GL4ElementalRenderer::Flush() {
|
||||
}
|
||||
|
||||
void GL4ElementalRenderer::RenderBatch(Batch* batch) {
|
||||
auto bitmap = static_cast<GL4Bitmap*>(batch->bitmap);
|
||||
if (bitmap != current_bitmap_) {
|
||||
current_bitmap_ = bitmap;
|
||||
Flush();
|
||||
glProgramUniformHandleui64ARB(program_, 1,
|
||||
bitmap ? bitmap->gpu_handle_ : 0);
|
||||
glProgramUniform1f(program_, 2, bitmap ? 1.0f : 0.0f);
|
||||
}
|
||||
|
||||
if (draw_command_count_ + 1 > kMaxCommands) {
|
||||
Flush();
|
||||
}
|
||||
@@ -266,6 +258,16 @@ void GL4ElementalRenderer::RenderBatch(Batch* batch) {
|
||||
if (!vertex_buffer_.CanAcquire(total_length)) {
|
||||
Flush();
|
||||
}
|
||||
|
||||
auto bitmap = static_cast<GL4Bitmap*>(batch->bitmap);
|
||||
if (bitmap != current_bitmap_) {
|
||||
Flush();
|
||||
current_bitmap_ = bitmap;
|
||||
glProgramUniformHandleui64ARB(program_, 1,
|
||||
bitmap ? bitmap->gpu_handle_ : 0);
|
||||
glProgramUniform1f(program_, 2, bitmap ? 1.0f : 0.0f);
|
||||
}
|
||||
|
||||
auto allocation = vertex_buffer_.Acquire(total_length);
|
||||
|
||||
// TODO(benvanik): custom batcher that lets us use the ringbuffer memory
|
||||
|
||||
@@ -144,43 +144,49 @@ GLProfilerDisplay::GLProfilerDisplay(xe::ui::Window* window)
|
||||
window_->on_painted.AddListener([this](UIEvent& e) { Profiler::Present(); });
|
||||
|
||||
// Pass through mouse events.
|
||||
window_->on_mouse_down.AddListener([](xe::ui::MouseEvent& e) {
|
||||
if (Profiler::is_enabled()) {
|
||||
window_->on_mouse_down.AddListener([this](xe::ui::MouseEvent& e) {
|
||||
if (Profiler::is_visible()) {
|
||||
Profiler::OnMouseDown(e.button() == xe::ui::MouseEvent::Button::kLeft,
|
||||
e.button() == xe::ui::MouseEvent::Button::kRight);
|
||||
e.set_handled(true);
|
||||
window_->Invalidate();
|
||||
}
|
||||
});
|
||||
window_->on_mouse_up.AddListener([](xe::ui::MouseEvent& e) {
|
||||
if (Profiler::is_enabled()) {
|
||||
window_->on_mouse_up.AddListener([this](xe::ui::MouseEvent& e) {
|
||||
if (Profiler::is_visible()) {
|
||||
Profiler::OnMouseUp();
|
||||
e.set_handled(true);
|
||||
window_->Invalidate();
|
||||
}
|
||||
});
|
||||
window_->on_mouse_move.AddListener([](xe::ui::MouseEvent& e) {
|
||||
if (Profiler::is_enabled()) {
|
||||
window_->on_mouse_move.AddListener([this](xe::ui::MouseEvent& e) {
|
||||
if (Profiler::is_visible()) {
|
||||
Profiler::OnMouseMove(e.x(), e.y());
|
||||
e.set_handled(true);
|
||||
window_->Invalidate();
|
||||
}
|
||||
});
|
||||
window_->on_mouse_wheel.AddListener([](xe::ui::MouseEvent& e) {
|
||||
if (Profiler::is_enabled()) {
|
||||
window_->on_mouse_wheel.AddListener([this](xe::ui::MouseEvent& e) {
|
||||
if (Profiler::is_visible()) {
|
||||
Profiler::OnMouseWheel(e.x(), e.y(), -e.dy());
|
||||
e.set_handled(true);
|
||||
window_->Invalidate();
|
||||
}
|
||||
});
|
||||
|
||||
// Watch for toggle/mode keys and such.
|
||||
window_->on_key_down.AddListener([](xe::ui::KeyEvent& e) {
|
||||
if (Profiler::is_enabled()) {
|
||||
window_->on_key_down.AddListener([this](xe::ui::KeyEvent& e) {
|
||||
if (Profiler::is_visible()) {
|
||||
Profiler::OnKeyDown(e.key_code());
|
||||
e.set_handled(true);
|
||||
window_->Invalidate();
|
||||
}
|
||||
});
|
||||
window_->on_key_up.AddListener([](xe::ui::KeyEvent& e) {
|
||||
if (Profiler::is_enabled()) {
|
||||
window_->on_key_up.AddListener([this](xe::ui::KeyEvent& e) {
|
||||
if (Profiler::is_visible()) {
|
||||
Profiler::OnKeyUp(e.key_code());
|
||||
e.set_handled(true);
|
||||
window_->Invalidate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user