Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
luishfonseca committed Jun 13, 2024
1 parent 2c5dc19 commit 1354f0b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
29 changes: 11 additions & 18 deletions core/samples/gl/quad/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,28 +118,21 @@ int main()
textureBP->bind(sampler);
cbBP->bind(cb);

{
auto& mvp = *(glm::mat4*)cb->map();
mvp = glm::perspective(glm::radians(70.0F), float(sz.x) / float(sz.y), 0.1F, 1000.0F) *
glm::lookAt(glm::vec3{0.0F, 0.0F, -5.0F}, glm::vec3{0.0F, 0.0F, 0.0F},
glm::vec3{0.0F, 1.0F, 0.0F}) *
glm::translate(glm::mat4(1.0F), glm::vec3{-2.0F, 0.0F, 0.0F}) *
glm::rotate(glm::mat4(1.0F), t, glm::vec3{0.0F, 1.0F, 0.0F});
cb->unmap();
}
auto mvp =
glm::perspective(glm::radians(70.0F), float(sz.x) / float(sz.y), 0.1F, 1000.0F) *
glm::lookAt(glm::vec3{0.0F, 0.0F, -5.0F}, glm::vec3{0.0F, 0.0F, 0.0F}, glm::vec3{0.0F, 1.0F, 0.0F}) *
glm::translate(glm::mat4(1.0F), glm::vec3{-2.0F, 0.0F, 0.0F}) *
glm::rotate(glm::mat4(1.0F), t, glm::vec3{0.0F, 1.0F, 0.0F});
cb->fill(&mvp, sizeof(mvp));

renderDevice.setRasterState(nullptr);
renderDevice.drawTrianglesIndexed(0, 6);

{
auto& mvp = *(glm::mat4*)cb->map();
mvp = glm::perspective(glm::radians(70.0F), float(sz.x) / float(sz.y), 0.1F, 1000.0F) *
glm::lookAt(glm::vec3{0.0F, 0.0F, -5.0F}, glm::vec3{0.0F, 0.0F, 0.0F},
glm::vec3{0.0F, 1.0F, 0.0F}) *
glm::translate(glm::mat4(1.0F), glm::vec3{2.0F, 0.0F, 0.0F}) *
glm::rotate(glm::mat4(1.0F), t, glm::vec3{0.0F, 1.0F, 0.0F});
cb->unmap();
}
mvp = glm::perspective(glm::radians(70.0F), float(sz.x) / float(sz.y), 0.1F, 1000.0F) *
glm::lookAt(glm::vec3{0.0F, 0.0F, -5.0F}, glm::vec3{0.0F, 0.0F, 0.0F}, glm::vec3{0.0F, 1.0F, 0.0F}) *
glm::translate(glm::mat4(1.0F), glm::vec3{2.0F, 0.0F, 0.0F}) *
glm::rotate(glm::mat4(1.0F), t, glm::vec3{0.0F, 1.0F, 0.0F});
cb->fill(&mvp, sizeof(mvp));

renderDevice.setRasterState(rs);
renderDevice.drawTrianglesIndexed(0, 6);
Expand Down
15 changes: 15 additions & 0 deletions core/src/ecs/cubos.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include <utility>

#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif

#include <cubos/core/ecs/command_buffer.hpp>
#include <cubos/core/ecs/cubos.hpp>
#include <cubos/core/ecs/name.hpp>
Expand Down Expand Up @@ -289,9 +293,20 @@ bool Cubos::update()
void Cubos::run()
{
this->start();
#ifndef __EMSCRIPTEN__
while (this->update())
{
}
#else
emscripten_set_main_loop_arg(
[](void* cubos) {
if (static_cast<Cubos*>(cubos)->update() == 0)
{
emscripten_cancel_main_loop();
}
},
this, 0, 1);
#endif
}

bool Cubos::isRegistered(const reflection::Type& type) const
Expand Down

0 comments on commit 1354f0b

Please sign in to comment.