diff options
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | include/Physics/Physics.hpp | 8 | ||||
-rw-r--r-- | project.conf | 6 | ||||
-rw-r--r-- | src/Physics/Physics.cpp | 40 | ||||
-rw-r--r-- | src/RenderBackend/OpenGL/Texture2D.cpp | 1 |
5 files changed, 61 insertions, 5 deletions
@@ -1,9 +1,10 @@ ## Prerequisite -glfw3 -glew -glm -sibs (https://github.com/DEC05EBA/sibs) +`glfw3`, `glew`, `glm`, [sibs](https://github.com/DEC05EBA/sibs) and a C++14 compiler. # TODO * Make use shader a no-op if already in use. -* Render vertices using glDrawElements instead of glDrawArrays.
\ No newline at end of file +* Render vertices using glDrawElements instead of glDrawArrays. +* Use opencl with bullet instead of using cpu. +* Remove obj loader and create an external program that uses assimp to convert different models to an amalgine specific binary file format. +This will allow amalgine to easily load models and animations with minimal code, no matter what the original format is. +This will make amalgine simpler, more efficient and use less memory.
\ No newline at end of file diff --git a/include/Physics/Physics.hpp b/include/Physics/Physics.hpp new file mode 100644 index 0000000..9aec701 --- /dev/null +++ b/include/Physics/Physics.hpp @@ -0,0 +1,8 @@ +#pragma once + +namespace amalgine { + class Physics { + public: + Physics(); + }; +}
\ No newline at end of file diff --git a/project.conf b/project.conf index 12fea06..150bfa7 100644 --- a/project.conf +++ b/project.conf @@ -4,8 +4,14 @@ type = "executable" version = "0.1.0" platforms = ["linux32", "linux64", "win64"] +[lang.cpp] +version = "c++14" + [dependencies] glfw3 = "3.2.1" glew = "2.1.0" glm = "0.9.8" +# TODO: Remove this and use a simple jpg and png loader soil = "1.16.0" +# TODO: Add support for vcpkg in sibs and use that instead +bullet = "2"
\ No newline at end of file diff --git a/src/Physics/Physics.cpp b/src/Physics/Physics.cpp new file mode 100644 index 0000000..fb00d1d --- /dev/null +++ b/src/Physics/Physics.cpp @@ -0,0 +1,40 @@ +#include "../../include/Physics/Physics.hpp" + +#include <btBulletDynamicsCommon.h> + +// TODO: Figure out how to process physics in another thread. Should it be done simply by +// calling stepSimulation in another thread? + +static void physics_update_callback(btDynamicsWorld *dynamics_world, btScalar time_step) { + btDispatcher *dispatcher = dynamics_world->getDispatcher(); + int num_manifolds = dispatcher->getNumManifolds(); + for(int i = 0; i < num_manifolds; ++i) { + btPersistentManifold *contact_manifold = dispatcher->getManifoldByIndexInternal(i); + { + // The bodies that collided + const btCollisionObject *obj_this = contact_manifold->getBody0(); + const btCollisionObject *obj_other = contact_manifold->getBody1(); + } + int num_contacts = contact_manifold->getNumContacts(); + for(int j = 0; j < num_contacts; ++j) { + btManifoldPoint &pt = contact_manifold->getContactPoint(j); + const btVector3 &pt_this = pt.getPositionWorldOnA(); + const btVector3 &pt_other = pt.getPositionWorldOnB(); + const btVector3 &normal_on_other = pt.m_normalWorldOnB; + } + } +} + +namespace amalgine { + Physics::Physics() { + btDefaultCollisionConfiguration *collision_configuration = new btDefaultCollisionConfiguration(); + btCollisionDispatcher *dispatcher = new btCollisionDispatcher(collision_configuration); + btBroadphaseInterface *overlapping_pair_cache = new btDbvtBroadphase(); + btSequentialImpulseConstraintSolver *solver = new btSequentialImpulseConstraintSolver(); + btDiscreteDynamicsWorld *dynamics_world = new btDiscreteDynamicsWorld(dispatcher, overlapping_pair_cache, solver, collision_configuration); + const float gravity = -10.0f; + dynamics_world->setGravity(btVector3(0.0f, gravity, 0.0f)); + dynamics_world->setInternalTickCallback(physics_update_callback); + //dynamics_world->debugDrawWorld(); + } +}
\ No newline at end of file diff --git a/src/RenderBackend/OpenGL/Texture2D.cpp b/src/RenderBackend/OpenGL/Texture2D.cpp index 089a5f1..fa84353 100644 --- a/src/RenderBackend/OpenGL/Texture2D.cpp +++ b/src/RenderBackend/OpenGL/Texture2D.cpp @@ -67,6 +67,7 @@ namespace amalgine { glBindTexture(GL_TEXTURE_2D, texture_ref); //output_gl_error("bind texture"); + // TODO: Take into account GL_ARB_texture_non_power_of_two and resize the image to power of two glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image->getWidth(), image->getHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, image->getData()); //output_gl_error("set texture"); |