mirror of
https://github.com/bjornbytes/lovr.git
synced 2024-07-03 21:13:42 +00:00
Allow Canvases to be used as Textures sometimes;
This commit is contained in:
parent
36ec69e244
commit
6b87a71261
|
@ -121,3 +121,4 @@ int luax_pushvariant(lua_State* L, Variant* variant);
|
||||||
int luax_checkuniform(lua_State* L, int index, const Uniform* uniform, void* dest, const char* debug);
|
int luax_checkuniform(lua_State* L, int index, const Uniform* uniform, void* dest, const char* debug);
|
||||||
void luax_checkuniformtype(lua_State* L, int index, UniformType* baseType, int* components);
|
void luax_checkuniformtype(lua_State* L, int index, UniformType* baseType, int* components);
|
||||||
int luax_optmipmap(lua_State* L, int index, Texture* texture);
|
int luax_optmipmap(lua_State* L, int index, Texture* texture);
|
||||||
|
Texture* luax_checktexture(lua_State* L, int index);
|
||||||
|
|
|
@ -829,7 +829,7 @@ int l_lovrGraphicsSphere(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int l_lovrGraphicsSkybox(lua_State* L) {
|
int l_lovrGraphicsSkybox(lua_State* L) {
|
||||||
Texture* texture = luax_checktype(L, 1, Texture);
|
Texture* texture = luax_checktexture(L, 1);
|
||||||
float angle = luaL_optnumber(L, 2, 0);
|
float angle = luaL_optnumber(L, 2, 0);
|
||||||
float ax = luaL_optnumber(L, 3, 0);
|
float ax = luaL_optnumber(L, 3, 0);
|
||||||
float ay = luaL_optnumber(L, 4, 1);
|
float ay = luaL_optnumber(L, 4, 1);
|
||||||
|
@ -864,7 +864,7 @@ int l_lovrGraphicsStencil(lua_State* L) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int l_lovrGraphicsFill(lua_State* L) {
|
int l_lovrGraphicsFill(lua_State* L) {
|
||||||
Texture* texture = lua_isnoneornil(L, 1) ? NULL : luax_checktype(L, 1, Texture);
|
Texture* texture = lua_isnoneornil(L, 1) ? NULL : luax_checktexture(L, 1);
|
||||||
lovrGraphicsFill(texture);
|
lovrGraphicsFill(texture);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1005,7 +1005,7 @@ int l_lovrGraphicsNewMaterial(lua_State* L) {
|
||||||
lovrRelease(textureData);
|
lovrRelease(textureData);
|
||||||
lovrRelease(texture);
|
lovrRelease(texture);
|
||||||
} else if (lua_isuserdata(L, index)) {
|
} else if (lua_isuserdata(L, index)) {
|
||||||
Texture* texture = luax_checktype(L, index, Texture);
|
Texture* texture = luax_checktexture(L, index);
|
||||||
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, texture);
|
lovrMaterialSetTexture(material, TEXTURE_DIFFUSE, texture);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,16 @@
|
||||||
#include "graphics/canvas.h"
|
#include "graphics/canvas.h"
|
||||||
#include "graphics/graphics.h"
|
#include "graphics/graphics.h"
|
||||||
|
|
||||||
|
Texture* luax_checktexture(lua_State* L, int index) {
|
||||||
|
Canvas* canvas = luax_totype(L, index, Canvas);
|
||||||
|
if (canvas) {
|
||||||
|
const Attachment* attachment = lovrCanvasGetAttachments(canvas, NULL);
|
||||||
|
return attachment->texture;
|
||||||
|
} else {
|
||||||
|
return luax_checktype(L, index, Texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int luax_checkattachment(lua_State* L, int index, Attachment* attachment) {
|
static int luax_checkattachment(lua_State* L, int index, Attachment* attachment) {
|
||||||
attachment->texture = luax_checktype(L, index++, Texture);
|
attachment->texture = luax_checktype(L, index++, Texture);
|
||||||
attachment->slice = lua_type(L, index) == LUA_TNUMBER ? lua_tointeger(L, index++) - 1 : 0;
|
attachment->slice = lua_type(L, index) == LUA_TNUMBER ? lua_tointeger(L, index++) - 1 : 0;
|
||||||
|
|
|
@ -57,7 +57,7 @@ int l_lovrMaterialSetTexture(lua_State* L) {
|
||||||
textureType = luaL_checkoption(L, index, NULL, MaterialTextures);
|
textureType = luaL_checkoption(L, index, NULL, MaterialTextures);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
Texture* texture = lua_isnoneornil(L, index) ? NULL : luax_checktype(L, index, Texture);
|
Texture* texture = lua_isnoneornil(L, index) ? NULL : luax_checktexture(L, index);
|
||||||
lovrMaterialSetTexture(material, textureType, texture);
|
lovrMaterialSetTexture(material, textureType, texture);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -538,7 +538,7 @@ static void lovrGpuUseProgram(uint32_t program) {
|
||||||
static void lovrGpuSetViewports(float viewports[][4], int viewportCount, int index) {
|
static void lovrGpuSetViewports(float viewports[][4], int viewportCount, int index) {
|
||||||
#ifdef GL_ARB_viewport_array
|
#ifdef GL_ARB_viewport_array
|
||||||
if (state.supportsSinglepass) {
|
if (state.supportsSinglepass) {
|
||||||
glViewportArrayv(0, viewportCount, viewports);
|
glViewportArrayv(0, viewportCount, &viewports[0][0]);
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
glViewport(viewports[index][0], viewports[index][1], viewports[index][2], viewports[index][3]);
|
glViewport(viewports[index][0], viewports[index][1], viewports[index][2], viewports[index][3]);
|
||||||
|
|
Loading…
Reference in a new issue