예제 #1
0
    def UpdateLightValues(self):
        #// Send to shader light enabled state and type
        rl.SetShaderValue(self.shader, self.enabledLoc, ffi.new("int *",self.enabled), rl.UNIFORM_INT)
        rl.SetShaderValue(self.shader, self.typeLoc, ffi.new("int *",self.type), rl.UNIFORM_INT)

        #// Send to shader light position values
        position = [ self.position.x, self.position.y, self.position.z]
        rl.SetShaderValue(self.shader, self.posLoc, ffi.new("struct Vector3 *",position), rl.UNIFORM_VEC3)

        #// Send to shader light target position values
        target =[  self.target.x, self.target.y, self.target.z ]
        rl.SetShaderValue(self.shader, self.targetLoc, ffi.new("struct Vector3 *",target), rl.UNIFORM_VEC3)

        #// Send to shader light color values
        color = [self.color[0]/255.0, self.color[1]/255.0,  self.color[2]/255.0, self.color[3]/255.0]
        rl.SetShaderValue(self.shader, self.colorLoc, ffi.new("struct Vector4 *",color), rl.UNIFORM_VEC4)
예제 #2
0
    def __init__(self, ambient = [ 0.2, 0.2, 0.2, 1.0 ], *ls):
        self.shader = rl.LoadShader(b"resources/shaders/fogLight.vs",
                            b"resources/shaders/fogLight.fs");

        #// Get some shader loactions
        self.shader.locs[rl.LOC_MATRIX_MODEL] = rl.GetShaderLocation(self.shader, b"matModel");
        self.shader.locs[rl.LOC_VECTOR_VIEW] = rl.GetShaderLocation(self.shader, b"viewPos");

        #// ambient light level
        self.ambientLoc = rl.GetShaderLocation(self.shader, b"ambient");
        v = ffi.new("struct Vector4 *", ambient)
        rl.SetShaderValue(self.shader, self.ambientLoc, v, rl.UNIFORM_VEC4);

        for light in ls:
            self.add(light)
예제 #3
0
 def update(self, cameraPos):
     rl.SetShaderValue(self.shader, self.shader.locs[rl.LOC_VECTOR_VIEW], ffi.new("struct Vector3 *",cameraPos), rl.UNIFORM_VEC3)
     for light in self.lights:
         light.UpdateLightValues()
예제 #4
0
screenWidth = 1260
screenHeight = 768

rl.InitWindow(screenWidth, screenHeight, b'Skymap Demo')

camera = ffi.new('struct Camera3D *', [[1, 1, 1], [4, 1, 4], [0, 1, 0], 70, 0])

cube = rl.GenMeshCube(100, 100, 100)
skybox = rl.LoadModelFromMesh(cube)

skybox.materials[0].shader = rl.LoadShader(b'resources/shaders/skybox.vs',
                                           b'resources/shaders/skybox.fs')

rl.SetShaderValue(
    skybox.materials[0].shader,
    rl.GetShaderLocation(skybox.materials[0].shader, b"environmentMap"),
    ffi.new('int[]', [rl.MAP_CUBEMAP]), rl.UNIFORM_INT)

shdrCubemap = rl.LoadShader(b'resources/shaders/cubemap.vs',
                            b'resources/shaders/cubemap.fs')

rl.SetShaderValue(shdrCubemap,
                  rl.GetShaderLocation(shdrCubemap, b'equirectangularMap'),
                  ffi.new('int[]', [0]), rl.UNIFORM_INT)

texHDR = rl.LoadTexture(b'resources/dresden_square.hdr')

skybox.materials[0].maps[rl.MAP_CUBEMAP].texture = rl.GenTextureCubemap(
    shdrCubemap, texHDR, 512, rl.UNCOMPRESSED_R32G32B32)

rl.UnloadTexture(texHDR)
예제 #5
0
camera = ffi.new(
    'struct Camera3D *',
    [[2, 12, 6], [0, .5, 0], [0, 1, 0], 45, rl.CAMERA_PERSPECTIVE])

