Commit graph

1760 commits

Author SHA1 Message Date
Yamagi Burmeister
3032698f95 Put console_history.txt in the binary dir when fs_portable is 1. 2017-03-13 15:41:41 +01:00
Yamagi Burmeister
00758277f1 Add a missing sanity check. attacker->classname may be NULL.
This was reported by maraakate in issue #170.
2017-03-13 14:17:51 +01:00
Yamagi Burmeister
692b64ad38 Add a cvar fs_portable. When set to 1 the game is 'portable'.
Normally Q2 writes all persistent data (the configurations, saves, etc.)
into a subdirectory in the users $HOME. That can be a problem when the
game is installed onto an thumb drive or something like that. Therefor
provide a cvar fs_portable. When set to 1 the games uses it binary dir
as it's persistent storage location.

Examples:

./quake2 +set fs_portable 1
./quake2 +set basedir ~/games/quake2 +set fs_portable 1

fs_portable is _not_ saved into the config file. It must be set at
every start!

This closed issue #158.
2017-03-13 14:12:33 +01:00
Yamagi Burmeister
4a54fdd0ed Ensure that '+set game baseq2' doesn't break the search pathes.
This is the first step to fix issue #158, consistent behavior for all
cases. This problem was also reported by @lonkamikaze through IRC.
2017-03-13 13:52:11 +01:00
Yamagi Burmeister
45cc75d2d9 Add an undocumented option for forcing busy waits.
Some people complained about the usage of non busy waits:

  * I was told that there's an input lag with nanosleep(). I still doubt
    that, but since the problem is easy to solve...
  * Some Intel CPUs throttle the GPU if the selected CPU pstate is too
    low. This is especially a problem on Haswell mobile CPUs. Keeping
    a core busy works around that.
2017-03-13 13:39:03 +01:00
Daniel Gibson
b6f68cd532 Allow setting png compression level in screenshot command
The level is between 0 and 10, use like
screenshot png 6
2017-03-13 00:50:57 +01:00
Daniel Gibson
bbf36746c8 stb_image_write.h: allow using custom zlib compress function
the one from zlib compresses better than the builtin one and might even
be faster.
2017-03-13 00:50:57 +01:00
Daniel Gibson
a1a634b95a stb_image_write.h: configurable png compress level 2017-03-12 22:33:59 +01:00
Daniel Gibson
9462063869 Screenshots can be tga, bmp, png, jpg now, using stb_image_write.h
the screenshot command now supports the filetype as optional argument
(just "screenshot" will use tga like before):
"screenshot png" will save the screenshot as PNG, same with jpg, png
and tga.
For jpg, you can even specify the quality, like "screenshot jpg 90"
(the Quality is between 1 and 100, like with libjpeg).

To reduce duplicated code, I addeed Vid_WriteScreenshot() to refimport_t
and implement most of it in the client (vid.c).
The renderer still fetches the raw image data from OpenGL or whatever
and then calls re.VidWriteScreenshot() which will write it to disk in
the format requested by the user.
2017-03-12 03:28:06 +01:00
Daniel Gibson
516c417d91 Render lightmaps together with corresponding faces; gl_overbrightbits
pass both normal texture and lightmap to shader instead of rendering the
level geometry again with the lightmap and GL_BLEND.

This is not done, some translucent surfaces are buggy now and it's only
static lightmaps. For this to work properly I'll need to add some more
shaders with and without lightmaps and use them accordingly.
For example, translucent surfaces (SURF_TRANS33/66) never have
lightmaps, neither to pertubed ones (SURF_DRAWTURB) like water and lava,
but scrolling surfaces (SURF_FLOWING) like elevators do use lightmaps
(as long as they're not also transulcent or perturbed)...
2017-03-12 03:11:29 +01:00
Daniel Gibson
13789554ba GL3: Dynamic Lightmaps (via blending)
well, seems to work, but once the lightmaps are rendered with the normal
textured faces, maybe the dynamic part can be done in shader?
(Might even look less blocky, because it's not limited to lightmap
 resolution then)
2017-03-05 17:34:53 +01:00
Daniel Gibson
2932d995fe GL3: Static Lightmaps (via blending)
not *that* cool, I wanna render them together with the normal texture..

and dynamic lightmaps are missing so most things look shitty anyway
2017-03-05 03:08:05 +01:00
Daniel Gibson
a3865db4bb GL3: rip out gl_flashblend 2017-03-04 16:38:08 +01:00
Daniel Gibson
18bfa35f9b Allow switching VSync on/off without vid_restart (for SDL2) 2017-03-04 16:31:34 +01:00
Daniel Gibson
6b21811af8 GL3: DrawNullModel()
this is used if a model can't be found/loaded
2017-02-26 20:47:37 +01:00
Daniel Gibson
613071078a GL3: render beams; common struct gl3_3D_vtx_t for vertex arrays
that struct can/should be used with gl3state.vao3D which expects data
as 7 floats (x,y,z, s,t, lms,lmt) - this is used for brushes, sprites,
the sky and more (not for models though).
(For rendering brushes the struct isn't used, the data already is in
 that format in float arrays)

beams are now rendered, they are used by the BFG and in some levels for
lasers etc
2017-02-26 05:22:39 +01:00
Daniel Gibson
977c81db5d GL3: Render sprites
and some cleanup/small stuff.

Damn, my productivity today scares me :-P
2017-02-26 04:37:22 +01:00
Daniel Gibson
15296ab5f8 GL3: Render Sky 2017-02-26 03:46:59 +01:00
Daniel Gibson
cf11473130 GL3: flashing screen (formerly R_Flash())
which just called R_PolyBlend().. no idea what that all was about..
and no idea why it happend in 3D mode, it's much  easier after
SetGL2D(), then it can share code with GL3_Draw_FadeScreen() and doesn't
need any additional messing with transformation matrices
2017-02-26 02:23:20 +01:00
Daniel Gibson
247a81c69b GL3: Render Particles, simplify GL3_ShutdownShaders()
* The particles look more fuzzy than in old renderer - I think it looks
  better this way ;)
