コード例 #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()
コード例 #2
0
python3 flow-field
        flow-field bees
"""

import sys, math, time, random
import glm
from raylib.dynamic import raylib as rl, ffi
from raylib.colors import *

CTM = lambda: round(time.time() * 1000)

BEES = bool(sys.argv[1:])

rl.SetTraceLogLevel(rl.LOG_ERROR)
rl.SetConfigFlags(rl.FLAG_WINDOW_RESIZABLE)
rl.InitWindow(512, 512, b'Friendly Bees')
rl.SetTargetFPS(60)
#rl.DisableCursor()

canvas = rl.LoadRenderTexture(rl.GetScreenWidth(), rl.GetScreenHeight())
rl.SetTextureWrap(canvas.texture, rl.WRAP_MIRROR_REPEAT)


def random_point_in_circle(center, radius):
    a = random.random() * 2 * math.pi
    r = radius * math.sqrt(random.random())
    x = r * math.cos(a)
    z = r * math.sin(a)
    return glm.vec3(x + center.x, center.y, z + center.z)
コード例 #3
0
#!/usr/bin/env python3

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

# a few functions ported from raymath
from rlmath import *

#// 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])

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)
コード例 #4
0
import screeninfo
from raylib.dynamic import raylib as rl, ffi
from raylib.colors import *

Vec2 = lambda p: glm.vec2(p.x, p.y)
CTM = lambda: round(time.perf_counter() * 1000)

monitors = screeninfo.get_monitors()
drag = False
offset = Vec2(rl.GetMousePosition())
width = height = 160
window_vel = glm.vec2()
window_pos = glm.vec2(monitors[0].width - width, monitors[0].height - height)

rl.SetConfigFlags(rl.FLAG_WINDOW_TRANSPARENT
                  | rl.FLAG_WINDOW_UNDECORATED
                  | rl.FLAG_VSYNC_HINT
                  | rl.FLAG_MSAA_4X_HINT)
rl.InitWindow(width, height, b'')
rl.SetWindowPosition(int(window_pos.x), int(window_pos.y))
#rl.SetTargetFPS(500)
target = rl.LoadRenderTexture(width, height)

# Top-Level Window Support Only On Windows
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)