Compare commits

..

No commits in common. "00bfa35252fe5b2fe020e5b0cd818f703b7c83f8" and "8a5d639f95fde8a01e5d65dfde4b2afaf665c749" have entirely different histories.

10 changed files with 14 additions and 77 deletions

View File

@ -85,7 +85,8 @@ endif()
if(TWN_RENDERING_API MATCHES OPENGL_15)
set(SYSTEM_SOURCE_FILES ${SYSTEM_SOURCE_FILES}
src/rendering/twn_gl_any_rendering.c
src/rendering/twn_gl_15_rendering.c)
src/rendering/twn_gl_15_rendering.c
src/rendering/twn_gl_15_gpu_texture.c)
endif()
set(TWN_THIRD_PARTY_SOURCE_FILES
@ -141,7 +142,7 @@ set_target_properties(${TWN_TARGET} PROPERTIES
C_STANDARD_REQUIRED ON
C_EXTENSIONS ON) # extensions are required by stb_ds.h
target_compile_definitions(${TWN_TARGET} PRIVATE $<$<BOOL:${TWN_FEATURE_PUSH_AUDIO}>:TWN_FEATURE_PUSH_AUDIO>)
add_compile_definitions(${TWN_TARGET} $<$<BOOL:${TWN_FEATURE_PUSH_AUDIO}>:TWN_FEATURE_PUSH_AUDIO>)
# precompile commonly used not-so-small headers
target_precompile_headers(${TWN_TARGET} PRIVATE

View File

@ -13,7 +13,7 @@
#define TERRAIN_FREQUENCY 0.15f
#define TERRAIN_DISTANCE 64
#define TERRAIN_DISTANCE 32
#define HALF_TERRAIN_DISTANCE ((float)TERRAIN_DISTANCE / 2)
#define PLAYER_HEIGHT 0.6f
@ -225,7 +225,8 @@ static void ingame_tick(State *state) {
draw_skybox("/assets/miramar/miramar_*.tga");
ctx.fog_color = (Color){ 140, 147, 160, 255 };
ctx.fog_density = 0.03f;
ctx.fog_start = 0.9f;
ctx.fog_density = 0.05f;
}

View File

@ -24,7 +24,7 @@ typedef struct Context {
float frame_duration;
/* it is disabled by having fog_density approximately equal to zero */
float fog_density;
float fog_start, fog_end, fog_density;
Color fog_color;
/* resolution is set from config and dictates both logical and drawing space, as they're related */

View File

@ -42,11 +42,6 @@ TWN_API void draw_nine_slice(char const *texture,
float border_thickness, /* optional, default: 0 */
Color color); /* optional, default: all 255 */
TWN_API void draw_line(Vec2 start,
Vec2 finsih,
float thickness, /* optional, default: 1 */
Color color); /* optional, default: all 255 */
/* pushes a textured 3d triangle onto the render queue */
/* texture coordinates are in pixels */
TWN_API void draw_triangle(char const *texture,

View File

@ -281,6 +281,8 @@
"fields": [
{ "name": "frame_number", "type": "float" },
{ "name": "frame_duration", "type": "float" },
{ "name": "fog_start", "type": "float" },
{ "name": "fog_end", "type": "float" },
{ "name": "fog_density", "type": "float" },
{ "name": "fog_color", "type": "Color" },
{ "name": "resolution", "type": "Vec2" },

View File

@ -3,7 +3,6 @@
#include "twn_engine_context_c.h"
#include "twn_camera_c.h"
#include "twn_types.h"
#include "twn_util.h"
#include "twn_vec.h"
#include "twn_deferred_commands.h"
@ -285,20 +284,6 @@ static void render_2d(void) {
break;
}
/* TODO: batching */
case PRIMITIVE_2D_LINE: {
struct Render2DInvocation const invocation = {
.primitive = current,
.layer = layer,
};
if (current->line.color.a != 255)
arrput(ghostly_invocations, invocation);
else
arrput(opaque_invocations, invocation);
break;
}
case PRIMITIVE_2D_TEXT: {
struct Render2DInvocation const invocation = {
.primitive = current,
@ -335,9 +320,6 @@ static void render_2d(void) {
case PRIMITIVE_2D_CIRCLE:
render_circle(&invocation.primitive->circle);
break;
case PRIMITIVE_2D_LINE:
render_line(&invocation.primitive->line);
break;
case PRIMITIVE_2D_TEXT:
default:
SDL_assert(false);
@ -367,9 +349,6 @@ static void render_2d(void) {
case PRIMITIVE_2D_TEXT:
render_text(&invocation.primitive->text);
break;
case PRIMITIVE_2D_LINE:
render_line(&invocation.primitive->line);
break;
default:
SDL_assert(false);
}
@ -501,28 +480,3 @@ void issue_deferred_draw_commands(void) {
}
}
}
/* TODO: Support thickness */
void draw_line(Vec2 start,
Vec2 finsih,
float thickness,
Color color)
{
if (fabsf(1.0f - thickness) >= 0.00001f)
log_warn("Thickness isn't yet implemented for line drawing (got %f)", (double)thickness);
LinePrimitive line = {
.start = start,
.finish = finsih,
.thickness = thickness,
.color = color,
};
Primitive2D primitive = {
.type = PRIMITIVE_2D_LINE,
.line = line,
};
arrput(ctx.render_queue_2d, primitive);
}

View File

@ -56,13 +56,6 @@ typedef struct SpritePrimitive {
bool repeat;
} SpritePrimitive;
typedef struct LinePrimitive {
Vec2 start;
Vec2 finish;
float thickness;
Color color;
} LinePrimitive;
typedef struct RectPrimitive {
Rect rect;
Color color;
@ -84,7 +77,6 @@ typedef struct TextPrimitive {
typedef enum Primitive2DType {
PRIMITIVE_2D_SPRITE,
PRIMITIVE_2D_LINE,
PRIMITIVE_2D_RECT,
PRIMITIVE_2D_CIRCLE,
PRIMITIVE_2D_TEXT,
@ -95,7 +87,6 @@ typedef struct Primitive2D {
union {
SpritePrimitive sprite;
LinePrimitive line;
RectPrimitive rect;
CirclePrimitive circle;
TextPrimitive text;
@ -297,8 +288,6 @@ VertexBuffer get_circle_element_buffer(void);
void render_circle(const CirclePrimitive *circle);
void render_line(const LinePrimitive *line);
void render_rectangle(const RectPrimitive *rectangle);
void finally_render_quads(Primitive2D const primitives[],

View File

@ -454,6 +454,8 @@ void finally_draw_command(DeferredCommandDraw command) {
ctx.game_copy.fog_density = clampf(ctx.game_copy.fog_density, 0.0, 1.0);
glFogf(GL_FOG_DENSITY, ctx.game_copy.fog_density);
glFogf(GL_FOG_START, ctx.game_copy.fog_start);
glFogf(GL_FOG_END, ctx.game_copy.fog_end);
float color_conv[4];
color_conv[0] = (float)ctx.game_copy.fog_color.r / UINT8_MAX;
@ -548,13 +550,3 @@ void finally_draw_command(DeferredCommandDraw command) {
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void render_line(const LinePrimitive *line) {
finally_use_2d_pipeline();
glBegin(GL_LINES);
glColor4b(line->color.r, line->color.g, line->color.b, line->color.a);
glVertex2f(line->start.x, line->start.y);
glColor4b(line->color.r, line->color.g, line->color.b, line->color.a);
glVertex2f(line->finish.x, line->finish.x);
glEnd();
}

View File

@ -170,4 +170,6 @@ void push_quad_payload_to_vertex_buffer_builder(struct QuadBatch batch,
((ElementIndexedQuadWithoutColorWithoutTexture *)builder->base)[index] = payload;
}
SDL_assert(false);
}

View File

@ -604,6 +604,7 @@ static bool initialize(void) {
ctx.window_mouse_resident = true;
ctx.game.fog_color = (Color){ 255, 255, 255, 255 }; /* TODO: pick some grey? */
ctx.game.fog_end = 1.0f;
update_viewport();