Added support for desktop full screen with pillarboxing and letterboxing
and started adding some comments to the code
This commit is contained in:
1 parent
ffaa6e5ae7
commit
e110b1f2fd
10 files changed
+351
-77
No files matched your search
+18
-10
@@ -41,9 +41,22 @@ ObjectStore *create_object_store() {
|
||||
return os;
|
||||
}
|
||||
|
||||
bool object_exists(ObjectStore *os, void *object) {
|
||||
// This is a crude implementation for checking that an object has already
|
||||
// been added.
|
||||
// TODO (Abdelrahman): Figure out if there is a better way of doing this
|
||||
for (size_t i = 0; i < MAX_OBJ_COUNT; ++i) {
|
||||
if (object == os->object_ptrs[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ObjectID add_object_to_store(ObjectStore *os, void *object, EventHandlerPtr eh,
|
||||
UpdateFuncPtr uf, RenderFuncPtr rf) {
|
||||
if (!os || !object ||
|
||||
if (!os || !object || object_exists(os, object) ||
|
||||
(os->count + 1 == MAX_OBJ_COUNT && os->deleted_count == 0)) {
|
||||
#ifdef DEBUG_ENGINE
|
||||
printf("Failed to add object\n");
|
||||
@@ -52,14 +65,6 @@ ObjectID add_object_to_store(ObjectStore *os, void *object, EventHandlerPtr eh,
|
||||
return INVALID_ID;
|
||||
}
|
||||
|
||||
// TODO (Abdelrahman): Need to figure out a way to check that the object
|
||||
// hasn't already been added to the store. If it has been added before, the
|
||||
// function should return -1 indicating an error to ensure that there aren't
|
||||
// two references to the same object without the user being aware that they
|
||||
// refer to the same thing. If the user intentionally copies the ID of one
|
||||
// object, then it would be their responsibility to make sure they don't
|
||||
// delete the object using one of the IDs, then try to use it with the other.
|
||||
|
||||
ObjectID id;
|
||||
|
||||
if (os->deleted_count > 0) {
|
||||
@@ -141,7 +146,10 @@ void destroy_object_store(ObjectStore **os) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < (*os)->count; ++i) {
|
||||
// TODO (Abdelrahman): Figure out if there is a better way to remove all of
|
||||
// the existing objects without having to loop for the maximum number of
|
||||
// objects allowed.
|
||||
for (size_t i = 0; i < MAX_OBJ_COUNT; ++i) {
|
||||
(*os)->object_ptrs[i] = NULL;
|
||||
(*os)->event_handlers[i] = NULL;
|
||||
(*os)->update_funcs[i] = NULL;
|
||||
|
||||
Reference in new issue
Block a user