Skip to content

Commit c6d16f1

Browse files
committed
Move the core of the primitives addon into the core.
This is the first step of #1003, enabling future rendering unification changes. On OpenGL, this is feature neutral, as the implementation is mostly copy-paste. On Direct3D this is more involved, as we remove the second shader system and use core's shaders. I believe this should have similar hardware support to the old system, but is far simpler.
1 parent 8a8f962 commit c6d16f1

40 files changed

+2975
-4407
lines changed

‎addons/native_dialog/gtk_dialog.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <gtk/gtk.h>
22
#include <gdk/gdkx.h>
33

4+
#define ALLEGRO_INTERNAL_UNSTABLE
45
#include "allegro5/allegro.h"
56
#include "allegro5/allegro_native_dialog.h"
67
#include "allegro5/internal/aintern_native_dialog.h"

‎addons/primitives/CMakeLists.txt‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
set(PRIMITIVES_SOURCES
22
high_primitives.c
3-
line_soft.c
4-
point_soft.c
53
polygon.c
64
polyline.c
7-
prim_directx.cpp
8-
prim_opengl.c
95
prim_soft.c
106
prim_util.c
117
primitives.c
128
triangulator.c
139
)
1410

15-
if(WIN32)
16-
# Add this file conditionally.
17-
# The Debian folks want to remove it because it contains precompiled code.
18-
list(APPEND PRIMITIVES_SOURCES directx_shaders.cpp)
19-
endif(WIN32)
20-
2111
set(PRIMITIVES_INCLUDE_FILES allegro5/allegro_primitives.h)
2212

2313
set_our_header_properties(${PRIMITIVES_INCLUDE_FILES})

‎addons/primitives/allegro5/allegro_primitives.h‎

Lines changed: 1 addition & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define __al_included_allegro5_allegro_primitives_h
33

44
#include <allegro5/allegro.h>
5+
#include <allegro5/internal/aintern_primitives_types.h>
56

67
#if (defined ALLEGRO_MINGW32) || (defined ALLEGRO_MSVC) || (defined ALLEGRO_BCC32)
78
#ifndef ALLEGRO_STATICLINK
@@ -31,57 +32,6 @@ extern "C"
3132
#endif
3233

3334

34-
/* Enum: ALLEGRO_PRIM_TYPE
35-
*/
36-
typedef enum ALLEGRO_PRIM_TYPE
37-
{
38-
ALLEGRO_PRIM_LINE_LIST,
39-
ALLEGRO_PRIM_LINE_STRIP,
40-
ALLEGRO_PRIM_LINE_LOOP,
41-
ALLEGRO_PRIM_TRIANGLE_LIST,
42-
ALLEGRO_PRIM_TRIANGLE_STRIP,
43-
ALLEGRO_PRIM_TRIANGLE_FAN,
44-
ALLEGRO_PRIM_POINT_LIST,
45-
ALLEGRO_PRIM_NUM_TYPES
46-
} ALLEGRO_PRIM_TYPE;
47-
48-
enum
49-
{
50-
ALLEGRO_PRIM_MAX_USER_ATTR = _ALLEGRO_PRIM_MAX_USER_ATTR
51-
};
52-
53-
/* Enum: ALLEGRO_PRIM_ATTR
54-
*/
55-
typedef enum ALLEGRO_PRIM_ATTR
56-
{
57-
ALLEGRO_PRIM_POSITION = 1,
58-
ALLEGRO_PRIM_COLOR_ATTR,
59-
ALLEGRO_PRIM_TEX_COORD,
60-
ALLEGRO_PRIM_TEX_COORD_PIXEL,
61-
ALLEGRO_PRIM_USER_ATTR,
62-
ALLEGRO_PRIM_ATTR_NUM = ALLEGRO_PRIM_USER_ATTR + ALLEGRO_PRIM_MAX_USER_ATTR
63-
} ALLEGRO_PRIM_ATTR;
64-
65-
/* Enum: ALLEGRO_PRIM_STORAGE
66-
*/
67-
typedef enum ALLEGRO_PRIM_STORAGE
68-
{
69-
ALLEGRO_PRIM_FLOAT_2,
70-
ALLEGRO_PRIM_FLOAT_3,
71-
ALLEGRO_PRIM_SHORT_2,
72-
ALLEGRO_PRIM_FLOAT_1,
73-
ALLEGRO_PRIM_FLOAT_4,
74-
ALLEGRO_PRIM_UBYTE_4,
75-
ALLEGRO_PRIM_SHORT_4,
76-
ALLEGRO_PRIM_NORMALIZED_UBYTE_4,
77-
ALLEGRO_PRIM_NORMALIZED_SHORT_2,
78-
ALLEGRO_PRIM_NORMALIZED_SHORT_4,
79-
ALLEGRO_PRIM_NORMALIZED_USHORT_2,
80-
ALLEGRO_PRIM_NORMALIZED_USHORT_4,
81-
ALLEGRO_PRIM_HALF_FLOAT_2,
82-
ALLEGRO_PRIM_HALF_FLOAT_4
83-
} ALLEGRO_PRIM_STORAGE;
84-
8535
/* Enum: ALLEGRO_LINE_JOIN
8636
*/
8737
typedef enum ALLEGRO_LINE_JOIN
@@ -104,60 +54,11 @@ typedef enum ALLEGRO_LINE_CAP
10454
ALLEGRO_LINE_CAP_CLOSED
10555
} ALLEGRO_LINE_CAP;
10656

