Пример #1
0
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)
rl.UnloadShader(shdrCubemap)

rl.SetCameraMode(camera[0], rl.CAMERA_FIRST_PERSON)

rl.SetTargetFPS(60)

while not rl.WindowShouldClose():
    rl.UpdateCamera(camera)
    rl.BeginDrawing()
    rl.ClearBackground(RAYWHITE)
Пример #2
0
Файл: main.py Проект: Pebaz/awd
if sys.platform == 'win32':
    import win32gui, win32con, pywintypes

    # Set window to always top without moving it
    win32gui.SetWindowPos(
        pywintypes.HANDLE(ffi.cast('int', rl.GetWindowHandle())),
        win32con.HWND_TOPMOST, 0, 0, 0, 0,
        win32con.SWP_NOSIZE | win32con.SWP_NOMOVE)

#tint = glm.vec4(255, 255, 255, 255) When mouse over, brighten everything fade
trans = 155
elapsed = CTM()

frames = list(pathlib.Path('data').iterdir())
frames.sort(key=lambda img: int(img.stem))
frames = [rl.LoadTexture(str(i).encode()) for i in frames]

frame_counter = 0
frame_time = CTM()
frame_flip = True
energy_ball = rl.LoadTexture(b'energy-ball.png')

while not rl.WindowShouldClose():
    frame_start_time = CTM()

    elapsed += 1 * rl.GetFrameTime()
    if elapsed > 1.0:
        elapsed = 0

    mouse_pos = Vec2(rl.GetMousePosition())
Пример #3
0
"""

from raylib.dynamic import raylib as rl, ffi
from raylib.colors import *

rl.SetConfigFlags(rl.FLAG_MSAA_4X_HINT | rl.FLAG_WINDOW_RESIZABLE)
rl.InitWindow(1280, 768, b'Fog Test')

camera = ffi.new('struct Camera3D *',
                 [[2, 2, 6], [0, 5, 0], [0, 1, 0], 45, rl.CAMERA_PERSPECTIVE])

model = rl.LoadModelFromMesh(rl.GenMeshTorus(0.4, 1, 16, 32))
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]
Пример #4
0
#// Initialization
#//--------------------------------------------------------------------------------------
screenWidth = 800
screenHeight = 450

rl.SetConfigFlags(rl.FLAG_MSAA_4X_HINT | rl.FLAG_WINDOW_RESIZABLE)
# Enable Multi Sampling Anti Aliasing 4x (if available)
rl.InitWindow(screenWidth, screenHeight,
              b"raylib [shaders] example - basic lighting")

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

model = rl.LoadModel(b"resources/models/barracks.obj")  # // Load OBJ model
texture = rl.LoadTexture(b"resources/models/barracks_diffuse.png"
                         )  # // Load model texture (diffuse map)

#// Assign texture to default model material
model.materials[0].maps[rl.MAP_DIFFUSE].texture = texture
#// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
shader = rl.LoadShader(b"", b"resources/shaders/glsl330/swirl.fs")
swirlCenterLoc = rl.GetShaderLocation(shader, b"center")
angle = 6.282

swirl = ffi.new("struct Vector2 *", [0, 0])

target = rl.LoadRenderTexture(screenWidth, screenHeight)

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