From 493a609bb23addc263bb6dd7f48a3b429aa833eb Mon Sep 17 00:00:00 2001 From: Tristan Date: Sun, 23 Feb 2025 22:35:21 -0600 Subject: [PATCH] Updating current work done in course --- renderer | Bin 16600 -> 16992 bytes src/main.c | 40 +++++++-- ycm_extra_conf.py | 220 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 254 insertions(+), 6 deletions(-) create mode 100644 ycm_extra_conf.py diff --git a/renderer b/renderer index 2f6af01ebc8f53c77ac4426dfd892357357f4791..ce4d274b9e0888c075904503c0d61e2442d1283e 100755 GIT binary patch literal 16992 zcmeHOeQ+GbmG519L15XEz)p-f@P?R#09s47>@&VnSXo+ooU%a}ISF@x$!d2jEm`e~ z-PzdU2r(s~P}WW#YDKyY-Z5K>xzPN~qM3DA_ejOXnGhP}OO8 zvWrlb`5=8>3zZToa<9B786!pYuSfTC`-J-KC^qpPqaPnwP9+|l+FM4%-FX6P1$r$Hj^tI?m4`DThF%sSTP^ltmRa% zDE?{K?7r>*b;mqm(w*TWh8KS%Tg!6N|F?8)aEmi@)AYT6`%l}CZoTuZw`I4H4%M4% zNQV;nlP(wjLS#rs$0KwXb^K+7k$+0hI6t1e^@E?jiQ=5 zsV4YWo8X^mf=@TWk2S&TP4Hb!@TZ#K8xgQZ?d@uUFE#Nq)&!@1i{d|+;JzV#brbxO zCiSU8|FWQS@a)-fQp4Wn4v>p@Nfio&8RZ+!Qo)qvINWxR5+Fl+Wf3 zJnR(RLVkLg>PSADO}yX98DB;;QgDib+)(0T*!W$UTsnV9mtvHMvQE;tHx*$8+fE%$ z+6ObaWHxiVqb8HtY(9n7V_v7Y^^?g=P8}>bjw-sSdqEvMRLHn!H_21)vr`lAvkxXS zSp^$3baT(aUqEb!TwL3o8daCArT?e=qQ$xA;CH_=AkM z#kH9dT=-Mh8l0{%bZwEe;KRj+WECIYAN%#41eiYE6IUlaCw`_2~52rdwdeDdSqlgxL(TATe z%AgPX@KrwiF(2OU!{>cC28NfO^5JVdRH>6bywUZ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MQ^iy&N6)zYMttBY{8dD|XM$1pU};whiO9Gf_h|^!iP0*0LIEF^zrG&1(`D zyWV)wyxlN>Zydd4QfqmUW1+bD-9p+zL*+$MI~^$ZNu6{Nw4YS3&)F&NF7aNm^Nb$x zPIV;3{bpWscIxuZmxt5o3-45UXF6T-u0WUtz9#xxtw^_qcow>&;@!%)c-2K(<^dt& zzD=aatAw1W*Nh1XM)4S~LhAm<7BmqM;D807b1hCGPFLWaHB zKS5HJONqiue|n|YC|c!mza^riKENAjQ`pG19n4%pGt*w~ zC7sp#3%sYeVkvj90#+R|Y|Mw#k6QVRn4ehs0fEUS-B+RAvs`mCh0VN_><-8s@_*-R z3YR07CnZ+}g=f3mL1^vJMugU=hp~Dpp5<~sEwrg?u$;ERw?{+{r9@uOwU{g3@8NN% z!heNk1w6DeFrU5(ROdd~@MzQHFSWHbzOsB(jCHg(M`O$B{_1x6x_ZZ+bu|ZNd5c8# zbG(jD{^+Bb=%=1JKF3b}8G&YE2_2o|vkeO=Hv5e^e$_6HfSqcB0jGH`OvG_{Gx&zI zm84pqEg?QD5_Y=3*6$b=tch{zsr8M2_L^&RRi +#include #include #include -bool is_running= false; +bool is_running = false; SDL_Window* window = NULL; SDL_Renderer* renderer = NULL; - +// Also known as frame buffer in other books, pointer to an array of color_buffer +uint32_t* color_buffer = NULL; +int window_width = 800; +int window_height = 600; bool initialize_window(void) { if (SDL_Init(SDL_INIT_EVERYTHING) != 0) { - fprintf(stderr, "Error initializing SDL.\n"); + fprintf(stderr, "Error initializing SDL.\n"); return false; } @@ -18,8 +22,8 @@ bool initialize_window(void) { NULL, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - 800, - 600, + window_width, + window_height, SDL_WINDOW_BORDERLESS ); if (!window) { @@ -38,7 +42,9 @@ bool initialize_window(void) { } void setup(void){ - //TODO + + // Allocates the memory required for color_buffer, using sizeof to allocate the # of bytes required + color_buffer = (uint32_t*) malloc(sizeof(uint32_t) * window_width * window_height); } void process_input(void){ @@ -58,13 +64,32 @@ void process_input(void){ void update(void){ //TODO } + +void clear_color_buffer(uint32_t color){ + for (int y = 0; y < window_height; y++){ + for (int x = 0; x < window_width; x++){ + color_buffer[(window_width * y) + x] = color; + } + } +} + void render(void){ SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); SDL_RenderClear(renderer); + + clear_color_buffer(0xFFFFFF00); SDL_RenderPresent(renderer); } +void destroy_window(void){ + free(color_buffer); + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + SDL_Quit(); +} + + int main(void) { is_running = initialize_window(); @@ -77,5 +102,8 @@ int main(void) { render(); } + destroy_window(); + + return 0; } diff --git a/ycm_extra_conf.py b/ycm_extra_conf.py new file mode 100644 index 0000000..d970148 --- /dev/null +++ b/ycm_extra_conf.py @@ -0,0 +1,220 @@ +# This file is NOT licensed under the GPLv3, which is the license for the rest +# of YouCompleteMe. +# +# Here's the license text for this file: +# +# This is free and unencumbered software released into the public domain. +# +# Anyone is free to copy, modify, publish, use, compile, sell, or +# distribute this software, either in source code form or as a compiled +# binary, for any purpose, commercial or non-commercial, and by any +# means. +# +# In jurisdictions that recognize copyright laws, the author or authors +# of this software dedicate any and all copyright interest in the +# software to the public domain. We make this dedication for the benefit +# of the public at large and to the detriment of our heirs and +# successors. We intend this dedication to be an overt act of +# relinquishment in perpetuity of all present and future rights to this +# software under copyright law. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +# For more information, please refer to + +from sysconfig import get_path +import platform +import os.path as p +import subprocess + +DIR_OF_THIS_SCRIPT = p.abspath( p.dirname( __file__ ) ) +DIR_OF_THIRD_PARTY = p.join( DIR_OF_THIS_SCRIPT, 'third_party' ) +DIR_OF_WATCHDOG_DEPS = p.join( DIR_OF_THIRD_PARTY, 'watchdog_deps' ) +SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ] + +database = None + +# These are the compilation flags that will be used in case there's no +# compilation database set (by default, one is not set). +# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR. +flags = [ +'-Wall', +'-Wextra', +'-Werror', +'-Wno-long-long', +'-Wno-variadic-macros', +'-fexceptions', +'-DNDEBUG', +# You 100% do NOT need -DUSE_CLANG_COMPLETER and/or -DYCM_EXPORT in your flags; +# only the YCM source code needs it. +'-DUSE_CLANG_COMPLETER', +'-DYCM_EXPORT=', +'-DYCM_ABSEIL_SUPPORTED', +# THIS IS IMPORTANT! Without the '-x' flag, Clang won't know which language to +# use when compiling headers. So it will guess. Badly. So C++ headers will be +# compiled as C headers. You don't want that so ALWAYS specify the '-x' flag. +# For a C project, you would set this to 'c' instead of 'c++'. +'-x', +'c++', +'-isystem', +'cpp/absl', +'-isystem', +'cpp/pybind11', +'-isystem', +'cpp/whereami', +'-isystem', +'cpp/BoostParts', +'-isystem', +get_path( 'include' ), +'-isystem', +'cpp/llvm/include', +'-isystem', +'cpp/llvm/tools/clang/include', +'-I', +'cpp/ycm', +'-I', +'cpp/ycm/ClangCompleter', +'-isystem', +'cpp/ycm/tests/gmock/googlemock/include', +'-isystem', +'cpp/ycm/tests/gmock/googletest/include', +'-isystem', +'cpp/ycm/benchmarks/benchmark/include', +'-std=c++17', +] + +# Set this to the absolute path to the folder (NOT the file!) containing the +# compile_commands.json file to use that instead of 'flags'. See here for +# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html +# +# You can get CMake to generate this file for you by adding: +# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 ) +# to your CMakeLists.txt file. +# +# Most projects will NOT need to set this to anything; you can just change the +# 'flags' list of compilation flags. Notice that YCM itself uses that approach. +compilation_database_folder = '' + + +def IsHeaderFile( filename ): + extension = p.splitext( filename )[ 1 ] + return extension in [ '.h', '.hxx', '.hpp', '.hh' ] + + +def FindCorrespondingSourceFile( filename ): + if IsHeaderFile( filename ): + basename = p.splitext( filename )[ 0 ] + for extension in SOURCE_EXTENSIONS: + replacement_file = basename + extension + if p.exists( replacement_file ): + return replacement_file + return filename + + +def PathToPythonUsedDuringBuild(): + try: + filepath = p.join( DIR_OF_THIS_SCRIPT, 'PYTHON_USED_DURING_BUILDING' ) + with open( filepath ) as f: + return f.read().strip() + except OSError: + return None + + +def Settings( **kwargs ): + # Do NOT import ycm_core at module scope. + import ycm_core + + global database + if database is None and p.exists( compilation_database_folder ): + database = ycm_core.CompilationDatabase( compilation_database_folder ) + + language = kwargs[ 'language' ] + + if language == 'cfamily': + # If the file is a header, try to find the corresponding source file and + # retrieve its flags from the compilation database if using one. This is + # necessary since compilation databases don't have entries for header files. + # In addition, use this source file as the translation unit. This makes it + # possible to jump from a declaration in the header file to its definition + # in the corresponding source file. + filename = FindCorrespondingSourceFile( kwargs[ 'filename' ] ) + + if not database: + return { + 'flags': flags, + 'include_paths_relative_to_dir': DIR_OF_THIS_SCRIPT, + 'override_filename': filename + } + + compilation_info = database.GetCompilationInfoForFile( filename ) + if not compilation_info.compiler_flags_: + return {} + + # Bear in mind that compilation_info.compiler_flags_ does NOT return a + # python list, but a "list-like" StringVec object. + final_flags = list( compilation_info.compiler_flags_ ) + + # NOTE: This is just for YouCompleteMe; it's highly likely that your project + # does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR + # ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT. + try: + final_flags.remove( '-stdlib=libc++' ) + except ValueError: + pass + + return { + 'flags': final_flags, + 'include_paths_relative_to_dir': compilation_info.compiler_working_dir_, + 'override_filename': filename + } + + if language == 'python': + return { + 'interpreter_path': PathToPythonUsedDuringBuild(), + 'ls': { + 'python': { + 'analysis': { + 'extraPaths': [ + p.join( DIR_OF_THIS_SCRIPT ), + p.join( DIR_OF_THIRD_PARTY, 'bottle' ), + p.join( DIR_OF_THIRD_PARTY, 'regex-build' ), + p.join( DIR_OF_THIRD_PARTY, 'frozendict' ), + p.join( DIR_OF_THIRD_PARTY, 'jedi_deps', 'jedi' ), + p.join( DIR_OF_THIRD_PARTY, 'jedi_deps', 'parso' ), + p.join( DIR_OF_WATCHDOG_DEPS, 'watchdog', 'build', 'lib3' ), + p.join( DIR_OF_WATCHDOG_DEPS, 'pathtools' ), + p.join( DIR_OF_THIRD_PARTY, 'waitress' ) + ], + 'useLibraryCodeForTypes': True + } + } + } + } + + return {} + + +def PythonSysPath( **kwargs ): + sys_path = kwargs[ 'sys_path' ] + + sys_path[ 0:0 ] = [ p.join( DIR_OF_THIS_SCRIPT ), + p.join( DIR_OF_THIRD_PARTY, 'bottle' ), + p.join( DIR_OF_THIRD_PARTY, 'regex-build' ), + p.join( DIR_OF_THIRD_PARTY, 'frozendict' ), + p.join( DIR_OF_THIRD_PARTY, 'jedi_deps', 'jedi' ), + p.join( DIR_OF_THIRD_PARTY, 'jedi_deps', 'parso' ), + p.join( DIR_OF_WATCHDOG_DEPS, + 'watchdog', + 'build', + 'lib3' ), + p.join( DIR_OF_WATCHDOG_DEPS, 'pathtools' ), + p.join( DIR_OF_THIRD_PARTY, 'waitress' ) ] + + sys_path.append( p.join( DIR_OF_THIRD_PARTY, 'jedi_deps', 'numpydoc' ) ) + return sys_path