raylib headers

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
paul doe
Posts: 1175
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: raylib headers

Postby paul doe » Mar 11, 2020 3:23

Hey, no prob ;)

Ported the rlights.h header, to port some examples that need it (namely, models_material_pbr.c). However, all I've got was a white screen. So, I tested the C example and alas, same thing. There are other weirdness, too:
Image Image

FreeBasic port above, original C code below (models_skybox.c). I wonder if the author changed something, and/or the repo I downloaded (2.6) is broken somehow? Mmmm...

Ported also some other 3D examples and they're fine, so I think that the shaders are giving me these results. Can you confirm, please?
Last edited by paul doe on Mar 11, 2020 3:35, edited 1 time in total.
paul doe
Posts: 1175
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: raylib headers

Postby paul doe » Mar 11, 2020 3:30

The ported skybox example. Interestingly enough, the grid isn't displayed here:

Code: Select all

/'
  ********************************************************************************************
  *
  *   raylib [models] example - Skybox loading and drawing
  *
  *   This example has been created using raylib 1.8 (www.raylib.com)
  *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  *
  *   Copyright (c) 2017 Ramon Santamaria (@raysan5)
  *
  ********************************************************************************************
'/
#include "../raylib.bi"

const as integer _
  screenWidth => 800, _
  screenHeight => 450
const as string _
  resPath => "../resources/models/"

InitWindow( _
  screenWidth, _
  screenHeight, _
  "raylib [models] example - skybox loading and drawing" )

'' Define the camera to look into our 3d world
dim as Camera _
  camera

with camera
  .position => Vector3( 1.0!, 1.0!, 1.0! )
  .target => Vector3( 4.0!, 1.0!, 4.0! )
  .up => Vector3( 0.0!, 1.0!, 0.0! )
  .fovy => 45.0!
  .type => 0
end with

'' Load skybox model
dim as Mesh _
  cube => GenMeshCube( 1.0!, 1.0!, 1.0! )

dim as Model _
  skybox => LoadModelFromMesh( cube )

/'
  Load skybox shader and set required locations
  NOTE: Some locations are automatically set at shader loading
'/
skybox.materials[ 0 ].shader => LoadShader( _
  resPath + "shaders/glsl330/skybox.vs", _
  resPath + "shaders/glsl330/skybox.fs" )

dim as long _
  map => MAP_CUBEMAP

SetShaderValue( _
  skybox.materials[ 0 ].shader, _
  GetShaderLocation( _
    skybox.materials[ 0 ].shader, _
    "environmentMap" ), _
  @map, UNIFORM_INT )

'' Load cubemap shader and setup required shader locations
dim as Shader _
  shdrCubemap => LoadShader( _
    resPath + "shaders/glsl330/cubemap.vs", _
    resPath + "shaders/glsl330/cubemap.fs" )

dim as long _
  zero => 0

SetShaderValue( _
  shdrCubemap, _
  GetShaderLocation( shdrCubemap, "equirectangularMap" ), _
  @zero, UNIFORM_INT )

'' Load HDR panorama (sphere) texture
dim as Texture2D _
  texHDR => LoadTexture( resPath + "dresden_square.hdr" )

/'
  Generate cubemap (texture with 6 quads-cube-mapping) from panorama HDR texture
  NOTE: New texture is generated rendering to texture, shader computes the sphre->cube coordinates mapping
'/
skybox.materials[ 0 ].maps[ MAP_CUBEMAP ].texture => GenTextureCubemap( shdrCubemap, texHDR, 512 )

'' Texture not required anymore, cubemap already generated
UnloadTexture( texHDR )   
'' Unload cubemap generation shader, not required anymore
UnloadShader( shdrCubemap )

SetCameraMode( camera, CAMERA_FIRST_PERSON )

SetTargetFPS( 60 )

do while( not WindowShouldClose() )
  '' Update
  UpdateCamera( @camera )

  '' Draw
  BeginDrawing()
    ClearBackground( RAYWHITE )
 
    BeginMode3D( camera )
      DrawModel( skybox, Vector3( 0, 0, 0 ), 1.0!, WHITE )
      DrawGrid( 10, 1.0! )
    EndMode3D()
   
    DrawFPS( 10, 10 )
  EndDrawing()
loop

