Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "al_get_render_state" #1583

Merged
merged 3 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs/src/refman/graphics.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2040,6 +2040,20 @@ Since: 5.1.2

See also: [al_set_render_state]


### API: al_get_render_state

Returns one of several render attributes; see [ALLEGRO_RENDER_STATE]
for details.

This function will return -1 when there is no current display.

Since: 5.2.10

See also: [al_set_render_state], [ALLEGRO_RENDER_STATE], [ALLEGRO_RENDER_FUNCTION],
[ALLEGRO_WRITE_MASK_FLAGS]


### API: al_set_render_state

Set one of several render attributes; see [ALLEGRO_RENDER_STATE]
Expand All @@ -2049,7 +2063,7 @@ This function does nothing if the target bitmap is a memory bitmap.

Since: 5.1.2

See also: [ALLEGRO_RENDER_STATE], [ALLEGRO_RENDER_FUNCTION],
See also: [al_get_render_state], [ALLEGRO_RENDER_STATE], [ALLEGRO_RENDER_FUNCTION],
[ALLEGRO_WRITE_MASK_FLAGS]


Expand Down
1 change: 1 addition & 0 deletions include/allegro5/render_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef enum ALLEGRO_WRITE_MASK_FLAGS {
ALLEGRO_MASK_RGBA = (ALLEGRO_MASK_RGB | ALLEGRO_MASK_ALPHA)
} ALLEGRO_WRITE_MASK_FLAGS;

AL_FUNC(int, al_get_render_state, (ALLEGRO_RENDER_STATE state));
AL_FUNC(void, al_set_render_state, (ALLEGRO_RENDER_STATE state, int value));

#ifdef __cplusplus
Expand Down
37 changes: 36 additions & 1 deletion src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,41 @@ void al_acknowledge_drawing_resume(ALLEGRO_DISPLAY *display)
}
}

/* Function: al_get_render_state
*/
int al_get_render_state(ALLEGRO_RENDER_STATE state)
{
ALLEGRO_DISPLAY *display = al_get_current_display();

if (!display)
return -1;

switch (state) {
case ALLEGRO_ALPHA_TEST:
return display->render_state.alpha_test;
break;
case ALLEGRO_WRITE_MASK:
return display->render_state.write_mask;
break;
case ALLEGRO_DEPTH_TEST:
return display->render_state.depth_test;
break;
case ALLEGRO_DEPTH_FUNCTION:
return display->render_state.depth_function;
break;
case ALLEGRO_ALPHA_FUNCTION:
return display->render_state.alpha_function;
break;
case ALLEGRO_ALPHA_TEST_VALUE:
return display->render_state.alpha_test_value;
break;
default:
ALLEGRO_ERROR("Unknown state to retrieve: %d\n", state);
return -1;
break;
}
}

/* Function: al_set_render_state
*/
void al_set_render_state(ALLEGRO_RENDER_STATE state, int value)
Expand Down Expand Up @@ -631,7 +666,7 @@ void al_set_render_state(ALLEGRO_RENDER_STATE state, int value)
display->render_state.alpha_test_value = value;
break;
default:
ALLEGRO_WARN("unknown state to change: %d\n", state);
ALLEGRO_WARN("Unknown state to change: %d\n", state);
break;
}

Expand Down
Loading