imBlank = rl.GenImageColor(1024, 1024, BLANK)
texture = rl.LoadTextureFromImage(
    imBlank)  #// Load blank texture to fill on shader
rl.UnloadImage(imBlank)

#// NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
shader = rl.LoadShader(b"", b"resources/shaders/glsl330/cubes_panning.fs")

time = ffi.new("float *", 0.0)
timeLoc = rl.GetShaderLocation(shader, b"uTime")
rl.SetShaderValue(shader, timeLoc, time, rl.UNIFORM_FLOAT)

rl.SetTargetFPS(60)  # // Set our game to run at 60 frames-per-second
#//--------------------------------------------------------------------------------------

#// Main game loop
while not rl.WindowShouldClose():  #// Detect window close button or ESC key
    #// Update
    #//----------------------------------------------------------------------------------
    time[0] = rl.GetTime()
    rl.SetShaderValue(shader, timeLoc, time, rl.UNIFORM_FLOAT)

    #//----------------------------------------------------------------------------------

    #// Draw
    #//----------------------------------------------------------------------------------
예제 #6
0
model2 = rl.LoadModelFromMesh(rl.GenMeshCube(1, 1, 1))
model3 = rl.LoadModelFromMesh(rl.GenMeshSphere(0.5, 32, 32))

texture = rl.LoadTexture(b'resources/test.png')

model.materials[0].maps[rl.MAP_DIFFUSE].texture = texture
model2.materials[0].maps[rl.MAP_DIFFUSE].texture = texture
model3.materials[0].maps[rl.MAP_DIFFUSE].texture = texture

shader = rl.LoadShader(b'resources/shaders/fogLight.vs',
                       b'resources/shaders/fogLight.fs')
shader.locs[rl.LOC_MATRIX_MODEL] = rl.GetShaderLocation(shader, b'matModel')
shader.locs[rl.LOC_VECTOR_VIEW] = rl.GetShaderLocation(shader, b'viewPos')

amb = rl.GetShaderLocation(shader, b'ambient')
rl.SetShaderValue(shader, amb, ffi.new('float[]', [0.2, 0.2, 0.2, 1.0]),
                  rl.UNIFORM_VEC4)

fog_color = [0.2, 0.2, 1.0, 1.0]
fogC = rl.GetShaderLocation(shader, b'fogColor')
rl.SetShaderValue(shader, fogC, ffi.new('float[]', fog_color), rl.UNIFORM_VEC4)

fogD = rl.GetShaderLocation(shader, b'FogDensity')
fogDensity = 0.12
rl.SetShaderValue(shader, fogD, ffi.new('float[]', [fogDensity]),
                  rl.UNIFORM_FLOAT)

model.materials[0].shader = shader
model2.materials[0].shader = shader
model3.materials[0].shader = shader

rl.SetCameraMode(camera[0], rl.CAMERA_ORBITAL)
예제 #7
0
rl.SetTargetFPS(60)  # // Set our game to run at 60 frames-per-second
#//--------------------------------------------------------------------------------------

#// Main game loop
while not rl.WindowShouldClose():  #// Detect window close button or ESC key
    #// Update
    #//----------------------------------------------------------------------------------

    angle -= 0.002
    camera.position.x = math.sin(angle) * 30.0
    camera.position.z = math.cos(angle) * 30.0
    rl.UpdateCamera(camera)  #// Update camera

    swirl.x = rl.GetMouseX()
    swirl.y = screenHeight - rl.GetMouseY()
    rl.SetShaderValue(shader, swirlCenterLoc, swirl, rl.UNIFORM_VEC2)
    #//----------------------------------------------------------------------------------

    #// Draw
    #//----------------------------------------------------------------------------------
    rl.BeginDrawing()

    rl.BeginTextureMode(target)
    rl.ClearBackground(RAYWHITE)
    rl.BeginMode3D(camera[0])

    #// Draw the three models
    rl.DrawModel(model, [0, 0, 0], 1.0, WHITE)

    rl.DrawGrid(10, 1.0)