UnloadShader( skybox.materials[ 0 ].shader )
UnloadTexture( skybox.materials[ 0 ].maps[ MAP_CUBEMAP ].texture )

UnloadModel( skybox )

CloseWindow()
paul doe
Posts: 1175
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: raylib headers

Postby paul doe » Mar 11, 2020 3:34

And this is the ported models_material_pbr example:

Code: Select all

/'
  ********************************************************************************************
  *
  *   raylib [models] example - PBR material
  *
  *   This example has been created using raylib 1.8 (www.raylib.com)
  *   raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  *
  *   Copyright (c) 2017 Ramon Santamaria (@raysan5)
  *
  ********************************************************************************************
'/
#include once "../raylib.bi"
#include once "../raymath.bi"

#define RLIGHTS_IMPLEMENTATION
#include "../rlights.bi"

#define CUBEMAP_SIZE     512 '' Cubemap texture size
#define IRRADIANCE_SIZE  32  '' Irradiance texture size
#define PREFILTERED_SIZE 256 '' Prefiltered HDR environment texture size
#define BRDF_SIZE        512 '' BRDF LUT texture size

'' PBR material loading
declare function _
  LoadMaterialPBR( _
    byref albedo as Color, _
    byval metalness as single, _
    byval roughness as single ) _
  as Material

const as integer _
  screenWidth => 800, _
  screenHeight => 450

const as string _
  resPath => "../resources/models/"

'' Enable Multi Sampling Anti Aliasing 4x (if available)
SetConfigFlags( FLAG_MSAA_4X_HINT )

InitWindow( _
  screenWidth, _
  screenHeight, _
  "raylib [models] example - pbr material" )

'' Define the camera to look into our 3d world
dim as Camera _
  camera

with camera
  .position => Vector3( 4.0!, 4.0!, 4.0! )    '' Camera position
  .target => Vector3( 0.0!, 0.5!, 0.0! )      '' Camera looking at point
  .up => Vector3( 0.0!, 1.0!, 0.0! )          '' Camera up vector (rotation towards target)
  .fovy => 45.0!                              '' Camera field-of-view Y
  .type => CAMERA_PERSPECTIVE                 '' Camera mode type
end with

'' Load model and PBR material
dim as Model _
  model => LoadModel( resPath + "pbr/trooper.obj" )

/'
  Mesh tangents are generated... and uploaded to GPU
  NOTE: New VBO for tangents is generated at default location and also binded to mesh VAO
'/
MeshTangents( @model.meshes[ 0 ] )

UnloadMaterial( model.materials[ 0 ] ) '' get rid of default material

model.materials[ 0 ] => LoadMaterialPBR( _
  Color( 255, 255, 255, 255 ), 1.0!, 1.0! )

/'
  Create lights
  NOTE: Lights are added to an internal lights pool automatically
'/
CreateLight( _
  LIGHT_POINT, _
  Vector3( LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0! ), _
  Vector3( 0.0!, 0.0!, 0.0! ), _
  Color( 255, 0, 0, 255 ), _
  model.materials[ 0 ].shader )
CreateLight( _
  LIGHT_POINT, _
  Vector3( 0.0!, LIGHT_HEIGHT, LIGHT_DISTANCE ), _
  Vector3( 0.0!, 0.0!, 0.0! ), _
  Color( 0, 255, 0, 255 ), _
  model.materials[ 0 ].shader )
CreateLight( _
  LIGHT_POINT, _
  Vector3( -LIGHT_DISTANCE, LIGHT_HEIGHT, 0.0! ), _
  Vector3( 0.0!, 0.0!, 0.0! ), _
  Color( 0, 0, 255, 255 ), _
  model.materials[ 0 ].shader )
CreateLight( _
  LIGHT_DIRECTIONAL, _
  Vector3( 0.0!, LIGHT_HEIGHT * 2.0!, -LIGHT_DISTANCE ), _
  Vector3( 0.0!, 0.0!, 0.0! ), _
  Color( 255, 0, 255, 255 ), _
  model.materials[ 0 ].shader )

'' Set an orbital camera mode
SetCameraMode( camera, CAMERA_ORBITAL )

SetTargetFPS( 60 )