* Not sure I keep the way they're rendered - instead of calculating and
  passing the distance in GL3_ShutdownShaders() I could set the player
  (camera) origin in a UBO and calculate distance (and based on that
  the size) in the vertex shader. I could also pass the basic point size
  via UBO, it's the same for all particles..
* Deleting shader programs is a lot shorter now and using a loop and
  the fact that consecutive fields of the same type in a struct have
  the same memory layout as an array of that type.
  Now I can just add a gl3ShaderInfo_t to gl3state, set it up in
  GL3_InitShaders() and don't have to add anything to
  GL3_ShutdownShaders() (this is good, I forgot that all the time and
  didn't notice, as it doesn't cause visible errors)
2017-02-26 00:47:27 +01:00
Daniel Gibson
f3e77e1123 GL3: Fix color-only rendering of models (+refactor GL3_UpdateUBO*)
* Of course the color attribute has 4 floats, not 2..
* I read that updating UBOs with glBufferData() is kinda slow.
  I didn't change that (yet), but at least all three GL3_UpdateUBO*()
  functions now call updateUBO() which can easily be changed to do
  whatever is best without touching the other three functions.
2017-02-26 00:20:32 +01:00
Daniel Gibson
b7bf822e6d GL1: Particle improvements
* When using gl_pointparameters, the particles always had the same size
  regardless of resolution, i.e. they look bigger (use bigger part of
  screen) at lower resolutions. Now I scale gl_particle_size according
  to the resolution, assuming the configured size looks good at 800x600
  (or generally 600px vertical)
* When not using gl_pointparameters, a textured triangle is rendered.
  The texture had a resolution of 8x8 pixels and looked like a cross,
  now it's 16x16 and has rounded ages, looking more like a circle.
  So particles with "gl_pointparameters 0" should look much better now.
2017-02-26 00:10:34 +01:00
Daniel Gibson
c4c21075a4 vid_listmodes command to show video modes, add 720p mode
the very unusual 1280x854 mode has been replaced with the more common
1280x720 ("720p").
2017-02-25 20:33:17 +01:00
Daniel Gibson
66e9c5f6db GL3: fix calculation of perspective matrix, some cleanups
turns out R_MYgluPerspective() was not the same as gluPerspective()
and thus not equivalent to HMM_Perspective() either. Because of this,
the weapon and corresponding arm looked different in GL3 vs GL1.
Created GL3_MYgluPerspective() to fix that.
Also tested optimized code in GL3_RotateForEntity() and
rotAroundAxisZYX(), use this code from now on and cleaned it all up by
removing commented out code.
2017-02-20 17:08:59 +01:00
Daniel Gibson
5511f44c99 GL3: Delete new shaders in GL3_ShutdownShaders()
also a small optimization in GL3_DrawAliasModel(), and adding that
function to local.h
2017-02-20 17:04:52 +01:00
Daniel Gibson
eadb607ac3 GL3: Support left-handed gun rendering (hand=1)
that was easy..
however, not related to this change or left vs right hand, the gun
seems to be drawn too far back, we should see more of the arm..
I wonder where that went wrong...
2017-02-20 02:16:34 +01:00
Daniel Gibson
de0197a8c0 GL3: Render models (weapons, items, monsters, projectiles etc)
introducing vertex color attributes GL3_ATTRIB_COLOR (it's used for
lighting models and to render models flat-colored, I think that's used
for quad damage effect and similar)
2017-02-20 02:03:31 +01:00
Daniel Gibson
098890805f GL3_BindVBO(vbo) wrapping glBindBuffer(GL_ARRAY_BUFFER, vbo)
avoids calling glBindBuffer() if the vbo is already bound, similar
to GL3_Bind(), GL3_BindVAO(), GL3_UseProgram() etc
2017-02-20 02:01:48 +01:00
Daniel Gibson
30026f2025 Make usage of anormtab.h a bit cleaner
bla =
#include "blub.h"
;

