Skip to content

Commit

Permalink
change type of seconds and clean up opengl includes (#887)
Browse files Browse the repository at this point in the history
* change type of `seconds`

* fixes to pc pad input (visual only)

* strip down openGL to the version we're actually using for now (4.3 no extensions)

* turn on this opengl message

* really minor inconsequential change
  • Loading branch information
ManDude authored Oct 6, 2021
1 parent 7463485 commit 4665b5a
Show file tree
Hide file tree
Showing 42 changed files with 136 additions and 20,882 deletions.
4 changes: 2 additions & 2 deletions common/type_system/TypeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ void TypeSystem::add_builtin_types() {
->set_runtime_type("float");
add_builtin_value_type("float", "degrees", 4, false, false, RegClass::FLOAT)
->set_runtime_type("float");
add_builtin_value_type("uint64", "seconds", 8, false, false)->set_runtime_type("uint64");
add_builtin_value_type("int64", "seconds", 8, false, true)->set_runtime_type("int64");

auto int_type = add_builtin_value_type("integer", "int", 8, false, true);
int_type->disallow_in_runtime();
Expand Down Expand Up @@ -1383,7 +1383,7 @@ bool TypeSystem::typecheck_base_types(const std::string& input_expected,
if (actual == "seconds") {
return true;
}
expected = "uint";
expected = "int";
}

if (expected == "degrees") {
Expand Down
2 changes: 1 addition & 1 deletion decompiler/util/DecompilerTypeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ bool DecompilerTypeSystem::should_attempt_cast_simplify(const TypeSpec& expected
return true;
}

if (expected == TypeSpec("seconds") && actual == TypeSpec("uint64")) {
if (expected == TypeSpec("seconds") && actual == TypeSpec("int64")) {
return true;
}

Expand Down
8 changes: 3 additions & 5 deletions game/graphics/opengl_renderer/DirectRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ DirectRenderer::DirectRenderer(const std::string& name, BucketId my_id, int batc
glGenBuffers(1, &m_ogl.vertex_buffer);
glGenBuffers(1, &m_ogl.color_buffer);
glGenBuffers(1, &m_ogl.st_buffer);
glGenVertexArrays(1, &m_ogl.vao);

glBindBuffer(GL_ARRAY_BUFFER, m_ogl.vertex_buffer);
m_ogl.vertex_buffer_bytes = batch_size * 3 * 3 * sizeof(u32);
Expand All @@ -29,6 +30,7 @@ DirectRenderer::~DirectRenderer() {
glDeleteBuffers(1, &m_ogl.color_buffer);
glDeleteBuffers(1, &m_ogl.vertex_buffer);
glDeleteBuffers(1, &m_ogl.st_buffer);
glDeleteVertexArrays(1, &m_ogl.vao);
}

/*!
Expand Down Expand Up @@ -137,9 +139,7 @@ void DirectRenderer::flush_pending(SharedRenderState* render_state) {
glDepthFunc(GL_ALWAYS);
}

GLuint vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glBindVertexArray(m_ogl.vao);

// render!
// update buffers:
Expand Down Expand Up @@ -212,8 +212,6 @@ void DirectRenderer::flush_pending(SharedRenderState* render_state) {
m_triangles += draw_count * (m_prim_buffer.vert_count / 3);
m_draw_calls += draw_count;
m_prim_buffer.vert_count = 0;

glDeleteVertexArrays(1, &vao);
}

void DirectRenderer::update_gl_prim(SharedRenderState* render_state) {
Expand Down
1 change: 1 addition & 0 deletions game/graphics/opengl_renderer/DirectRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class DirectRenderer : public BucketRenderer {

struct {
GLuint vertex_buffer, color_buffer, st_buffer;
GLuint vao;
u32 vertex_buffer_bytes = 0;
u32 color_buffer_bytes = 0;
u32 st_buffer_bytes = 0;
Expand Down
4 changes: 3 additions & 1 deletion game/graphics/opengl_renderer/OpenGLRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void GLAPIENTRY opengl_error_callback(GLenum source,
const GLchar* message,
const void* /*userParam*/) {
if (severity == GL_DEBUG_SEVERITY_NOTIFICATION) {
return;
lg::debug("OpenGL notification 0x{:X} S{:X} T{:X}: {}", id, source, type, message);
} else if (severity == GL_DEBUG_SEVERITY_LOW) {
lg::info("OpenGL message 0x{:X} S{:X} T{:X}: {}", id, source, type, message);
} else if (severity == GL_DEBUG_SEVERITY_MEDIUM) {
Expand All @@ -45,6 +45,8 @@ OpenGLRenderer::OpenGLRenderer(std::shared_ptr<TexturePool> texture_pool)
glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_PERFORMANCE, GL_DONT_CARE, 1,
&l_gl_error_ignores[0], GL_FALSE);

lg::debug("OpenGL context information: {}", (const char*)glGetString(GL_VERSION));

// initialize all renderers
init_bucket_renderers();
}
Expand Down
6 changes: 3 additions & 3 deletions game/graphics/pipelines/opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ static int gl_init(GfxSettings& settings) {
return 1;
}

// request an OpenGL 3.3 Core context
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // 3.3
// request an OpenGL 4.3 Core context
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); // 4.3
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // core profile, not compat
// debug check
Expand Down Expand Up @@ -175,7 +175,7 @@ static std::shared_ptr<GfxDisplay> gl_make_main_display(int width,
// NOTE: imgui's setup calls functions that may fail intentionally, and attempts to disable error
// reporting so these errors are invisible. But it does not work, and some weird X11 default
// cursor error is set here that we clear.
glfwGetError(nullptr);
glfwGetError(NULL);

// set up the renderer
ImGui_ImplOpenGL3_Init("#version 130");
Expand Down
2 changes: 1 addition & 1 deletion goal_src/engine/game/game-info.gc
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@
(defmethod reset! fact-info-target ((obj fact-info-target) (arg0 symbol))
"Reset the facts for a given thing"
(when (or (not arg0) (= arg0 'eco))
(set! (-> obj eco-timeout) (the-as uint 0))
(set! (-> obj eco-timeout) 0)
(set! (-> obj eco-level) 0.0)
(set! (-> obj eco-pickup-time) (-> *display* game-frame-counter))
)
Expand Down
15 changes: 8 additions & 7 deletions goal_src/pc_debug/pc-pad-utils.gc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defconstant PC_PAD_INPUT_NOTICE_TIME (seconds 1.5))
(defconstant PC_PAD_TOP_Y 40)



Expand Down Expand Up @@ -161,7 +162,7 @@
(defbehavior pc-pi-post pc-pad-proc ()
(with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string-xy (string-format "MAPPING PAD ~D" (-> self pad-idx)) buf 256 32
(draw-string-xy (string-format "MAPPING PAD ~D" (-> self pad-idx)) buf 256 PC_PAD_TOP_Y
(font-color red) (font-flags shadow kerning large middle))
)
)
Expand All @@ -184,7 +185,7 @@
(bucket-id debug-draw1))
(draw-string-xy (string-format "MAPPED ~D TO ~S!"
(pc-pad-input-key-get) (-> *pc-pad-button-names* (1- (-> self input-index))))
buf 256 96 (font-color green) (font-flags shadow kerning large middle))
buf 256 (+ PC_PAD_TOP_Y 64) (font-color green) (font-flags shadow kerning large middle))
)
(suspend)
)
Expand All @@ -207,7 +208,7 @@
(until (time-passed? PC_PAD_INPUT_NOTICE_TIME)
(with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string-xy "CANCELED!" buf 256 96 (font-color red-reverse) (font-flags shadow kerning large middle))
(draw-string-xy "CANCELED!" buf 256 (+ PC_PAD_TOP_Y 64) (font-color red-reverse) (font-flags shadow kerning large middle))
)
(suspend)
)
Expand All @@ -225,15 +226,15 @@
(bucket-id debug-draw1))
(draw-string-xy (string-format "MAPPED ~D TO ~S!"
(pc-pad-input-key-get) (-> *pc-pad-button-names* (1- (-> self input-index))))
buf 256 96 (font-color green) (font-flags shadow kerning large middle))
buf 256 (+ PC_PAD_TOP_Y 64) (font-color green) (font-flags shadow kerning large middle))
)
(suspend)
)
(set-state-time)
(until (time-passed? PC_PAD_INPUT_NOTICE_TIME)
(with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string-xy "KEY MAPPING COMPLETE!~%SETTINGS SAVED." buf 256 96 (font-color green) (font-flags shadow kerning large middle))
(draw-string-xy (string-format "KEY MAPPING COMPLETE!~%SETTINGS SAVED.") buf 256 (+ PC_PAD_TOP_Y 64) (font-color green) (font-flags shadow kerning large middle))
)
(suspend)
)
Expand All @@ -246,9 +247,9 @@
(loop
(with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(draw-string-xy "PRESS ESCAPE TO EXIT" buf 256 64 (font-color default) (font-flags shadow kerning large middle))
(draw-string-xy "PRESS ESCAPE TO EXIT" buf 256 (+ PC_PAD_TOP_Y 32) (font-color default) (font-flags shadow kerning large middle))
(draw-string-xy (string-format "PRESS KEY FOR ~S" (-> *pc-pad-button-names* (-> self input-index)))
buf 256 96 (font-color default) (font-flags shadow kerning large middle))
buf 256 (+ PC_PAD_TOP_Y 64) (font-color default) (font-flags shadow kerning large middle))
)
(suspend)
)
Expand Down
35 changes: 16 additions & 19 deletions test/decompiler/reference/engine/game/game-info_REF.gc
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@
;; INFO: Return type mismatch float vs none.
(defmethod reset! fact-info-target ((obj fact-info-target) (arg0 symbol))
(when (or (not arg0) (= arg0 'eco))
(set! (-> obj eco-timeout) (the-as seconds 0))
(set! (-> obj eco-timeout) 0)
(set! (-> obj eco-level) 0.0)
(set!
(-> obj eco-pickup-time)
Expand Down Expand Up @@ -776,7 +776,7 @@
)
(when (!= (-> obj eco-type) kind)
(set! (-> obj eco-level) 0.0)
(set! (-> obj eco-timeout) (the-as seconds 0))
(set! (-> obj eco-timeout) 0)
0
)
(set! (-> obj eco-type) (the-as int kind))
Expand All @@ -796,24 +796,21 @@
)
(set!
(-> obj eco-timeout)
(the-as
seconds
(min
(the-as
int
(+
(-> obj eco-timeout)
(* (the-as int (-> *FACT-bank* eco-single-timeout)) (the int amount))
)
(min
(the-as
int
(+
(-> obj eco-timeout)
(* (the-as int (-> *FACT-bank* eco-single-timeout)) (the int amount))
)
(the-as
int
(+
(-> *FACT-bank* eco-full-timeout)
(-
(-> *display* game-frame-counter)
(the-as int (-> obj eco-pickup-time))
)
)
(the-as
int
(+
(-> *FACT-bank* eco-full-timeout)
(-
(-> *display* game-frame-counter)
(the-as int (-> obj eco-pickup-time))
)
)
)
Expand Down
9 changes: 1 addition & 8 deletions test/decompiler/reference/engine/game/projectiles_REF.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1009,10 +1009,7 @@
)
:enter
(behavior ()
(set!
(-> self state-time)
(the-as seconds (-> *display* base-frame-counter))
)
(set! (-> self state-time) (-> *display* base-frame-counter))
(none)
)
:code
Expand Down Expand Up @@ -1947,7 +1944,3 @@
(none)
)
)




Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,7 @@
:virtual #t
:enter
(behavior ()
(set!
(-> self state-time)
(the-as seconds (-> *display* base-frame-counter))
)
(set! (-> self state-time) (-> *display* base-frame-counter))
(none)
)
:trans
Expand Down Expand Up @@ -1013,7 +1010,7 @@
;; definition for function process-taskable-hide-enter
;; INFO: Return type mismatch none vs int.
(defbehavior process-taskable-hide-enter process-taskable ()
(set! (-> self state-time) (the-as seconds (-> *display* base-frame-counter)))
(set! (-> self state-time) (-> *display* base-frame-counter))
(let ((v1-3 (-> self draw shadow-ctrl)))
(logior! (-> v1-3 settings flags) 32)
)
Expand Down Expand Up @@ -1319,10 +1316,7 @@
)
:enter
(behavior ()
(set!
(-> self state-time)
(the-as seconds (-> *display* base-frame-counter))
)
(set! (-> self state-time) (-> *display* base-frame-counter))
(process-taskable-clean-up-after-talking)
(none)
)
Expand Down
9 changes: 1 addition & 8 deletions test/decompiler/reference/levels/beach/lurkercrab_REF.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1049,10 +1049,7 @@ nav-enemy-default-event-handler
)
:code
(behavior ()
(set!
(-> self state-time)
(the-as seconds (-> *display* base-frame-counter))
)
(set! (-> self state-time) (-> *display* base-frame-counter))
(ja-channel-push! 1 22)
(let ((v1-4 (-> self skel root-channel 0)))
(set!
Expand Down Expand Up @@ -1268,7 +1265,3 @@ nav-enemy-default-event-handler
(go (method-of-object obj nav-enemy-idle))
(none)
)




25 changes: 5 additions & 20 deletions test/decompiler/reference/levels/citadel/citb-drop-plat-CIT_REF.gc
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@
(behavior ()
(suspend)
(dummy-47 (-> self root-override))
(set!
(-> self state-time)
(the-as seconds (-> *display* base-frame-counter))
)
(set! (-> self state-time) (-> *display* base-frame-counter))
(logior! (-> self mask) (process-mask actor-pause))
(while #t
(if
Expand Down Expand Up @@ -241,10 +238,7 @@
)
(logior! (-> self draw status) 2)
(ja-post)
(set!
(-> self state-time)
(the-as seconds (-> *display* base-frame-counter))
)
(set! (-> self state-time) (-> *display* base-frame-counter))
(while #t
(when
(>=
Expand Down Expand Up @@ -278,10 +272,7 @@
:code
(behavior ((arg0 draw-control))
(set! (-> self interp) 1.0)
(set!
(-> self state-time)
(the-as seconds (-> *display* base-frame-counter))
)
(set! (-> self state-time) (-> *display* base-frame-counter))
(set! (-> self spin-angle) 0.0)
(set!
(-> self root-override trans y)
Expand Down Expand Up @@ -375,10 +366,7 @@
(-> (the-as process-drawable (-> self parent 0)) root trans y)
(-> self root-override trans y)
)
(set!
(-> self state-time)
(the-as seconds (-> *display* base-frame-counter))
)
(set! (-> self state-time) (-> *display* base-frame-counter))
(sound-play-by-name
(static-sound-name "bridge-piece-dn")
(new-sound-id)
Expand Down Expand Up @@ -860,10 +848,7 @@
)
:code
(behavior ()
(set!
(-> self state-time)
(the-as seconds (-> *display* base-frame-counter))
)
(set! (-> self state-time) (-> *display* base-frame-counter))
(citb-drop-plat-spawn-children)
(while #t
(if
Expand Down
Loading

0 comments on commit 4665b5a

Please sign in to comment.