do while( not WindowShouldClose() )
  UpdateCamera( @camera )
 
  '' Send to material PBR shader camera view position
  dim as single _
    cameraPos( 0 to 2 ) => { _
      camera.position.x, _
      camera.position.y, _
      camera.position.z }
   
  SetShaderValue( _
    model.materials[ 0 ].shader, _
    model.materials[ 0 ].shader.locs[ LOC_VECTOR_VIEW ], _
    @cameraPos( 0 ), _
    UNIFORM_VEC3 )
 
  '' Render
  BeginDrawing()
  ClearBackground( RAYWHITE )
 
  BeginMode3D( camera )
 
  DrawModel( model, Vector3Zero(), 1.0!, WHITE )
  DrawGrid( 10, 1.0! )
 
  EndMode3D()
 
  DrawFPS( 10, 10 )
 
  EndDrawing()
loop

'' Shaders and textures must be unloaded by user,
'' they could be in use by other models
with model
  UnloadTexture( .materials[ 0 ].maps[ MAP_ALBEDO ].texture )
  UnloadTexture( .materials[ 0 ].maps[ MAP_NORMAL ].texture )
  UnloadTexture( .materials[ 0 ].maps[ MAP_METALNESS ].texture )
  UnloadTexture( .materials[ 0 ].maps[ MAP_ROUGHNESS ].texture )
  UnloadTexture( .materials[ 0 ].maps[ MAP_OCCLUSION ].texture )
  UnloadTexture( .materials[ 0 ].maps[ MAP_IRRADIANCE ].texture )
  UnloadTexture( .materials[ 0 ].maps[ MAP_PREFILTER ].texture )
  UnloadTexture( .materials[ 0 ].maps[ MAP_BRDF ].texture )
  UnloadShader( .materials[ 0 ].shader )
end with

UnloadModel(model)

CloseWindow()

/'
  Load PBR material (Supports: ALBEDO, NORMAL, METALNESS, ROUGHNESS, AO, EMMISIVE, HEIGHT maps).
 
  NOTE: PBR shader is loaded inside this function.