sucks, bla = {
#include "blub.h"
};
is a bit cleaner, especially regarding comments in "blub.h"

(Eclipse was very confused)
2017-02-19 06:04:47 +01:00
Daniel Gibson
f5e2fb16b4 GL3: Draw Entities (only brush-based so far) 2017-02-19 06:04:47 +01:00
Daniel Gibson
8723f73831 Show renderer name in window title 2017-02-19 06:04:47 +01:00
Daniel Gibson
7cd86106dc GL3: Use HMM types in structs for UBOs, some cleanups
.. hmm_mat4 and hmm_vec4 are much easier to set than float arrays.

removed some debug code from initShader2D()
2017-02-19 06:04:47 +01:00
Daniel Gibson
101b9b14bb GL3: Flowing (non-warping) textures 2017-02-19 06:04:47 +01:00
Daniel Gibson
d7b5c7e86e GL3: shared UBOs instead of normal uniforms; warping water 2017-02-19 06:04:47 +01:00
Daniel Gibson
6e07ff0a2d GL3: Rework 2D drawing, Rotation-Matrix stuff; common vtx attr layout
kind of messy commit with all the shit from last weekend, finished now

Most importantly the common vertex attribute layout stuff using
glBindAttribLocation()
2017-02-19 06:04:43 +01:00
Daniel Gibson
0d81fd6080 Fix OSX build (with Makefile) 2017-02-19 06:03:08 +01:00
Daniel Gibson
57fd192cda GL3: levels are rendered a bit
the code is still very much WIP and kinda crappy, especially the
  static GLuint vao = 0, vbo = 0;
part in GL3_DrawGLPoly()
2017-02-19 06:03:07 +01:00
Daniel Gibson
0b35ceabdc GL3: added missing source files and stubs of most functions
still no 3D rendering, but in theory it should be able to load models,
bsps etc, just not render them yet.

also moved/copied md2.c and sp2.c to gl/ and gl3/ because they use
renderer-specific types
2017-02-19 06:03:07 +01:00
Daniel Gibson
ebbb675cb8 GL3: gamma and intensity via shader
only for 2D rendering, as we don't have 3D yet; also this might need
a more flexible solution later, as some textures are not supposed to
have intensity applied.
According to the old R_Upload32*() and R_LightScaleTexture() the ones
without mipmaps didn't get intensity. Those were it_pic and it_sky (and
the ones in the "scrap", but those were it_pic too)
2017-02-19 06:03:07 +01:00
Daniel Gibson
43e108fb9b GL3_Draw_* is done, menu, console, videos work 2017-02-19 06:03:07 +01:00
Daniel Gibson
678410bfb4 Added super simple shaders, does render videos now 2017-02-19 06:03:07 +01:00
Daniel Gibson
56661fd43f GL3: Add remaining stubs, add HandMadeMath, update Copyrights 2017-02-19 06:03:07 +01:00
Daniel Gibson
26904949c2 Implemented GL3_LoadPic() and related functions
so loading texture and uploading them to the GPU should work.
a pity there's no code to use them yet :P
2017-02-19 06:03:07 +01:00
Daniel Gibson
0787b75792 Cache gl_nolerp_list Cvar in ref libs, fix possible bug in R_FindImage()
I see no reason to Cvar_Get() gl_nolerp_list again and again, just save
it like all the other gl_ Cvars.
2017-02-19 06:03:07 +01:00
Daniel Gibson
64a456b867 Moved LoadWal() to r_image.c/gl3_image.c
It returns the renderer-specific image_t*; wal.c is now
renderer-agnostic and only contains GetWalInfo().
2017-02-19 06:03:07 +01:00
Daniel Gibson
c098ee2ce3 LoadPCX() supports palette=NULL to avoid malloc()
when called from R_FindImage() the palette wasn't used anyway.
R_FindImage() now passes NULL.
(LoadPCX() is still called with non-NULL palette from Draw_GetPalette())
2017-02-19 06:03:07 +01:00
Daniel Gibson
9970dc43ad some further steps; ref_shared.h shared between ref libs
still nothing useful..
2017-02-19 06:03:07 +01:00
Daniel Gibson
324eaa8048 begin implementing ref_gl3
so far it can't even be loaded completely and has no code for
rendering yet
2017-02-19 06:03:07 +01:00
Daniel Gibson
c901ad9bb6 Fix build on OSX 2017-02-19 06:03:07 +01:00
Daniel Gibson
aaa73236ec refexport_t::Init() now returns bool and has no args; minor things
the arguments were not used anyway, and returning true/false is clearer
than returning -1 (for error) or sth else (which has no deeper meaning
anyway).

Also:
* PrepareForWindow() can now return -1 if there's an error
* suppress some warnings in Makefile
* fix error for building ref_gl.dylib on OSX
2017-02-19 06:03:07 +01:00