Beispiel #1
0
def camera_test():
    rl.SetTraceLogLevel(rl.LOG_ERROR)
    rl.SetConfigFlags(rl.FLAG_WINDOW_RESIZABLE)
    rl.InitWindow(512, 256, b'Test')
    rl.SetTargetFPS(60)
    rl.DisableCursor()

    flycam = CameraFly()

    while not rl.WindowShouldClose():
        flycam.update()
        cam = flycam.get_camera()

        rl.BeginDrawing()
        rl.ClearBackground((0, 200, 255, 255))
        rl.BeginMode3D(cam[0])

        # NOTE(pebaz): For whatever reason, this can solve a percentage of artifacts
        rl.DrawGizmo([100000000, 100000000, 100000000])

        rl.DrawGrid(32, 1)

        rl.EndMode3D()
        rl.EndDrawing()

    rl.CloseWindow()
Beispiel #2
0
"""
This shows how to use the CFFI dynamic (ABI) binding.  Note that is slower and more likely to run into silent errors and segfaults.
But it doesnt require any C compiler to build.
"""
from raylib.dynamic import ffi, raylib as rl
from raylib.colors import *

rl.InitWindow(800, 450, b"Raylib dynamic binding test")
rl.SetTargetFPS(60)

camera = ffi.new(
    "struct Camera3D *",
    [[18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0])
image = rl.LoadImage(b"examples/models/resources/heightmap.png")
texture = rl.LoadTextureFromImage(image)
mesh = rl.GenMeshHeightmap(image, [16, 8, 16])
model = rl.LoadModelFromMesh(mesh)
print(
    model.materials
)  # SHOULD BE A pointer to a 'struct Material' but some is NULL pointer to 'Material' ?
model.materials.maps[rl.MAP_DIFFUSE].texture = texture

rl.UnloadImage(image)
rl.SetCameraMode(camera[0], rl.CAMERA_ORBITAL)

while not rl.WindowShouldClose():
    rl.UpdateCamera(camera)
    rl.BeginDrawing()
    rl.ClearBackground(RAYWHITE)
    rl.BeginMode3D(camera[0])
    rl.DrawModel(model, (-8.0, 0.0, -8.0), 1.0, RED)
Beispiel #3
0
    '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
    #//----------------------------------------------------------------------------------
    rl.BeginDrawing()
Beispiel #4
0
import toml, pprint, math, sys
from raylib.dynamic import raylib as rl, ffi
from raylib.colors import *
from haishoku.haishoku import Haishoku

TILE_SIZE = 64

colors = toml.load(open((sys.argv[1:] or ['palettes/painting.toml'])[0]))
pprint.pprint(colors)

WIDTH = 640
HEIGHT = 512

rl.SetConfigFlags(rl.FLAG_WINDOW_RESIZABLE)
rl.InitWindow(WIDTH, HEIGHT, b'Palettizer - Press E To Export Palette')
rl.SetTargetFPS(30)


def get_dropped_files():
    files = []
    if rl.IsFileDropped():
        file_count = ffi.new('int *')
        files = rl.GetDroppedFiles(file_count)
        files = [ffi.string(files[i]).decode() for i in range(file_count[0])]
        rl.ClearDroppedFiles()
    return files


while not rl.WindowShouldClose():
    for file in get_dropped_files():
        h = Haishoku.loadHaishoku(file)