'/
function _
  LoadMaterialPBR( _
    byref albedo as Color, _
    byval metalness as single, _
    byval roughness as single ) _
  as Material
 
  '' Initialize material to default
  dim as Material _
    mat
 
  mat => LoadMaterialDefault()
 
  #if defined( PLATFORM_DESKTOP )
    mat.shader => LoadShader( _
      resPath + "shaders/glsl330/pbr.vs", _
      resPath + "shaders/glsl330/pbr.fs" )
  #else   '' PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
    mat.shader => LoadShader( _
      resPath + "shaders/glsl100/pbr.vs", _
      resPath + "shaders/glsl100/pbr.fs" )
  #endif
 
  /'
    Get required locations points for PBR material.
   
    NOTE: Those location names must be available and used in the shader code.
  '/
  with mat.shader
    .locs[ LOC_MAP_ALBEDO ] => GetShaderLocation( mat.shader, "albedo.sampler" )
    .locs[ LOC_MAP_METALNESS ] => GetShaderLocation( mat.shader, "metalness.sampler" )
    .locs[ LOC_MAP_NORMAL ] => GetShaderLocation( mat.shader, "normals.sampler" )
    .locs[ LOC_MAP_ROUGHNESS ] => GetShaderLocation( mat.shader, "roughness.sampler" )
    .locs[ LOC_MAP_OCCLUSION ] => GetShaderLocation( mat.shader, "occlusion.sampler" )
    .locs[ LOC_MAP_IRRADIANCE ] => GetShaderLocation( mat.shader, "irradianceMap" )
    .locs[ LOC_MAP_PREFILTER ] => GetShaderLocation( mat.shader, "prefilterMap" )
    .locs[ LOC_MAP_BRDF ] => GetShaderLocation( mat.shader, "brdfLUT" )
   
    '' Set view matrix location
    .locs[ LOC_MATRIX_MODEL ] => GetShaderLocation( mat.shader, "matModel" )
    .locs[ LOC_VECTOR_VIEW ] => GetShaderLocation( mat.shader, "viewPos" )
  end with
 
  '' Set PBR standard maps
  with mat
    .maps[ MAP_ALBEDO ].texture => LoadTexture( _
      resPath + "pbr/trooper_albedo.png" )
    .maps[ MAP_NORMAL ].texture => LoadTexture( _
      resPath + "pbr/trooper_normals.png" )
    .maps[ MAP_METALNESS ].texture => LoadTexture( _
      resPath + "pbr/trooper_metalness.png" )
    .maps[ MAP_ROUGHNESS ].texture => LoadTexture( _
      resPath + "pbr/trooper_roughness.png" )
    .maps[ MAP_OCCLUSION ].texture => LoadTexture( _
      resPath + "pbr/trooper_ao.png" )
  end with
 
  '' Load equirectangular to cubemap shader
  #if defined( PLATFORM_DESKTOP )
    dim as Shader _
      shdrCubemap => LoadShader( _
        resPath + "shaders/glsl330/cubemap.vs", _
        resPath + "shaders/glsl330/cubemap.fs" )
  #else '' PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
    dim as Shader _
      shdrCubemap => LoadShader( _
        resPath + "shaders/glsl100/cubemap.vs", _
        resPath + "shaders/glsl100/cubemap.fs" )
  #endif
 
  '' Load irradiance (GI) calculation shader
  #if defined( PLATFORM_DESKTOP )
    dim as Shader _
      shdrIrradiance => LoadShader( _
        resPath + "shaders/glsl330/skybox.vs", _
        resPath + "shaders/glsl330/irradiance.fs" )
  #else '' PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
    dim as Shader _
      shdrIrradiance => LoadShader( _
        resPath + "shaders/glsl100/skybox.vs", _
        resPath + "shaders/glsl100/irradiance.fs" )
  #endif
 
  '' Load reflection prefilter calculation shader
  #if defined( PLATFORM_DESKTOP )
    dim as Shader _
      shdrPrefilter => LoadShader( _
        resPath + "shaders/glsl330/skybox.vs", _
        resPath + "shaders/glsl330/prefilter.fs" )
  #else
    dim as Shader _
      shdrPrefilter => LoadShader( _
        resPath + "shaders/glsl100/skybox.vs", _
        resPath + "shaders/glsl100/prefilter.fs" )
  #endif
 
  '' Load bidirectional reflectance distribution function shader
  #if defined( PLATFORM_DESKTOP )
    dim as Shader _
      shdrBRDF => LoadShader( _
        resPath + "shaders/glsl330/brdf.vs", _
        resPath + "shaders/glsl330/brdf.fs" )
  #else
    dim as Shader _
      shdrBRDF => LoadShader( _
        resPath + "shaders/glsl100/brdf.vs", _
        resPath + "shaders/glsl100/brdf.fs" )
  #endif
 
  dim as long _
    zero => 0, _
    one => 1
 
  '' Setup required shader locations
  SetShaderValue( _
    shdrCubemap, GetShaderLocation( _
      shdrCubemap, "equirectangularMap" ), _
    @zero, UNIFORM_INT)
  SetShaderValue( _
    shdrIrradiance, GetShaderLocation( _
      shdrIrradiance, "environmentMap" ), _
    @zero, UNIFORM_INT)
  SetShaderValue( _
    shdrPrefilter, GetShaderLocation( _
      shdrPrefilter, "environmentMap" ), _
    @zero, UNIFORM_INT )
 
  dim as Texture2D _
    texHDR => LoadTexture( resPath + "dresden_square.hdr" )
  dim as Texture2D _
    cubemap => GenTextureCubemap( _
      shdrCubemap, texHDR, CUBEMAP_SIZE )
   
  with mat
    .maps[ MAP_IRRADIANCE ].texture => GenTextureIrradiance( _
      shdrIrradiance, cubemap, IRRADIANCE_SIZE )
    .maps[ MAP_PREFILTER ].texture => GenTexturePrefilter( _
      shdrPrefilter, cubemap, PREFILTERED_SIZE )
    .maps[ MAP_BRDF ].texture => GenTextureBRDF( _
      shdrBRDF, BRDF_SIZE )
  end with
 
  UnloadTexture( cubemap )
  UnloadTexture( texHDR )

  '' Unload already used shaders (to create specific textures)
  UnloadShader( shdrCubemap )
  UnloadShader( shdrIrradiance )
  UnloadShader( shdrPrefilter )
  UnloadShader( shdrBRDF )
 
  with mat
    '' Set textures filtering for better quality
    SetTextureFilter( _
      .maps[ MAP_ALBEDO ].texture, FILTER_BILINEAR )
    SetTextureFilter( _
      .maps[ MAP_NORMAL ].texture, FILTER_BILINEAR )
    SetTextureFilter( _
      .maps[ MAP_METALNESS ].texture, FILTER_BILINEAR )
    SetTextureFilter( _
      .maps[ MAP_ROUGHNESS ].texture, FILTER_BILINEAR )
    SetTextureFilter( _
      .maps[ MAP_OCCLUSION ].texture, FILTER_BILINEAR )
   
    '' Enable sample usage in shader for assigned textures
    SetShaderValue( _
      .shader, GetShaderLocation( _
        .shader, "albedo.useSampler" ), _
      @one, UNIFORM_INT )
    SetShaderValue( _
      .shader, GetShaderLocation( _
        .shader, "normals.useSampler" ), _
      @one, UNIFORM_INT )
    SetShaderValue( _
      .shader, GetShaderLocation( _
        .shader, "metalness.useSampler" ), _
      @one, UNIFORM_INT )
    SetShaderValue( _
      .shader, GetShaderLocation( _
        .shader, "roughness.useSampler" ), _
      @one, UNIFORM_INT )
    SetShaderValue( _
      .shader, GetShaderLocation( _
        .shader, "occlusion.useSampler" ), _
      @one, UNIFORM_INT)
   
    dim as long _
      renderModeLoc => GetShaderLocation( .shader, "renderMode" )
   
    SetShaderValue( _
      .shader, renderModeLoc, @zero, UNIFORM_INT )
 
    '' Set up material properties color
    .maps[ MAP_ALBEDO ].color => albedo
    .maps[ MAP_NORMAL ].color => Color( 128, 128, 255, 255 )
    .maps[ MAP_METALNESS ].value => metalness
    .maps[ MAP_ROUGHNESS ].value => roughness
    .maps[ MAP_OCCLUSION ].value => 1.0!
    .maps[ MAP_EMISSION ].value => 0.5!
    .maps[ MAP_HEIGHT ].value => 0.5!
  end with
 
  return( mat )