107-
/* Enum: ALLEGRO_PRIM_BUFFER_FLAGS
108-
*/
109-
typedef enum ALLEGRO_PRIM_BUFFER_FLAGS
110-
{
111-
ALLEGRO_PRIM_BUFFER_STREAM = 0x01,
112-
ALLEGRO_PRIM_BUFFER_STATIC = 0x02,
113-
ALLEGRO_PRIM_BUFFER_DYNAMIC = 0x04,
114-
ALLEGRO_PRIM_BUFFER_READWRITE = 0x08
115-
} ALLEGRO_PRIM_BUFFER_FLAGS;
116-
117-
/* Enum: ALLEGRO_VERTEX_CACHE_SIZE
118-
*/
119-
#define ALLEGRO_VERTEX_CACHE_SIZE 256
12057

12158
/* Enum: ALLEGRO_PRIM_QUALITY
12259
*/
12360
#define ALLEGRO_PRIM_QUALITY 10
12461

125-
/* Type: ALLEGRO_VERTEX_ELEMENT
126-
*/
127-
typedef struct ALLEGRO_VERTEX_ELEMENT ALLEGRO_VERTEX_ELEMENT;
128-
129-
struct ALLEGRO_VERTEX_ELEMENT {
130-
int attribute;
131-
int storage;
132-
int offset;
133-
};
134-
135-
/* Type: ALLEGRO_VERTEX_DECL
136-
*/
137-
typedef struct ALLEGRO_VERTEX_DECL ALLEGRO_VERTEX_DECL;
138-
139-
/* Duplicated in allegro5/internal/aintern_tri_soft.h */
140-
#ifndef _ALLEGRO_VERTEX_DEFINED
141-
#define _ALLEGRO_VERTEX_DEFINED
142-
143-
/* Type: ALLEGRO_VERTEX
144-
*/
145-
typedef struct ALLEGRO_VERTEX ALLEGRO_VERTEX;
146-
147-
struct ALLEGRO_VERTEX {
148-
float x, y, z;
149-
float u, v;
150-
ALLEGRO_COLOR color;
151-
};
152-
#endif
153-
154-
/* Type: ALLEGRO_VERTEX_BUFFER
155-
*/
156-
typedef struct ALLEGRO_VERTEX_BUFFER ALLEGRO_VERTEX_BUFFER;
157-
158-
/* Type: ALLEGRO_INDEX_BUFFER
159-
*/
160-
typedef struct ALLEGRO_INDEX_BUFFER ALLEGRO_INDEX_BUFFER;
16162

