Screen background
This commit is contained in:
@@ -7,6 +7,8 @@ module('screen')
|
|||||||
module('time')
|
module('time')
|
||||||
|
|
||||||
camera = cameraCreate(CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC)
|
camera = cameraCreate(CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC)
|
||||||
|
text = "Hello World"
|
||||||
|
screenSetBackground(colorBlack())
|
||||||
|
|
||||||
function sceneDispose()
|
function sceneDispose()
|
||||||
end
|
end
|
||||||
@@ -14,7 +16,6 @@ end
|
|||||||
function sceneUpdate()
|
function sceneUpdate()
|
||||||
end
|
end
|
||||||
|
|
||||||
text = "Hello World"
|
|
||||||
|
|
||||||
function sceneRender()
|
function sceneRender()
|
||||||
cameraPushMatrix(camera)
|
cameraPushMatrix(camera)
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ errorret_t displayUpdate(void) {
|
|||||||
screenBind();
|
screenBind();
|
||||||
frameBufferClear(
|
frameBufferClear(
|
||||||
FRAMEBUFFER_CLEAR_COLOR | FRAMEBUFFER_CLEAR_DEPTH,
|
FRAMEBUFFER_CLEAR_COLOR | FRAMEBUFFER_CLEAR_DEPTH,
|
||||||
COLOR_CORNFLOWER_BLUE
|
SCREEN.background
|
||||||
);
|
);
|
||||||
errorChain(sceneRender());
|
errorChain(sceneRender());
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ screen_t SCREEN;
|
|||||||
void screenInit() {
|
void screenInit() {
|
||||||
memoryZero(&SCREEN, sizeof(screen_t));
|
memoryZero(&SCREEN, sizeof(screen_t));
|
||||||
|
|
||||||
|
SCREEN.background = COLOR_CORNFLOWER_BLUE;
|
||||||
|
|
||||||
#if DISPLAY_SIZE_DYNAMIC == 1
|
#if DISPLAY_SIZE_DYNAMIC == 1
|
||||||
SCREEN.mode = SCREEN_MODE_FIXED_VIEWPORT_HEIGHT;
|
SCREEN.mode = SCREEN_MODE_FIXED_VIEWPORT_HEIGHT;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "display/framebuffer.h"
|
#include "display/framebuffer.h"
|
||||||
#include "display/camera/camera.h"
|
#include "display/camera/camera.h"
|
||||||
#include "display/mesh/quad.h"
|
#include "display/mesh/quad.h"
|
||||||
|
#include "display/color.h"
|
||||||
|
|
||||||
#if DISPLAY_SIZE_DYNAMIC == 1
|
#if DISPLAY_SIZE_DYNAMIC == 1
|
||||||
#ifndef DISPLAY_SCREEN_HEIGHT_DEFAULT
|
#ifndef DISPLAY_SCREEN_HEIGHT_DEFAULT
|
||||||
@@ -44,6 +45,7 @@ typedef struct {
|
|||||||
int32_t width;
|
int32_t width;
|
||||||
int32_t height;
|
int32_t height;
|
||||||
float_t aspect;
|
float_t aspect;
|
||||||
|
color_t background;
|
||||||
|
|
||||||
#if DISPLAY_SIZE_DYNAMIC == 1
|
#if DISPLAY_SIZE_DYNAMIC == 1
|
||||||
framebuffer_t framebuffer;
|
framebuffer_t framebuffer;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ void moduleScreen(scriptcontext_t *context) {
|
|||||||
|
|
||||||
lua_register(context->luaState, "screenGetWidth", moduleScreenGetWidth);
|
lua_register(context->luaState, "screenGetWidth", moduleScreenGetWidth);
|
||||||
lua_register(context->luaState, "screenGetHeight", moduleScreenGetHeight);
|
lua_register(context->luaState, "screenGetHeight", moduleScreenGetHeight);
|
||||||
|
lua_register(context->luaState, "screenSetBackground", moduleScreenSetBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
int moduleScreenGetWidth(lua_State *L) {
|
int moduleScreenGetWidth(lua_State *L) {
|
||||||
@@ -27,3 +28,16 @@ int moduleScreenGetHeight(lua_State *L) {
|
|||||||
lua_pushinteger(L, SCREEN.height);
|
lua_pushinteger(L, SCREEN.height);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int moduleScreenSetBackground(lua_State *L) {
|
||||||
|
assertNotNull(L, "Lua state is null");
|
||||||
|
|
||||||
|
if(!lua_isuserdata(L, 1)) {
|
||||||
|
luaL_error(L, "Screen background color must be a color struct");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
color_t *color = (color_t*)luaL_checkudata(L, 1, "color_mt");
|
||||||
|
SCREEN.background = *color;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -30,3 +30,11 @@ int moduleScreenGetWidth(lua_State *L);
|
|||||||
* @return Count of return values.
|
* @return Count of return values.
|
||||||
*/
|
*/
|
||||||
int moduleScreenGetHeight(lua_State *L);
|
int moduleScreenGetHeight(lua_State *L);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the screen background color.
|
||||||
|
*
|
||||||
|
* @param L The Lua state.
|
||||||
|
* @return Count of return values.
|
||||||
|
*/
|
||||||
|
int moduleScreenSetBackground(lua_State *L);
|
||||||
Reference in New Issue
Block a user