end function


rlights.bi

Code: Select all

/'
  ***********************************************************************************************
  *
  *   raylib.lights - Some useful functions to deal with lights data
  *
  *   CONFIGURATION:
  *
  *   #define RLIGHTS_IMPLEMENTATION
  *       Generates the implementation of the library into the included file.
  *       If not defined, the library is in header only mode and can be included in other headers
  *       or source files without problems. But only ONE file should hold the implementation.
  *
  *   LICENSE: zlib/libpng
  *
  *   Copyright (c) 2017 Victor Fisac and Ramon Santamaria
  *
  *   This software is provided "as-is", without any express or implied warranty. In no event
  *   will the authors be held liable for any damages arising from the use of this software.
  *
  *   Permission is granted to anyone to use this software for any purpose, including commercial
  *   applications, and to alter it and redistribute it freely, subject to the following restrictions:
  *
  *     1. The origin of this software must not be misrepresented; you must not claim that you
  *     wrote the original software. If you use this software in a product, an acknowledgment
  *     in the product documentation would be appreciated but is not required.
  *
  *     2. Altered source versions must be plainly marked as such, and must not be misrepresented
  *     as being the original software.
  *
  *     3. This notice may not be removed or altered from any source distribution.
  *
  **********************************************************************************************
'/
#ifndef RLIGHTS_H
#define RLIGHTS_H

#include once "raylib.bi"

/'
  Defines and Macros
'/
#define MAX_LIGHTS     4    '' Max lights supported by shader
#define LIGHT_DISTANCE 3.5! '' Light distance from world center
#define LIGHT_HEIGHT   1.0! '' Light height position

/'
  Types and Structures Definition
'/
enum _
  LightType
 
  LIGHT_DIRECTIONAL
  LIGHT_POINT
end enum

type _
  Light
 
  as boolean _
    enabled
  as LightType _
    type
  as Vector3 _
    position, _
    target
  as Color _
    color
  as long _
    enabledLoc, _
    typeLoc, _
    posLoc, _
    targetLoc, _
    colorLoc
end type

extern "C" '' Prevents name mangling of functions
  /'
    Module Functions Declaration
  '/
  '' Defines a light and get locations from PBR shader
  declare sub _
    CreateLight( _
      byval _type as long, byref _pos as Vector3, byref targ as Vector3, byref _color as Color, byref _shader as Shader )
   
  '' Send to PBR shader light values
  declare sub _
    UpdateLightValues( byref _shader as Shader, byref _light as Light )