16263
ALLEGRO_PRIM_FUNC(uint32_t, al_get_allegro_primitives_version, (void));
16364

‎addons/primitives/allegro5/internal/aintern_prim.h‎ renamed to ‎addons/primitives/allegro5/internal/aintern_prim_addon.h‎

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
#ifndef __al_included_allegro5_aintern_prim_h
2-
#define __al_included_allegro5_aintern_prim_h
1+
#ifndef __al_included_allegro5_aintern_prim_addon_h
2+
#define __al_included_allegro5_aintern_prim_addon_h
3+
4+
#include <allegro5/internal/aintern_primitives_types.h>
35

46
#ifdef __cplusplus
57
extern "C" {
@@ -11,13 +13,6 @@ enum ALLEGRO_PRIM_VERTEX_CACHE_TYPE
1113
ALLEGRO_PRIM_VERTEX_CACHE_LINE_STRIP
1214
};
1315

14-
struct ALLEGRO_VERTEX_DECL {
15-
ALLEGRO_VERTEX_ELEMENT* elements;
16-
int stride;
17-
void* d3d_decl;
18-
void* d3d_dummy_shader;
19-
};
20-
2116
typedef struct ALLEGRO_PRIM_VERTEX_CACHE {
2217
ALLEGRO_VERTEX buffer[ALLEGRO_VERTEX_CACHE_SIZE];
2318
ALLEGRO_VERTEX* current;
@@ -27,31 +22,6 @@ typedef struct ALLEGRO_PRIM_VERTEX_CACHE {
2722
void* user_data;
2823
} ALLEGRO_PRIM_VERTEX_CACHE;
2924

30-
typedef struct ALLEGRO_BUFFER_COMMON {
31-
uintptr_t handle;
32-
bool write_only;
33-
/* In elements */
34-
int size;
35-
36-
bool is_locked;
37-
int lock_flags;
38-
void* locked_memory;
39-
/* These three are in bytes */
40-
int local_buffer_length;
41-
int lock_offset;
42-
int lock_length;
43-
} ALLEGRO_BUFFER_COMMON;
44-
45-
struct ALLEGRO_VERTEX_BUFFER {
46-
ALLEGRO_VERTEX_DECL* decl;
47-
ALLEGRO_BUFFER_COMMON common;
48-
};
49-
50-
struct ALLEGRO_INDEX_BUFFER {
51-
int index_size;
52-
ALLEGRO_BUFFER_COMMON common;
53-
};
54-
5525
/* Internal cache for primitives. */
5626
void _al_prim_cache_init(ALLEGRO_PRIM_VERTEX_CACHE* cache, int prim_type, ALLEGRO_COLOR color);
5727
void _al_prim_cache_init_ex(ALLEGRO_PRIM_VERTEX_CACHE* cache, int prim_type, ALLEGRO_COLOR color, void* user_data);
@@ -69,9 +39,6 @@ bool _al_prim_is_point_in_triangle(const float* point, const float* v0, con
6939
bool _al_prim_intersect_segment(const float* v0, const float* v1, const float* p0, const float* p1, float* point, float* t0, float* t1);
7040
bool _al_prim_are_points_equal(const float* point_a, const float* point_b);
7141

72-
int _al_bitmap_region_is_locked(ALLEGRO_BITMAP* bmp, int x1, int y1, int x2, int y2);
73-
int _al_draw_buffer_common_soft(ALLEGRO_VERTEX_BUFFER* vertex_buffer, ALLEGRO_BITMAP* texture, ALLEGRO_INDEX_BUFFER* index_buffer, int start, int end, int type);
74-
7542
#ifdef __cplusplus
7643
}
7744
#endif

‎addons/primitives/allegro5/internal/aintern_prim_opengl.h‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)