Re: [AD] Primitives Addon Release 1

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2008-12-29, Paul Suntsov <siegelords_abode@xxxxxxxxxx> wrote:
> Attached is the first release of the primitives addon. Naturally, it is not complete yet in the slightest, but this is the first time something logical could be submitted.
> 
> What it has now:
> 
> -All primitives that are based on lines are implemented for OpenGL and Software.
> -Transformations for OpenGL and Software
> -Software vertex buffers
> -NaturalDocs documentation stuck here and there
> -A somewhat normal public header?
> 
> What it doesn't have that it should have at this point:
> 
> -Anything DirectX, I can do this myself eventually, but it'd be nice to have someone more experienced with it help me out with this.
> 
> Problems so far:
> 
> -Blending does not work properly yet (or won't ever). The reason for this is that blending in A5 now is done via calling the glColor* before drawing the polygons. Since every vertex in the addon right now has a separate glColor* equivalent call, this approach will no longer feasible. In my mind, two things can be done: one, to specifically state that colour shading does not work for this addon; two, to implement this shading via a shader.
> -API naming is not too great... I'd appreciate comments on it.
> 
> Compiling + Running:
> 
> -I haven't made a CMakeLists.txt for this, but basically compiling every .c file will do the trick for now. To run the example you need the DejaVuSans.ttf from the examples folder.
> 
> That should be all for now. Ask for any clarifications etc.

A fair number of the ASSERTs appear to be slightly wrong, e.g.

    ASSERT(type > 0 && type < ALLEGRO_PRIM_NUM_TYPES);
    ASSERT(idx > 0 && idx < vbuff->len);
    ASSERT(start >= end);

so you should compile in debug mode and fix those.

Attached are cmake files you can use.

Peter
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 89c00eb..2222b2a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,6 +109,7 @@ option(WANT_JPG "Enable JPEG support in IIO" on)
 option(WANT_PNG "Enable PNG support in IIO" on)
 option(WANT_TTF "Enable TTF addon" on)
 option(WANT_COLOR "Enable color addon" on)
+option(WANT_PRIMITIVES "Enable primitives addon" on)
 
 option(WANT_ALSA "Enable ALSA digital audio driver (Unix)" on)
 option(WANT_OSS "Enable OSS digital audio driver (Unix)" on)
diff --git a/addons/primitives/CMakeLists.txt b/addons/primitives/CMakeLists.txt
new file mode 100644
index 0000000..7d431a9
--- /dev/null
+++ b/addons/primitives/CMakeLists.txt
@@ -0,0 +1,86 @@
+set(PRIMITIVES_SOURCES
+    high_primitives.c
+    line_soft.c
+    mesh.c
+    prim_directx.c
+    prim_opengl.c
+    prim_soft.c
+    primitives.c
+    )
+set(PRIMITIVES_INCLUDE_FILES allegro5/a5_primitives.h)
+
+macro(add_primitives_build nm extra_flags)
+    macro(really_add_primitives_build nm2 target libtype more_extra_flags)
+        add_library(${target} ${libtype} ${PRIMITIVES_SOURCES})
+
+        set_target_properties(${target}
+            PROPERTIES
+            COMPILE_FLAGS "${more_extra_flags} ${LIBRARY_CFLAGS} -DALLEGRO_PRIMITIVES_SRC"
+            OUTPUT_NAME ${nm2}
+            )
+
+        install(TARGETS ${target}
+                DESTINATION "lib${LIB_SUFFIX}"
+                LIBRARY PERMISSIONS
+                    OWNER_READ OWNER_WRITE OWNER_EXECUTE
+                    GROUP_READ             GROUP_EXECUTE
+                    WORLD_READ             WORLD_EXECUTE
+                )
+    endmacro(really_add_primitives_build)
+
+    if(SHARED)
+        really_add_primitives_build(${nm} ${nm}_shared SHARED "")
+        target_link_libraries(${nm}_shared ${IIO_ADDONS_LINK_WITH})
+        target_link_libraries(${nm}_shared ${ADDONS_LINK_WITH})
+    endif(SHARED)
+
+    if(STATIC)
+        really_add_primitives_build(${nm}-static ${nm}_static STATIC "-DALLEGRO_STATICLINK")
+    endif(STATIC)
+
+endmacro(add_primitives_build)
+
+if(GRADE_STANDARD)
+    add_primitives_build(a5_primitives
+        "-O2 -funroll-loops -ffast-math -fomit-frame-pointer")
+endif(GRADE_STANDARD)
+
+if(GRADE_DEBUG)
+    add_primitives_build(a5_primitives-debug
+        "-DDEBUGMODE -g")
+endif(GRADE_DEBUG)
+
+if(GRADE_PROFILE)
+    add_primitives_build(a5_primitives-profile
+        "-pg -O2 -funroll-loops -ffast-math")
+endif(GRADE_PROFILE)
+
+
+if(GRADE_STANDARD)
+    set(PRIMITIVES_LIB_TO_LINK a5_primitives CACHE INTERNAL "internal")
+elseif(GRADE_DEBUG)
+    set(PRIMITIVES_LIB_TO_LINK a5_primitives-debug CACHE INTERNAL "internal")
+elseif(GRADE_PROFILE)
+    set(PRIMITIVES_LIB_TO_LINK a5_primitives-profile CACHE INTERNAL "internal")
+endif(GRADE_STANDARD)
+
+if(STATIC)
+    set(PRIMITIVES_LINK_WITH ${PRIMITIVES_LIB_TO_LINK}_static PARENT_SCOPE)
+    set(PRIMITIVES_LINK_WITH ${PRIMITIVES_LIB_TO_LINK}_static CACHE INTERNAL "internal")
+else(STATIC)
+    set(PRIMITIVES_LINK_WITH ${PRIMITIVES_LIB_TO_LINK}_shared PARENT_SCOPE)
+    set(PRIMITIVES_LINK_WITH ${PRIMITIVES_LIB_TO_LINK}_shared CACHE INTERNAL "internal")
+endif(STATIC)
+
+
+#-----------------------------------------------------------------------------#
+#
+# Install header files.
+#
+
+install(FILES ${PRIMITIVES_INCLUDE_FILES}
+        DESTINATION include/allegro5
+        )
+
+#-----------------------------------------------------------------------------#
+# vi: set ts=8 sts=4 sw=4 et:
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 2a3a955..4fbb0c2 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -65,6 +65,12 @@ if(SUPPORT_TTF)
 endif(SUPPORT_TTF)
 endif(SUPPORT_COLOR)
 
+if(SUPPORT_PRIMITIVES AND SUPPORT_TTF)
+    include_directories(../addons/primitives)
+    example(ex_prim ${PRIMITIVES_LINK_WITH} ${TTF_LINK_WITH} ${FONT_LINK_WITH}
+        ${IIO_LINK_WITH})
+endif(SUPPORT_PRIMITIVES AND SUPPORT_TTF)
+
 example(ex_config)
 example(ex_drawpixels)
 example(ex_get_path)


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/