end extern

#endif '' RLIGHTS_H

/'
  ************************************************************************************
  *
  *   RLIGHTS IMPLEMENTATION
  *
  ************************************************************************************/
'/
#if defined( RLIGHTS_IMPLEMENTATION )

#include once "raylib.bi"

dim shared as Light _
  lights( MAX_LIGHTS )

'' Current amount of created lights
dim shared as long _
  lightsCount => 0

extern "C"

'' Defines a light and get locations from PBR shader
sub _
  CreateLight( _
    byval _type as long, _
    byref _pos as Vector3, _
    byref targ as Vector3, _
    byref _color as Color, _
    byref _shader as Shader )
   
  dim as Light _
    _light
 
  if( lightsCount < MAX_LIGHTS ) then
    with _light
      .enabled => true
      .type => _type
      .position => _pos
      .target => targ
      .color => _color
    end with
   
    dim as string _
      enabledName => "lights[" & lightsCount & "].enabled", _
      typeName => "lights[" & lightsCount & "].type", _
      posName => "lights[" & lightsCount & "].position", _
      targetName => "lights[" & lightsCount & "].target", _
      colorName => "lights[" & lightsCount & "].color"
   
    with _light
      .enabledLoc => GetShaderLocation( _shader, strPtr( enabledName ) )
      .typeLoc => GetShaderLocation( _shader, strPtr( typeName ) )
      .posLoc => GetShaderLocation( _shader, strPtr( posName ) )
      .targetLoc => GetShaderLocation( _shader, strPtr( targetName ) )
      .colorLoc => GetShaderLocation( _shader, strPtr( colorName ) )
    end with
   
    UpdateLightValues( _shader, _light )
   
    lights( lightsCount ) => _light
    lightsCount +=> 1
  end if
end sub

'' Send to PBR shader light values
sub _
  UpdateLightValues( _
    byref _shader as Shader, _
    byref _light as Light )
   
  '' Send to shader light enabled state and type
  SetShaderValue( _shader, _light.enabledLoc, @_light.enabled, UNIFORM_INT )
  SetShaderValue( _shader, _light.typeLoc, @_light.type, UNIFORM_INT )

  '' Send to shader light position values
  dim as single _
    position( 0 to 2 ) => { _
      _light.position.x, _
      _light.position.y, _
      _light.position.z }
  SetShaderValue( _shader, _light.posLoc, @position( 0 ), UNIFORM_VEC3 )

  '' Send to shader light target position values
  dim as single _
    target( 0 to 2 ) => { _
      _light.target.x, _
      _light.target.y, _
      _light.target.z }
  SetShaderValue( _shader, _light.targetLoc, @target( 0 ), UNIFORM_VEC3 )

  '' Send to shader light color values
  dim as single _
    diff( 0 to 3 ) => { _
      _light.color.r / 255, _
      _light.color.g / 255, _
      _light.color.b / 255, _
      _light.color.a / 255 }
  SetShaderValue( _shader, _light.colorLoc, @diff( 0 ), UNIFORM_VEC4 )
end sub

end extern

#endif '' RLIGHTS_IMPLEMENTATION

It needs the above header to run.
D.J.Peters
Posts: 8023
Joined: May 28, 2005 3:28
Contact:

Re: raylib headers

Postby D.J.Peters » Mar 11, 2020 19:26

