Create material using correct texture source.
This commit is contained in:
@@ -23,7 +23,7 @@ if( EMSCRIPTEN ) # Web
|
||||
target_link_libraries( ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/lib/web/liblua.a )
|
||||
|
||||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY" )
|
||||
set( CMAKE_EXECUTABLE_SUFFIX ".html" ) # This line is used to set your executable to build with the emscripten html template so taht you can directly open it.
|
||||
set( CMAKE_EXECUTABLE_SUFFIX ".html" ) # This line is used to set your executable to build with the emscripten html template so that you can directly open it.
|
||||
set( resources_dir "resources" )
|
||||
set_target_properties( ${PROJECT_NAME} PROPERTIES LINK_FLAGS "--preload-file ${resources_dir}" )
|
||||
else() # Desktop
|
||||
@@ -54,6 +54,7 @@ else() # Desktop
|
||||
target_link_libraries( ${PROJECT_NAME} "-framework Cocoa" )
|
||||
target_link_libraries( ${PROJECT_NAME} "-framework OpenGL" )
|
||||
elseif( WIN32 )
|
||||
set( CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-mwindows" )
|
||||
target_link_libraries( ${PROJECT_NAME} mingw32 opengl32 gdi32 winmm )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -215,7 +215,7 @@ ReiLua
|
||||
||\main.lua
|
||||
```
|
||||
|
||||
We can now build the game. You can use the command it top of the "CMakeLists.txt" to use emsdk toolchain with cmake. Remember to replace \<YOUR PATH HERE> with correct path.
|
||||
We can now build the game. You can use the command in the top of the "CMakeLists.txt" to use emsdk toolchain with cmake. Remember to replace \<YOUR PATH HERE> with correct path.
|
||||
|
||||
```
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=<YOUR PATH HERE>/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DPLATFORM=Web
|
||||
|
||||
2
devnotes
2
devnotes
@@ -2,6 +2,8 @@ Current {
|
||||
}
|
||||
|
||||
Backlog {
|
||||
* Audio
|
||||
* Pan (From newer RayLib).
|
||||
* Text
|
||||
* Codepoints
|
||||
* String management. At least TextSplit.
|
||||
|
||||
@@ -36,7 +36,7 @@ function process( delta )
|
||||
cameraPos[2] = cameraPos[2] - cameraSpeed * delta
|
||||
end
|
||||
-- Rotate.
|
||||
if RL_IsKeyDown( string.byte( "E" ) ) then
|
||||
if RL_IsKeyDown( string.byte( "E" ) ) then -- Or RL_IsKeyDown( KEY_E )
|
||||
cameraRot = cameraRot + cameraRotSpeed * delta
|
||||
elseif RL_IsKeyDown( string.byte( "Q" ) ) then
|
||||
cameraRot = cameraRot - cameraRotSpeed * delta
|
||||
|
||||
@@ -34,7 +34,7 @@ function init()
|
||||
textImage = RL_ImageText( 0, "Cat", 10, 4, WHITE )
|
||||
local imageSize = RL_GetImageSize( textImage )
|
||||
RL_ImageDraw( image, textImage, { 0, 0, imageSize[1], imageSize[2] }, { 250, 40, imageSize[1], imageSize[2] }, WHITE )
|
||||
|
||||
|
||||
texture = RL_LoadTextureFromImage( image )
|
||||
end
|
||||
|
||||
|
||||
@@ -49,6 +49,11 @@ local player = {
|
||||
facing = 1,
|
||||
}
|
||||
|
||||
local kissa = { Vec2:new( 2, 4 ), 23 }
|
||||
|
||||
-- print( table.concat( kissa ) )
|
||||
print( kissa[1] )
|
||||
|
||||
local function createMap()
|
||||
for x = 1, tilemap.size.x do
|
||||
table.insert( tilemap.tiles, {} )
|
||||
|
||||
@@ -331,7 +331,7 @@ int lcoreSetWindowState( lua_State *L ) {
|
||||
}
|
||||
|
||||
/*
|
||||
> state = RL_IsWindowState( int flag ) )
|
||||
> state = RL_IsWindowState( int flag )
|
||||
|
||||
Check if one specific window flag is enabled ( FLAG_FULLSCREEN_MODE, FLAG_WINDOW_RESIZABLE... )
|
||||
|
||||
|
||||
@@ -1554,7 +1554,13 @@ int lmodelsCreateMaterial( lua_State *L ) {
|
||||
|
||||
while ( lua_next( L, t4 ) != 0 ) {
|
||||
if ( strcmp( "texture", (char*)lua_tostring( L, -2 ) ) == 0 && lua_isnumber( L, -1 ) ) {
|
||||
state->materials[i]->maps[map].texture = *state->textures[ lua_tointeger( L, -1 ) ];
|
||||
size_t texId = lua_tointeger( L, -1 );
|
||||
|
||||
if ( !validSourceTexture( texId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
state->materials[i]->maps[map].texture = *texturesGetSourceTexture( texId );
|
||||
}
|
||||
else if ( strcmp( "color", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) {
|
||||
state->materials[i]->maps[map].color = uluaGetColor( L );
|
||||
|
||||
@@ -1285,7 +1285,7 @@ Get image pixel color at ( x, y ) position
|
||||
- Success return Color
|
||||
*/
|
||||
int ltexturesGetImageColor( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
|
||||
if ( !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GetImageColor( Image image, Vector2 pixelPos )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user