Commit Graph

1787 Commits

Author SHA1 Message Date
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
Daniel Gibson 5938a665e8 pass Com_VPrintf() to reflib used by R_Printf(), remove VID_Printf()
So in all code in the reflib (ref_gl.dll/.so/.dylib) calls to
ri.Con_Printf(print_level, fmt, ...) have been replaced by calls to
R_Printf(print_level, fmt, ...) which uses ri.Com_VPrintf().
2017-02-19 06:03:07 +01:00
Daniel Gibson a0c1c74a2e (Mostly) get rid of VID_Printf() and VID_Error()
they're only wrapping Com_Printf() and Com_Error() anyway
2017-02-19 06:03:07 +01:00
Daniel Gibson 54ae3be0c6 Com_VPrintf(level, fmt, argptr) (Com_D?Printf() wraps that)
somehow all the printf()-like things in Q2 wrap each other and each
one prints into a buffer and then calls the next one with ("%s", buf).
That's not very clever and kinda annoying.
As in the end everyone calls Com_Printf() I created Com_VPrintf()
that can be called instead with the va_list.

I also added printf-format annotation to Com_Printf() and Com_DPrintf()
and fixed places where Com_Printf() was called with the wrong type.
2017-02-19 06:03:07 +01:00
Daniel Gibson c743aaa8fe Copyright-header in r_sdl.c
forgot that when I created the file..
2017-02-19 06:03:07 +01:00
Daniel Gibson 181d4fa0ea Move client/refresh/header/* and qgl.h to client/refresh/gl/header/*
and the changes in the including files for this.

(also removed gl.h includes from local.h, as it's already included in
 qgl.h which is included by local.h)
2017-02-19 06:03:07 +01:00
Daniel Gibson 73cf610cdb Only use client/refresh/header/local.h in refresh lib
that's why it's called "local.h". duh.
(next I'll move it to refresh/gl/)
2017-02-19 06:03:07 +01:00
Daniel Gibson 9252eba643 use vid_ref cvar to select render dll 2017-02-19 06:03:07 +01:00
Daniel Gibson 4ede163794 Fix window build with Makefile
the problem is that sdl2-config --libs apparently includes shit that's only
useful for the executable, but not dlls, like linking against SDL2main and
libmingw32 and setting -mwindows

Furthermore I forgot to add -lopengl32 and -shared to the ref_gl Windows
LDFLAGS.
2017-02-19 06:03:07 +01:00
Daniel Gibson 7f27c549a8 It works again, ref_gl doesn't use any client symbols anymore
So in theory this should even work on Windows now.
2017-02-19 06:03:07 +01:00
Daniel Gibson 0588d3f988 VID_Error -> ri.Sys_Error; VID_Printf -> ri.Con_Printf 2017-02-19 05:53:56 +01:00
Daniel Gibson 2062b319e9 move qgl.[ch] to src/client/refresh/gl/ 2017-02-19 05:53:56 +01:00
Daniel Gibson f13e15e561 ref_gl.so builds and works (on Linux, with Makefile)
still dirty, seems to use some symbols from client directly, which will
not work on Windows.
2017-02-19 05:53:56 +01:00
Daniel Gibson 3a65b41d60 Move OpenGL render specific files to src/client/refresh/gl/ 2017-02-19 05:53:56 +01:00
Yamagi Burmeister 6e5cf7ee08 Add a cvar gl_showbbox for drawing entities bounding boxes 2017-01-19 21:04:58 +01:00
Yamagi Burmeister 55d7842a02 Add back 'spectator' and 'password' cvars.
Those are special cvars that just need to be registered. They're used
in the servers userinfo structures. This closes issue #166.
2017-01-02 19:45:22 +01:00
Yamagi Burmeister 44472722e0 Make sure that a monsters enemy is still alive when deciding to attack.
When the monster was already killed by another monster or a coop player
some references may be NULL and the game was crashed. This was observed
by maraakte, who reported it in issue #164. I've just merged his fix
from q2dos.
2016-12-28 18:29:08 +01:00
Yamagi Burmeister af957c5e36 Fix a small buffer overflow when disabling shuffle playback
Repeat 10 times:
 - strcat() is evil
 - strcat() is evil
 ...

While here fix another small inconsistency: Vorbis playback should
stop when switching 'shuffle' on.

The overflow was reported by @tomgreen66 in pull request #168.
2016-12-28 17:23:51 +01:00
Yamagi Burmeister c07fe5ac2d Reorder conditionals to please unoptimizing compilers
This was requested by Maraakate. This is likely a noop, since even
early compilers from th 1970th supported simple optimiziations like
this.
2016-12-20 15:14:59 +01:00
Yamagi Burmeister 693b7bfb84 Use strtod() instead of strof() to aid VS2005 2016-12-18 10:17:06 +01:00
Yamagi Burmeister 8fe8f832f8 Remove last remnant of multitexturing.
Pointed out by DanielGibson.
2016-12-18 09:48:06 +01:00
Yamagi Burmeister a774846659 Change edict_s->show_hostile from qboolean to int and add casts
This variable is used as an integer. Defining it as a qbooblean is
just wrong. Add some explicit float -> int casts while at it.
2016-12-18 09:11:58 +01:00
Yamagi Burmeister c26f85fd02 Rename teleport_time to last_sound time
teleport_time has nothing to do with teleports, it's just the time
since the last player sound. Rename it accordingly. This was suggest
by maraakate in issue #162.
2016-12-18 09:07:51 +01:00
Yamagi Burmeister 935c37f819 Fix monsters ignoring the player under certain circumstances
In ai_checkattack() is a check against AI_SOUND_TARGET. If the player
made a noice and the the monster noticed this noise it's true. If
that noice was more than 5 seconds ago the monster forgets that event
and continues with it's search for the player. Otherwise it informs
the surrounding monsters that something interesting has happened and
then returns false. So the problem is: Even if the monster heard the
player and can see him, it aborts at this point.

Fix this by adding an additional visibility check. Do the sound
checking only if the player is not visible, otherwise just continue.

This was reported by shoober420 and debbuged by maraakate. This fix
was DanielGibons idea. This commit fixes issue #162.
2016-12-18 09:04:46 +01:00