On windows the *.dll's wasn't linked with the "-static-libgcc" linker flag so the mingw gcc runtime library are needed also.
How ever I made this changes with cmake compiled raylib V3.0 (static and dynamic 32/64-bit) and created fbraylib.bi and fbraylbimath.bi (improved of course)
But looks like all changes of V2.5 to V3.0 are internal only, no new stuff for the user of the library :-(
(I can't find a kind of changelog of raylib V3.0)

I wonder me that all structs like music, camera, vector, color ... are all pushed BYVAL on the stack (a slow copy) why not BYREF !
(on more mystery thing of this cute lib)

Joshy
Coolman
Posts: 228
Joined: Nov 05, 2010 15:09

Re: raylib headers

Postby Coolman » Mar 11, 2020 20:41

impressive library. it would be cool to divert it from its use and use it to create a graphical interface to programs generated by freebasic. the programs compiled with the static library are around 630 kb in size. it's perfect. I tried to test it with codeblocks but it is parameter for windows. if i have time i will fix this problem. I now only use linux.
paul doe
Posts: 1175
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: raylib headers

Postby paul doe » Mar 11, 2020 21:42

D.J.Peters wrote:On windows the *.dll's wasn't linked with the "-static-libgcc" linker flag so the mingw gcc runtime library are needed also.
...

Seems not to be the case with the binary I have (both FreeBasic and C are linking against the same lib in the above examples). Will have a closer look, thanks.
D.J.Peters wrote:...
How ever I made this changes with cmake compiled raylib V3.0 (static and dynamic 32/64-bit) and created fbraylib.bi and fbraylbimath.bi (improved of course)

But looks like all changes of V2.5 to V3.0 are internal only, no new stuff for the user of the library :-(
(I can't find a kind of changelog of raylib V3.0)
...

Yeah, was looking into raymath.bi and it could use some improvements. Where did you found the raylib 3.0 sources? I can't seem to find them (not that I looked much, anyway). The latest release in the official repo seems to be 2.6.
D.J.Peters wrote:...
I wonder me that all structs like music, camera, vector, color ... are all pushed BYVAL on the stack (a slow copy) why not BYREF !
(on more mystery thing of this cute lib)

Joshy

Indeed, this also struck me as strange. On the other hand, none of the structures are too large so...
Coolman wrote:impressive library. it would be cool to divert it from its use and use it to create a graphical interface to programs generated by freebasic. the programs compiled with the static library are around 630 kb in size. it's perfect. I tried to test it with codeblocks but it is parameter for windows. if i have time i will fix this problem. I now only use linux.

Users of the lib already did, it's called 'raygui'. Naturally, this is also one of the uses I indend for it (but quality rendering of primitives is probably best left to ie Cairo), and the lib also implements some convenience features for in-engine tooling (drag and drop support and clipboard routines, for example).

Linking statically against it would solve most of the functionality issues of the dated FBGFX2. One thing I did notice is that the library lacks a way of exposing the OpenGL context so you can bind extensions against it (for DIY OpenGL rendering). You can of course use the FreeBasic builtins, but this isn't recommended by the Kronos Group and may have undefined results.
Modifying the lib to allow this shouldn't pose too much trouble, though, but I'll have to dig deeper into the sources and work alonside the devels (or simply ask them to include it XD)

Can somebody please confirm that both the above examples are running as expected, so I can discard my gfx card (which is notoriously sh*tty) before embarking on a fruitless bug hunt?
D.J.Peters
Posts: 8023
Joined: May 28, 2005 3:28
Contact:

Re: raylib headers

Postby D.J.Peters » Mar 12, 2020 1:36

The latest version V3.0 is the current github branche last changes 2 and 3 days ago.
https://github.com/raysan5/raylib

V2.6 32-bit lib has the dependencies 64-bit are ok.
Image

Joshy
IchMagBier
Posts: 52
Joined: Jan 13, 2018 8:47
Location: Germany
Contact:

Re: raylib headers

Postby IchMagBier » Mar 12, 2020 4:52

paul doe wrote:Ported the rlights.h header, to port some examples that need it (namely, models_material_pbr.c). However, all I've got was a white screen. So, I tested the C example and alas, same thing.

models_material_pbc.c does work for me as expected. What OpenGL version is in use for you? It should tell in the console output when starting the example.
paul doe wrote:FreeBasic port above, original C code below (models_skybox.c). I wonder if the author changed something, and/or the repo I downloaded (2.6) is broken somehow? Mmmm...
Ported also some other 3D examples and they're fine, so I think that the shaders are giving me these results. Can you confirm, please?

I can confirm that the skybox is flipped in both, the C and the ported FB example. I will take a look at the shader when I have more time.
D.J.Peters wrote:I wonder me that all structs like music, camera, vector, color ... are all pushed BYVAL on the stack (a slow copy) why not BYREF !

I have seen that aswell and changed it in raymath.bi (The file was auto-generated by fbfrog). I am not touching the byvals in raylib.bi for now, since I don't know where it is actually needed.
paul doe wrote:Indeed, this also struck me as strange. On the other hand, none of the structures are too large so...

Well, take a look at the struct Mesh, which is 102 bytes in size.
Coolman
Posts: 228
Joined: Nov 05, 2010 15:09

Re: raylib headers

Postby Coolman » Mar 12, 2020 17:18

excellent lib but the compilation instructions are for windows. i had to make some adaptations to compile under linux with codeblocks. that said, to speed up the compilation, i made the following bash script :

Code: Select all

#!/bin/bash
shopt -s nullglob
for f in *.c
do
   echo Compiling : "$f"
   gcc -O2 -Wall -m64 -O2 -c "$f" -o "${f%.*}".obj
   g++ -o "${f%.*}" "${f%.*}".obj -m64 -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -s   
done


use : position yourself in the examples directory which contains the *.c files and run the script.

note : this will work if you have compiled and installed raylib and a few other necessary libraries under linux...

note : i have corrected the script in case the files to be processed have several points. it's rare but it can happen...
Last edited by Coolman on Mar 14, 2020 16:21, edited 2 times in total.
paul doe
Posts: 1175
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: raylib headers

Postby paul doe » Mar 14, 2020 0:08

@Joshy: I see. Thanks for confirming this.

IchMagBier wrote:...
models_material_pbc.c does work for me as expected. What OpenGL version is in use for you? It should tell in the console output when starting the example.

It uses the 3.30 version of the shaders. 1.1 also gives me the same results, so it is indeed my card, then.
IchMagBier wrote:...
I can confirm that the skybox is flipped in both, the C and the ported FB example. I will take a look at the shader when I have more time.
...

Then it is the shader alright. Thanks for checking this.
IchMagBier wrote:...
Well, take a look at the struct Mesh, which is 102 bytes in size.

Perhaps, but is still fits into a single cache line (usually 128 bytes). To address a single member of the struct, the prefetcher still has to load the entire struct into the cache anyway, so perhaps it was designed to take this into account?

@Coolman: very useful, thanks!
Coolman
Posts: 228
Joined: Nov 05, 2010 15:09

Re: raylib headers

Postby Coolman » Mar 14, 2020 16:22

note : i have corrected the script in case the files to be processed have several points. it's rare but it can happen...
BasicCoder2
Posts: 3520
Joined: Jan 01, 2009 7:03

Re: raylib headers

Postby BasicCoder2 » Mar 27, 2020 22:10

When I tried to run an example:

Command executed:
"C:\FreeBasic\fbc.exe" "C:\FreeBasic\raylib-fb-master\examples\2d.bas"

Compiler output:
C:\FreeBasic\bin\win32\ld.exe: cannot find -lraylib

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.07.1 (2019-09-27), built for win32 (32bit)
OS: Windows NT 6.2 (build 9200)
UEZ
Posts: 510
Joined: May 05, 2017 19:59
Location: Germany

Re: raylib headers

Postby UEZ » Mar 27, 2020 22:32

BasicCoder2 wrote:When I tried to run an example:

Command executed:
"C:\FreeBasic\fbc.exe" "C:\FreeBasic\raylib-fb-master\examples\2d.bas"

Compiler output:
C:\FreeBasic\bin\win32\ld.exe: cannot find -lraylib

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.07.1 (2019-09-27), built for win32 (32bit)
OS: Windows NT 6.2 (build 9200)


I had the same problem. You need Raylib from here: https://github.com/raysan5/raylib/releases.
BasicCoder2
Posts: 3520
Joined: Jan 01, 2009 7:03

Re: raylib headers

Postby BasicCoder2 » Mar 27, 2020 22:50

UEZ wrote:I had the same problem. You need Raylib from here: https://github.com/raysan5/raylib/releases.


Ok thanks, although I am not sure which one of the 9 "assets" to download.
UEZ
Posts: 510
Joined: May 05, 2017 19:59
Location: Germany

Re: raylib headers

Postby UEZ » Mar 27, 2020 22:58

BasicCoder2 wrote:
UEZ wrote:I had the same problem. You need Raylib from here: https://github.com/raysan5/raylib/releases.


Ok thanks, although I am not sure which one of the 9 "assets" to download.


I used the minigw versions for Windows only. I don't know if msvc version is better (faster).

I'm not using Linux or any other OS.

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 2 guests