GithubHelp home page GithubHelp logo

quake2generic's Introduction

quake2generic

The purpose of Quake 2 generic is to make porting Quake 2 easier. Now it is possible with just a few functions to port Quake 2 in a single file.

To try it, you will need a baseq2 directory (game data). If you don't own the game, shareware version is freely available.

Original game loads both game and renderer library dynamically to support different mods and rendering engines. This port embeds these libraries to make porting easier. Because many toy operating systems don't support dynamically loadable libraries (for example: .dll, .so, .dylib).

porting

Implement these functions to suit your platform as well as renderer frame functions.

  • QG_Milliseconds
  • QG_GetMouseDiff
  • QG_CaptureMouse
  • QG_ReleaseMouse
  • QG_Mkdir
Functions Description
QG_Milliseconds Measure ticks in milliseconds.
QG_GetMouseDiff If you support mouse, return x and y mouse difference from previous frame.
QG_CaptureMouse If you support mouse, this is used for capturing mouse so that cursor cannot go outside the window.
QG_ReleaseMouse If you support mouse, this is used for releasing mouse when going to menu.
QG_Mkdir Save game depends on this. If you don't implement this, the game still runs.

renderer - software or gl

Choose a renderer. Software renderer does not have any dependencies and runs everywhere. It is in ref_soft folder. If your porting target has OpenGL, you can use gl renderer in ref_gl folder.

software renderer

Implement functions beginning with name SWimp_ (look at port_soft_sdl.c for SDL port). software renderer

gl renderer

Implement functions beginning with name GLimp_ (look at port_gl_sdl.c for SDL port). gl renderer

main loop

At start, call Quake2_Init().

In a loop, call Quake2_Frame().

Send key events with Quake2_SendKey().

In simplest form:

int main(int argc, char **argv)
{
    int time, oldtime, newtime;
    Quake2_Init(argc, argv);
    oldtime = Quake2_Milliseconds ();
    while (1)
    {
      HandleInput();
      
      do {
        newtime = Quake2_Milliseconds ();
        time = newtime - oldtime;
      } while (time < 1);
      Quake2_Frame(time);
      oldtime = newtime;
    }
    return 0;
}

sound

Null sound is used in Makefile. You can use sound/snd_sdl.c instead of sound/snddma_null.c for SDL port.

net

Networking works in both unix environment and Windows. There are implementations in net folder. For systems lacking network support, you can compile net/net_loopback.c.

platforms

Ported platforms include Windows GDI, SDL (both software and gl),. Just look at (port_soft_gdi.c, port_soft_sdl.c, port_gl_sdl.c). Provided Makefile works for unix (MacOS and Linux tested). Visual Studio solution is also provided.

quake2generic's People

Contributors

ozkl avatar

Stargazers

hellisabove avatar sandwich avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.