Skip to content

Commit

Permalink
Still working on lines
Browse files Browse the repository at this point in the history
  • Loading branch information
rswinkle committed May 31, 2024
1 parent 340235a commit 8a47fee
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 457 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ demos/pgl_imgui
demos/imgui.ini
demos/assimp_convert

demos/polyline
demos/polyline.make

testing/run_tests
testing/perf_tests
testing/math_testing
Expand Down
8 changes: 7 additions & 1 deletion demos/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ifndef config
endif
export config

PROJECTS := swrenderer sphereworld sphereworld_color cubemap grass gears modelviewer pointsprites shadertoy raytracing_1weekend texturing multidraw testprimitives particles sdl_renderer_imgui pgl_imgui assimp_convert
PROJECTS := swrenderer sphereworld sphereworld_color cubemap grass gears modelviewer pointsprites shadertoy raytracing_1weekend texturing multidraw polyline testprimitives particles sdl_renderer_imgui pgl_imgui assimp_convert

.PHONY: all clean help $(PROJECTS)

Expand Down Expand Up @@ -60,6 +60,10 @@ multidraw:
@echo "==== Building multidraw ($(config)) ===="
@${MAKE} --no-print-directory -C . -f multidraw.make

polyline:
@echo "==== Building polyline ($(config)) ===="
@${MAKE} --no-print-directory -C . -f polyline.make

testprimitives:
@echo "==== Building testprimitives ($(config)) ===="
@${MAKE} --no-print-directory -C . -f testprimitives.make
Expand Down Expand Up @@ -93,6 +97,7 @@ clean:
@${MAKE} --no-print-directory -C . -f raytracing_1weekend.make clean
@${MAKE} --no-print-directory -C . -f texturing.make clean
@${MAKE} --no-print-directory -C . -f multidraw.make clean
@${MAKE} --no-print-directory -C . -f polyline.make clean
@${MAKE} --no-print-directory -C . -f testprimitives.make clean
@${MAKE} --no-print-directory -C . -f particles.make clean
@${MAKE} --no-print-directory -C . -f sdl_renderer_imgui.make clean
Expand Down Expand Up @@ -121,6 +126,7 @@ help:
@echo " raytracing_1weekend"
@echo " texturing"
@echo " multidraw"
@echo " polyline"
@echo " testprimitives"
@echo " particles"
@echo " sdl_renderer_imgui"
Expand Down
11 changes: 11 additions & 0 deletions demos/premake4.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ solution "Demos"
"../glcommon/rsw_matstack.h",
}

project "polyline"
language "C++"
configuration { "gmake" }
buildoptions { "-fno-rtti", "-fno-exceptions", "-fno-strict-aliasing", "-Wunused-variable", "-Wreturn-type" }
links { "SDL2", "m" }
files {
"./polyline.cpp",
"../glcommon/rsw_math.cpp",
"../glcommon/rsw_matstack.h",
}

project "testprimitives"
language "C++"
configuration { "gmake" }
Expand Down
9 changes: 4 additions & 5 deletions portablegl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6070,10 +6070,9 @@ static void draw_point(glVertex* vert, float poly_offset)
// clamp(point.z, c->depth_range_near, c->depth_range_far);

Shader_Builtins builtins;
// spec pg 110 r,q are supposed to be replaced with 0 and 1...but PointCoord is a vec2
// not worth making it a vec4 for something unlikely to be used
//builtins.gl_PointCoord.z = 0;
//builtins.gl_PointCoord.w = 1;
// 3.3 spec pg 110 says r,q are supposed to be replaced with 0 and 1...
// but PointCoord is a vec2 and that is not in the 4.6 spec so it must be a typo

int fragdepth_or_discard = c->programs.a[c->cur_program].fragdepth_or_discard;

//TODO why not just pass vs_output directly? hmmm...
Expand Down Expand Up @@ -6847,7 +6846,7 @@ static void draw_thick_line(vec3 hp1, vec3 hp2, float w1, float w2, float* v1_ou
//if (dist*dist < width2) {
if (fabsf(dist) < width) {
t = e / dot_1212;

z = (1 - t) * z1 + t * z2;
z += poly_offset;
if (fragdepth_or_discard || fragment_processing(x, y, z)) {
Expand Down
9 changes: 4 additions & 5 deletions portablegl_unsafe.h
Original file line number Diff line number Diff line change
Expand Up @@ -6070,10 +6070,9 @@ static void draw_point(glVertex* vert, float poly_offset)
// clamp(point.z, c->depth_range_near, c->depth_range_far);

Shader_Builtins builtins;
// spec pg 110 r,q are supposed to be replaced with 0 and 1...but PointCoord is a vec2
// not worth making it a vec4 for something unlikely to be used
//builtins.gl_PointCoord.z = 0;
//builtins.gl_PointCoord.w = 1;
// 3.3 spec pg 110 says r,q are supposed to be replaced with 0 and 1...
// but PointCoord is a vec2 and that is not in the 4.6 spec so it must be a typo

int fragdepth_or_discard = c->programs.a[c->cur_program].fragdepth_or_discard;

//TODO why not just pass vs_output directly? hmmm...
Expand Down Expand Up @@ -6847,7 +6846,7 @@ static void draw_thick_line(vec3 hp1, vec3 hp2, float w1, float w2, float* v1_ou
//if (dist*dist < width2) {
if (fabsf(dist) < width) {
t = e / dot_1212;

z = (1 - t) * z1 + t * z2;
z += poly_offset;
if (fragdepth_or_discard || fragment_processing(x, y, z)) {
Expand Down
9 changes: 4 additions & 5 deletions src/gl_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,9 @@ static void draw_point(glVertex* vert, float poly_offset)
// clamp(point.z, c->depth_range_near, c->depth_range_far);

Shader_Builtins builtins;
// spec pg 110 r,q are supposed to be replaced with 0 and 1...but PointCoord is a vec2
// not worth making it a vec4 for something unlikely to be used
//builtins.gl_PointCoord.z = 0;
//builtins.gl_PointCoord.w = 1;
// 3.3 spec pg 110 says r,q are supposed to be replaced with 0 and 1...
// but PointCoord is a vec2 and that is not in the 4.6 spec so it must be a typo

int fragdepth_or_discard = c->programs.a[c->cur_program].fragdepth_or_discard;

//TODO why not just pass vs_output directly? hmmm...
Expand Down Expand Up @@ -1023,7 +1022,7 @@ static void draw_thick_line(vec3 hp1, vec3 hp2, float w1, float w2, float* v1_ou
//if (dist*dist < width2) {
if (fabsf(dist) < width) {
t = e / dot_1212;

z = (1 - t) * z1 + t * z2;
z += poly_offset;
if (fragdepth_or_discard || fragment_processing(x, y, z)) {
Expand Down
Loading

0 comments on commit 8a47fee

Please sign in to comment.