Skip to content

Commit

Permalink
Implement GeometryLightingAllocate
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Aug 9, 2024
1 parent 0ee9b21 commit 5061425
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/brender/drivers/softrend/lighting.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,48 @@
#include "lighting.h"

C2_HOOK_VARIABLE_IMPLEMENT_INIT(const br_geometry_lighting_dispatch, geometryLightingDispatch, 0x0058bf40, {
NULL,
NULL,
NULL,
NULL,
_M_br_geometry_lighting_soft_free,
_M_br_object_soft_identifier,
_M_br_geometry_lighting_soft_type,
_M_br_geometry_lighting_soft_isType,
_M_br_object_soft_device,
_M_br_geometry_lighting_soft_space,
_M_br_geometry_lighting_soft_templateQuery,
_M_br_object_query,
_M_br_object_queryBuffer,
_M_br_object_queryMany,
_M_br_object_queryManySize,
_M_br_object_queryAll,
_M_br_object_queryAllSize,
_M_br_geometry_lighting_soft_render,
_M_br_geometry_lighting_soft_renderFixedToFloat,
});

br_geometry_lighting* (C2_HOOK_STDCALL * GeometryLightingAllocate_original)(br_soft_renderer_facility* type, const char* id);
br_geometry_lighting* C2_HOOK_STDCALL GeometryLightingAllocate(br_soft_renderer_facility* type, const char* id) {

#if defined(C2_HOOKS_ENABLED)
#if 0//defined(C2_HOOKS_ENABLED)
return GeometryLightingAllocate_original(type, id);
#else
#error "Not implemented"
br_geometry_lighting_soft* self;

C2_HOOK_BUG_ON(sizeof(br_geometry_lighting_soft) != 0x10);
self = BrResAllocate(type->device, sizeof(br_geometry_lighting_soft), BR_MEMORY_OBJECT_DATA);

if (self == NULL) {
return NULL;
}
self->dispatch = &C2V(geometryLightingDispatch);
self->identifier = id;
self->device = type->device;
self->renderer_facility = type;

type->dispatch->_addFront((br_object_container*)type, (br_object*)self);
return (br_geometry_lighting*)self;
#endif
}
C2_HOOK_FUNCTION_ORIGINAL(0x00540e30, GeometryLightingAllocate, GeometryLightingAllocate_original)
7 changes: 7 additions & 0 deletions src/brender/drivers/softrend/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,11 @@ typedef struct {
br_soft_renderer_facility* renderer_facility;
} br_geometry_v1_buckets_soft;

typedef struct {
const br_geometry_lighting_dispatch* dispatch;
const char* identifier;
br_soft_device* device;
br_soft_renderer_facility* renderer_facility;
} br_geometry_lighting_soft;

#endif /* SOFTREND_TYPES_H */

0 comments on commit 5061425

Please sign in to comment.