No announcement yet.

Trying to understand darkplaces source code

  • Filter
  • Time
  • Show
Clear All
new posts

  • #61
    Planned to discard makefile completely and move to codeblocks project, but it provides options on what features to include. Codeblocks can't do that by himself.

    It's possible to use codeblocks with makefiles though.

    Can't wait to use a real debugger, instead of inserting printf everywhere. Learning codeblocks just for that.

    By options I mean things like those:

    # athlon optimizations
    # athlon xp optimizations
    # athlon 64 optimizations
    #CPUOPTIMIZATIONS?=-march=athlon64 -m32
    # Pentium 3 optimizations
    # Pentium 4 optimizations
    # 686 (Pentium Pro/II) optimizations
    # No specific CPU (386 compatible)
    # Experimental
    #CPUOPTIMIZATIONS?=-fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fassociative-math -freciprocal-math -fno-signed-zeros -fno-trapping-math
    # Normal
    CPUOPTIMIZATIONS?=-fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math
    # NOTE: *never* *ever* use the -ffast-math or -funsafe-math-optimizations flag


    • #62
      It's also possible to remove sound support too, with DP_SOUND_API=NULL. Not sure why though, but maybe it's useful sometimes.

      # NULL: no sound
      ifeq ($(DP_SOUND_API), NULL)
      # WIN: DirectX and Win32 WAVE output
      ifeq ($(DP_SOUND_API), WIN)
      I guess I'll remove the NULL one.


      • #63
        This bit is for crossplatform compilation, I guess. For compiling 64 release from 32 or 32 from 64. I'll delete it too, but it may become useful later. I'll leave a copy here just in case.

        # Win32 configuration
        ifeq ($(WIN32RELEASE), 1)
        #	TARGET=i686-pc-mingw32
        #	CC=$(TARGET)-g++
        #	WINDRES=$(TARGET)-windres
        	CPUOPTIMIZATIONS=-march=pentium3 -mfpmath=sse -fno-math-errno -ffinite-math-only -fno-rounding-math -fno-signaling-nans -fno-trapping-math
        ifeq ($(WIN64RELEASE), 1)
        #	TARGET=x86_64-pc-mingw32
        #	CC=$(TARGET)-g++
        #	WINDRES=$(TARGET)-windres


        • #64

          strange they didn't chose icon.o instead. Probably because they had nexius icon in the same folder.

          Need to understand what's going in this bit before changing anything

          darkplaces.o: %.o : %.rc
          	windres -o [email protected] $<
          Answer here

          I guess it's just wildcard, needed because there are multiple exe and two different icons (for darkplaces and nexius). Doesn't matter now, can simplify.
          Last edited by vibok; 06-24-2017, 09:30 AM.


          • #65
            I wonder what's the point of those things


            WINDRES ?= windres

            They used only once anyway, why not use them directly.

            I guess it's for rewriting them by calling
            WINDRES=mysuperrarewindres make
            instead of

            It's a linux tradition I suppose. They have much more choice for everything.


            • #66
              Currently Active Users Viewing This Thread: 5 (1 members and 4 guests)

              search engines, i guess


              • #67
                the resource.h file is weird. It's generated by one of microsoft tools, so I suppose only one line of it is really needed.

                Look at it:

                // Microsoft Developer Studio generated include file.
                // Used by resource.rc
                #define IDI_ICON1                       101
                // Next default values for new objects
                #ifdef APSTUDIO_INVOKED
                #ifndef APSTUDIO_READONLY_SYMBOLS
                #define _APS_NEXT_RESOURCE_VALUE        102
                #define _APS_NEXT_COMMAND_VALUE         40001
                #define _APS_NEXT_CONTROL_VALUE         1000
                #define _APS_NEXT_SYMED_VALUE           101
                I guess only #define IDI_ICON1 101 is needed.

                resource.h is used from two files:


                hIcon = LoadIcon (global_hInstance, MAKEINTRESOURCE (IDI_ICON1));

                and sys_win.c

                (no real use, at least i can't find it.)

                No idea how to generate resource.h out of darkplaces.rc. Probably would be necessary ever though, it's not the most important part of this all.


                • #68
                  I don't see the "static" keyword being used anywhere. There are a lot of functions in the conproc.c, but only two in conproc.h. I guess all those unmentioned in .h are private functions?

                  Maybe static keyword didn't even existed when quake was made.

                  Wonder if there is much point in making functions static anyway. If there is, + one thing to do.


                  • #69
                    huh, darkplaces.ico actually contains 10 different images. Always thought ico can contain only one. I now wonder how to make an ico like that.


                    • #70
                      Making a function static means it will basically be a Singleton so, multiple instances of the function will not exist no matter how many instances of the class do. Also, no instance of the class needs to exist to use the function.

                      You simply....


                      Where dot represents however your language handles accessing class methods.


                      You generally cannot refer to non-static members in a static method unless passed to the method in the interface, nor can you usually refer to "this", either....unless, I guess, if the class was marked as static but, still probably not.

                      Most classes I write are almost entirely made up of private static functions. Exceptions are classes that need to hold variables that will be different from one instance to the next and more than one instance of the class may exist at any given time. Even then there are generally parts of the class that can be made static.

                      An example of fully static would be my bsp parser. The parse method returns an object of results. Nowhere in the class are those results stored or referenced so, the parser can be fully static. This also means I do not need to ever instantiate the bsp parser class.

                      var bspobjectbject = BSP.parse(data);
                      Last edited by MadGypsy; 06-24-2017, 12:17 PM.


                      • #71
                        static function in C pretty much means "private function". It wouldn't be visible from outside, you can use it only from the same object file.

                        quake simply doesn't add them in the header file, so it probably have the same effect. I should google the difference later.


                        • #72
                          Weird. Static is not at all "basically private" so if what you say is true that's pretty dumb.


                          • #73
                            @in C....

                            Are you programming in actual C? Cause, in c++ static does everything and works as I just said.

                            Same for Java, HaXe, PHP, JavaScript, As3 and probably thousands of other languages.


                            • #74
                              Darkplaces is written in C, so I'm learning it. I probably should learn a more modern engine instead.

                              Here is a link about c static functions and variables

                              C++ and others remade them somewhat, static in C++ is completely different from static in C. In C++ static method is a method attached to class instead of object, or something like that.


                              • #75
                                static in c and c++:

                                as a global, prevents that global from being visible to other compilation units (read: .o), basically just allocates storage without naming it.

                                as a local, promotes to .bss or .data instead of stack (see above), also prevents that variable from being visible from other functions (local scope wouldn't mean much otherwise).

                                as a c++ class member, forces that member into an individual .bss or .data symbol instead of part of the class's normal allocation (which could be .bss, .data, stack, or dynamically allocated, etc). doesn't bother to affect visibility, because THIS IS C++! Doesn't bother to actually allocate storage for the member/symbol, requiring some 'int foo::faz;' definition outside of the class in question, thereby ensuring that there's only one allocation despite the X different compilation units that the linker will see that might poke it, because C++ conceptually uses an unmodified C linker (ignoring the whole constructors on global classes thing, which is technically a libc hack and doesn't normally require the linker to change at all, assuming it already supported arbitrary named segments).

                                as a class, doesn't work. trying to define some 'static class foo {} foobar;' would define just foobar as static rather than the class type. omit the foobar and its a syntax error. if you want that anyway, define it as a namespace, or define all the members as static and then don't instantiate the class.
                                Some Game Thing