mirror of
https://github.com/TobyAdd/GDH.git
synced 2025-09-06 21:11:41 +00:00
recorder for android fix
This commit is contained in:
@@ -214,7 +214,7 @@ public:
|
||||
// m_touchedRings = player->// m_touchedRings;
|
||||
m_lastActivatedPortal = player->m_lastActivatedPortal;
|
||||
m_hasEverJumped = player->m_hasEverJumped;
|
||||
m_ringOrStreakRelated = player->m_ringOrStreakRelated;
|
||||
// m_ringOrStreakRelated = player->m_ringOrStreakRelated;
|
||||
m_playerColor1 = player->m_playerColor1;
|
||||
m_playerColor2 = player->m_playerColor2;
|
||||
m_position = player->m_position;
|
||||
@@ -522,7 +522,7 @@ public:
|
||||
// player->m_touchedRings = // m_touchedRings;
|
||||
player->m_lastActivatedPortal = m_lastActivatedPortal;
|
||||
player->m_hasEverJumped = m_hasEverJumped;
|
||||
player->m_ringOrStreakRelated = m_ringOrStreakRelated;
|
||||
// player->m_ringOrStreakRelated = m_ringOrStreakRelated;
|
||||
player->m_playerColor1 = m_playerColor1;
|
||||
player->m_playerColor2 = m_playerColor2;
|
||||
player->m_position = m_position;
|
||||
@@ -831,7 +831,7 @@ private:
|
||||
// gd::unordered_set<int> m_touchedRings;
|
||||
GameObject* m_lastActivatedPortal;
|
||||
bool m_hasEverJumped;
|
||||
bool m_ringOrStreakRelated;
|
||||
// bool m_ringOrStreakRelated;
|
||||
cocos2d::ccColor3B m_playerColor1;
|
||||
cocos2d::ccColor3B m_playerColor2;
|
||||
cocos2d::CCPoint m_position;
|
||||
|
@@ -32,36 +32,50 @@ void RenderTexture::begin() {
|
||||
void RenderTexture::capture_frame(std::mutex& lock, std::vector<uint8_t>& data, volatile bool& frame_has_data) {
|
||||
auto& recorder = Recorder::get();
|
||||
|
||||
#ifdef GEODE_IS_ANDROID
|
||||
auto flip_vertical = [this, &data]() {
|
||||
const size_t row_size = width * 3;
|
||||
uint8_t* top = data.data();
|
||||
uint8_t* bottom = data.data() + (height - 1) * row_size;
|
||||
|
||||
static thread_local std::vector<uint8_t> tmp_row;
|
||||
if (tmp_row.size() < row_size) tmp_row.resize(row_size);
|
||||
|
||||
for (int y = 0; y < height / 2; y++) {
|
||||
memcpy(tmp_row.data(), top, row_size);
|
||||
memcpy(top, bottom, row_size);
|
||||
memcpy(bottom, tmp_row.data(), row_size);
|
||||
top += row_size;
|
||||
bottom -= row_size;
|
||||
}
|
||||
};
|
||||
#else
|
||||
auto flip_vertical = [](){};
|
||||
#endif
|
||||
|
||||
if (recorder.overlay_mode) {
|
||||
lock.lock();
|
||||
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data.data());
|
||||
flip_vertical();
|
||||
frame_has_data = true;
|
||||
lock.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
auto director = cocos2d::CCDirector::get();
|
||||
auto scene = PlayLayer::get();
|
||||
|
||||
#ifdef GEODE_IS_ANDROID
|
||||
scene->setScaleY(-1);
|
||||
#endif
|
||||
scene->visit();
|
||||
#ifdef GEODE_IS_ANDROID
|
||||
scene->setScaleY(1);
|
||||
#endif
|
||||
|
||||
lock.lock();
|
||||
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data.data());
|
||||
flip_vertical();
|
||||
frame_has_data = true;
|
||||
lock.unlock();
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, oldFBO);
|
||||
|
||||
director->setViewport();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user