Announcement

Collapse

Welcome to the all new QuakeOne.com!!

Welcome to the all new QuakeOne.com! The web site has been moved to a brand new web host, and the site software (vBulletin) has been upgraded to the most recent version. All previous data, including users and posts, has been converted over to the new version of the site.

We are still in the process of updating the site look and feel. We hope to have this updated shortly. In the meantime we have simply launched the site with the default software templates so as to not keep the site down any longer.

Until we get the site back up and running as it was before, please use http://servers.quakeone.com to find game server stats.

If you find any issues with anything on QuakeOne.com, please let us know in the Site Feedback Forum.

Thanks for your patience!

-Solecord
See more
See less

Trying to understand darkplaces source code

Collapse
X
  • 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:

    Code:
    DP_CDDA?=enabled
    DP_VIDEO_CAPTURE?=enabled
    
    
    DP_LINK_ZLIB?=dlopen
    DP_LINK_JPEG?=shared
    DP_LINK_ODE?=dlopen
    DP_LINK_CRYPTO?=dlopen
    DP_LINK_CRYPTO_RIJNDAEL?=dlopen
    
    
    # athlon optimizations
    #CPUOPTIMIZATIONS?=-march=athlon
    # athlon xp optimizations
    #CPUOPTIMIZATIONS?=-march=athlon-xp
    # athlon 64 optimizations
    #CPUOPTIMIZATIONS?=-march=athlon64 -m32
    # Pentium 3 optimizations
    #CPUOPTIMIZATIONS?=-march=pentium3
    # Pentium 4 optimizations
    #CPUOPTIMIZATIONS?=-march=pentium4
    # 686 (Pentium Pro/II) optimizations
    #CPUOPTIMIZATIONS?=-march=i686
    # No specific CPU (386 compatible)
    #CPUOPTIMIZATIONS?=
    # 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

    Comment


    • #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.

      Code:
      # NULL: no sound
      ifeq ($(DP_SOUND_API), NULL)
      	OBJ_SOUND=snd_null.o
      	LIB_SOUND=
      endif
      
      # WIN: DirectX and Win32 WAVE output
      ifeq ($(DP_SOUND_API), WIN)
      	OBJ_SOUND=$(OBJ_SND_WIN)
      	LIB_SOUND=$(LIB_SND_WIN)
      endif
      I guess I'll remove the NULL one.

      Comment


      • #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.

        Code:
        # 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
        #       CPUOPTIMIZATIONS+=-DUSE_WSPIAPI_H -DSUPPORTIPV6
        	LDFLAGS_WINCOMMON=-Wl,--large-address-aware
        else
        	LDFLAGS_WINCOMMON=
        endif
        
        ifeq ($(WIN64RELEASE), 1)
        #	TARGET=x86_64-pc-mingw32
        #	CC=$(TARGET)-g++
        #	WINDRES=$(TARGET)-windres
        endif

        Comment


        • #64
          OBJ_ICON=darkplaces.o

          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

          Code:
          darkplaces.o: %.o : %.rc
          	$(CHECKLEVEL2)
          	windres -o $@ $<
          Answer here https://stackoverflow.com/questions/...am-o-o-rc-mean

          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.

          Comment


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

            CC?=gcc

            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
            make

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

            Comment


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

              search engines, i guess

              Comment


              • #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:

                Code:
                //{{NO_DEPENDENCIES}}
                // 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
                #endif
                #endif
                I guess only #define IDI_ICON1 101 is needed.

                resource.h is used from two files:

                vid_wgl.c

                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.

                Comment


                • #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.

                  Comment


                  • #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.

                    Comment


                    • #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....

                      SomeClass.myStaticFunc();

                      Where dot represents however your language handles accessing class methods.

                      SomeClass::
                      SomeClass->
                      etc...

                      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.

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

                      Comment


                      • #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.

                        Comment


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

                          Comment


                          • #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.
                            X_Michael

                            Comment


                            • #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 https://stackoverflow.com/questions/...es-static-mean

                              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.

                              Comment


                              • #75
                                @gypsy:
                                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

                                Comment

                                Working...
                                X