things
This commit is contained in:
parent
0629b042ad
commit
310889bd2c
33
src/main.c
33
src/main.c
@ -382,26 +382,12 @@ static int gr_lowres(int newW, int newH) {
|
|||||||
}
|
}
|
||||||
k3TexUpdate(lowresDepth, k3_DEPTH, 0, newW, newH, NULL);
|
k3TexUpdate(lowresDepth, k3_DEPTH, 0, newW, newH, NULL);
|
||||||
|
|
||||||
lowresOffscreen = k3OffscreenCreate(lowres, lowresDepth);
|
lowresOffscreen = k3OffscreenCreateMultisampled(lowres, lowresDepth, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !!lowresOffscreen;
|
return !!lowresOffscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_RAYS 64
|
|
||||||
static struct LocalRay RaysToCast[MAX_RAYS];
|
|
||||||
static size_t RaysToCastCount = 0;
|
|
||||||
|
|
||||||
struct LocalRay *request_ray(struct LocalRay *lr) {
|
|
||||||
if(RaysToCastCount == MAX_RAYS) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(RaysToCast + RaysToCastCount, lr, sizeof(*lr));
|
|
||||||
|
|
||||||
return &RaysToCast[RaysToCastCount++];
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc_, char **argv_) {
|
int main(int argc_, char **argv_) {
|
||||||
argc = argc_;
|
argc = argc_;
|
||||||
argv = argv_;
|
argv = argv_;
|
||||||
@ -480,9 +466,6 @@ int main(int argc_, char **argv_) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
game_raycast(RaysToCast, RaysToCastCount);
|
|
||||||
RaysToCastCount = 0;
|
|
||||||
|
|
||||||
while(accumulator >= 1. / GAME_TPS) {
|
while(accumulator >= 1. / GAME_TPS) {
|
||||||
for(size_t i = 0; i < Game.entities.renderCount; i++) {
|
for(size_t i = 0; i < Game.entities.renderCount; i++) {
|
||||||
glm_vec4_copy(Game.entities.render[i].pos, Game.entities.render[i].posLast);
|
glm_vec4_copy(Game.entities.render[i].pos, Game.entities.render[i].posLast);
|
||||||
@ -509,10 +492,10 @@ int main(int argc_, char **argv_) {
|
|||||||
glfwGetFramebufferSize(GameWnd, &width, &height);
|
glfwGetFramebufferSize(GameWnd, &width, &height);
|
||||||
|
|
||||||
mat4 proj;
|
mat4 proj;
|
||||||
glm_perspective(glm_rad(LuaapiFov), (float) width / height, 0.01f, 100.f, proj);
|
glm_perspective(glm_rad(LuaapiFov), (float) width / height, 0.1f, 80.f, proj);
|
||||||
|
|
||||||
/* Third-person camera movement */
|
/* Third-person camera movement */
|
||||||
struct LocalRay camray;
|
struct LocalRay camray = {};
|
||||||
if(Game.spectated != ENT_ID_INVALID) {
|
if(Game.spectated != ENT_ID_INVALID) {
|
||||||
struct CRender *c = game_getcomponent(Game.spectated, render);
|
struct CRender *c = game_getcomponent(Game.spectated, render);
|
||||||
if(c) {
|
if(c) {
|
||||||
@ -533,6 +516,9 @@ int main(int argc_, char **argv_) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mat4 cam;
|
mat4 cam;
|
||||||
|
if(InstantCamShift) {
|
||||||
|
InstantCamShift--;
|
||||||
|
}
|
||||||
if(LuaapiFirstPerson) {
|
if(LuaapiFirstPerson) {
|
||||||
struct CRender *c = game_getcomponent(Game.spectated, render);
|
struct CRender *c = game_getcomponent(Game.spectated, render);
|
||||||
|
|
||||||
@ -551,10 +537,15 @@ int main(int argc_, char **argv_) {
|
|||||||
vec3 almostThere;
|
vec3 almostThere;
|
||||||
|
|
||||||
if(LuaapiCamFocus) {
|
if(LuaapiCamFocus) {
|
||||||
|
float lerpa = InstantCamShift ? 1 : 0.1;
|
||||||
|
|
||||||
glm_vec3_copy(LuaapiCamFocusPos, almostThere);
|
glm_vec3_copy(LuaapiCamFocusPos, almostThere);
|
||||||
glm_vec3_lerp(CamPos, almostThere, 0.1, CamPos);
|
glm_vec3_lerp(CamPos, almostThere, 0.1, CamPos);
|
||||||
|
glm_vec3_copy(LuaapiCamFocusPos, CamPos);
|
||||||
glm_look(CamPos, LuaapiCamFocusDir, (vec3) {0, 1, 0}, cam);
|
glm_look(CamPos, LuaapiCamFocusDir, (vec3) {0, 1, 0}, cam);
|
||||||
} else {
|
} else {
|
||||||
|
float lerpa = InstantCamShift ? 1 : 0.2;
|
||||||
|
|
||||||
vec3 dirneg;
|
vec3 dirneg;
|
||||||
glm_vec3_negate_to(camray.dir, dirneg);
|
glm_vec3_negate_to(camray.dir, dirneg);
|
||||||
|
|
||||||
@ -668,7 +659,7 @@ int main(int argc_, char **argv_) {
|
|||||||
|
|
||||||
// Shadowmap debugging
|
// Shadowmap debugging
|
||||||
if(glfwGetKey(GameWnd, GLFW_KEY_F5) == GLFW_PRESS) {
|
if(glfwGetKey(GameWnd, GLFW_KEY_F5) == GLFW_PRESS) {
|
||||||
k3BlitToScreen(shadowmapOffscreen, 0);
|
k3BlitToScreenEffect(shadowmapOffscreen, 0, k3_ARBFRAG, shadowmapDebugThing, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSwapBuffers(GameWnd);
|
glfwSwapBuffers(GameWnd);
|
||||||
|
Loading…
Reference in New Issue
Block a user