diff --git a/raylib/core.go b/raylib/core.go index af2ecf2..341b110 100644 --- a/raylib/core.go +++ b/raylib/core.go @@ -95,16 +95,6 @@ func ToggleFullscreen() { C.ToggleFullscreen() } -// UnhideWindow - Show the window -func UnhideWindow() { - C.UnhideWindow() -} - -// HideWindow - Hide the window -func HideWindow() { - C.HideWindow() -} - // SetWindowIcon - Set icon for window (only PLATFORM_DESKTOP) func SetWindowIcon(image Image) { cimage := image.cptr() diff --git a/raylib/models.go b/raylib/models.go index f2aa3c8..68c80c4 100644 --- a/raylib/models.go +++ b/raylib/models.go @@ -156,22 +156,6 @@ func DrawGrid(slices int32, spacing float32) { C.DrawGrid(cslices, cspacing) } -// DrawGizmo - Draw simple gizmo -func DrawGizmo(position Vector3) { - cposition := position.cptr() - C.DrawGizmo(*cposition) -} - -// LoadMeshes - Load mesh from file -func LoadMeshes(fileName string) Mesh { - cfileName := C.CString(fileName) - defer C.free(unsafe.Pointer(cfileName)) - ccount := C.int(0) - ret := C.LoadMeshes(cfileName, &ccount) - v := newMeshFromPointer(unsafe.Pointer(&ret)) - return v -} - // LoadModel - Load model from file func LoadModel(fileName string) Model { cfileName := C.CString(fileName) @@ -390,20 +374,20 @@ func DrawBillboard(camera Camera, texture Texture2D, center Vector3, size float3 } // DrawBillboardRec - Draw a billboard texture defined by sourceRec -func DrawBillboardRec(camera Camera, texture Texture2D, sourceRec Rectangle, center Vector3, size float32, tint Color) { +func DrawBillboardRec(camera Camera, texture Texture2D, sourceRec Rectangle, center Vector3, size Vector2, tint Color) { ccamera := camera.cptr() ctexture := texture.cptr() csourceRec := sourceRec.cptr() ccenter := center.cptr() - csize := (C.float)(size) + csize := size.cptr() ctint := tint.cptr() - C.DrawBillboardRec(*ccamera, *ctexture, *csourceRec, *ccenter, csize, *ctint) + C.DrawBillboardRec(*ccamera, *ctexture, *csourceRec, *ccenter, *csize, *ctint) } -// MeshBoundingBox - Compute mesh bounding box limits -func MeshBoundingBox(mesh Mesh) BoundingBox { +// GetMeshBoundingBox - Compute mesh bounding box limits +func GetMeshBoundingBox(mesh Mesh) BoundingBox { cmesh := mesh.cptr() - ret := C.MeshBoundingBox(*cmesh) + ret := C.GetMeshBoundingBox(*cmesh) v := newBoundingBoxFromPointer(unsafe.Pointer(&ret)) return v } diff --git a/raylib/platform_desktop.go b/raylib/platform_desktop.go index b197d67..f73a426 100644 --- a/raylib/platform_desktop.go +++ b/raylib/platform_desktop.go @@ -105,11 +105,6 @@ func IsWindowFocused() bool { return v } -// UndecorateWindow - Undecorate the window (only PLATFORM_DESKTOP) -func UndecorateWindow() { - C.UndecorateWindow() -} - // MaximizeWindow - Maximize the window, if resizable (only PLATFORM_DESKTOP) func MaximizeWindow() { C.MaximizeWindow() @@ -120,11 +115,6 @@ func RestoreWindow() { C.RestoreWindow() } -// DecorateWindow - Decorate the window (only PLATFORM_DESKTOP) -func DecorateWindow() { - C.DecorateWindow() -} - // GetMonitorRefreshRate - Get primary monitor refresh rate func GetMonitorRefreshRate(monitor int) int { cmonitor := (C.int)(monitor) diff --git a/raylib/raudio.go b/raylib/raudio.go index e15a9da..789d5f6 100644 --- a/raylib/raudio.go +++ b/raylib/raudio.go @@ -174,11 +174,11 @@ func WaveCrop(wave Wave, initSample int32, finalSample int32) { C.WaveCrop(cwave, cinitSample, cfinalSample) } -// GetWaveData - Get samples data from wave as a floats array -func GetWaveData(wave Wave) []float32 { +// LoadWaveSamples - Get samples data from wave as a floats array +func LoadWaveSamples(wave Wave) []float32 { var data []float32 cwave := wave.cptr() - ret := C.GetWaveData(*cwave) + ret := C.LoadWaveSamples(*cwave) sliceHeader := (*reflect.SliceHeader)((unsafe.Pointer(&data))) sliceHeader.Cap = int(wave.SampleCount) @@ -233,10 +233,10 @@ func ResumeMusicStream(music Music) { C.ResumeMusicStream(cmusic) } -// IsMusicPlaying - Check if music is playing -func IsMusicPlaying(music Music) bool { +// IsMusicStreamPlaying - Check if music is playing +func IsMusicStreamPlaying(music Music) bool { cmusic := *(*C.Music)(unsafe.Pointer(&music)) - ret := C.IsMusicPlaying(cmusic) + ret := C.IsMusicStreamPlaying(cmusic) v := bool(ret) return v } diff --git a/raylib/raylib.go b/raylib/raylib.go index 8f8d894..1495841 100644 --- a/raylib/raylib.go +++ b/raylib/raylib.go @@ -1147,13 +1147,11 @@ type RenderTexture2D struct { ID uint32 // Color buffer attachment texture Texture Texture2D - // Depth buffer attachment texture - Depth Texture2D } // NewRenderTexture2D - Returns new RenderTexture2D -func NewRenderTexture2D(id uint32, texture, depth Texture2D) RenderTexture2D { - return RenderTexture2D{id, texture, depth} +func NewRenderTexture2D(id uint32, texture Texture2D) RenderTexture2D { + return RenderTexture2D{id, texture} } // newRenderTexture2DFromPointer - Returns new RenderTexture2D from pointer diff --git a/raylib/shaders.go b/raylib/rlgl.go similarity index 57% rename from raylib/shaders.go rename to raylib/rlgl.go index a4c09bb..238073d 100644 --- a/raylib/shaders.go +++ b/raylib/rlgl.go @@ -2,6 +2,7 @@ package rl /* #include "raylib.h" +#include "rlgl.h" #include */ import "C" @@ -38,15 +39,15 @@ func LoadShader(vsFileName string, fsFileName string) Shader { return v } -// LoadShaderCode - Load shader from code strings and bind default locations -func LoadShaderCode(vsCode string, fsCode string) Shader { +// LoadShaderFromMemory - Load shader from code strings and bind default locations +func LoadShaderFromMemory(vsCode string, fsCode string) Shader { cvsCode := C.CString(vsCode) defer C.free(unsafe.Pointer(cvsCode)) cfsCode := C.CString(fsCode) defer C.free(unsafe.Pointer(cfsCode)) - ret := C.LoadShaderCode(cvsCode, cfsCode) + ret := C.LoadShaderFromMemory(cvsCode, cfsCode) v := newShaderFromPointer(unsafe.Pointer(&ret)) return v @@ -60,14 +61,14 @@ func UnloadShader(shader Shader) { // GetShaderDefault - Get default shader func GetShaderDefault() Shader { - ret := C.GetShaderDefault() + ret := C.rlGetShaderDefault() v := newShaderFromPointer(unsafe.Pointer(&ret)) return v } // GetTextureDefault - Get default texture func GetTextureDefault() *Texture2D { - ret := C.GetTextureDefault() + ret := C.rlGetTextureDefault() v := newTexture2DFromPointer(unsafe.Pointer(&ret)) return &v } @@ -103,56 +104,13 @@ func SetShaderValueMatrix(shader Shader, uniformLoc int32, mat Matrix) { // SetMatrixProjection - Set a custom projection matrix (replaces internal projection matrix) func SetMatrixProjection(proj Matrix) { cproj := proj.cptr() - C.SetMatrixProjection(*cproj) + C.rlSetMatrixProjection(*cproj) } // SetMatrixModelview - Set a custom modelview matrix (replaces internal modelview matrix) func SetMatrixModelview(view Matrix) { cview := view.cptr() - C.SetMatrixModelview(*cview) -} - -// GenTextureCubemap - Generate cubemap texture from HDR texture -func GenTextureCubemap(shader Shader, skyHDR Texture2D, size int) Texture2D { - cshader := shader.cptr() - cskyHDR := skyHDR.cptr() - csize := (C.int)(size) - - ret := C.GenTextureCubemap(*cshader, *cskyHDR, csize) - v := newTexture2DFromPointer(unsafe.Pointer(&ret)) - return v -} - -// GenTextureIrradiance - Generate irradiance texture using cubemap data -func GenTextureIrradiance(shader Shader, cubemap Texture2D, size int) Texture2D { - cshader := shader.cptr() - ccubemap := cubemap.cptr() - csize := (C.int)(size) - - ret := C.GenTextureIrradiance(*cshader, *ccubemap, csize) - v := newTexture2DFromPointer(unsafe.Pointer(&ret)) - return v -} - -// GenTexturePrefilter - Generate prefilter texture using cubemap data -func GenTexturePrefilter(shader Shader, cubemap Texture2D, size int) Texture2D { - cshader := shader.cptr() - ccubemap := cubemap.cptr() - csize := (C.int)(size) - - ret := C.GenTexturePrefilter(*cshader, *ccubemap, csize) - v := newTexture2DFromPointer(unsafe.Pointer(&ret)) - return v -} - -// GenTextureBRDF - Generate BRDF texture using cubemap data -func GenTextureBRDF(shader Shader, size int) Texture2D { - cshader := shader.cptr() - csize := (C.int)(size) - - ret := C.GenTextureBRDF(*cshader, csize) - v := newTexture2DFromPointer(unsafe.Pointer(&ret)) - return v + C.rlSetMatrixModelview(*cview) } // BeginShaderMode - Begin custom shader drawing @@ -176,41 +134,3 @@ func BeginBlendMode(mode BlendMode) { func EndBlendMode() { C.EndBlendMode() } - -// InitVrSimulator - Init VR simulator for selected device -func InitVrSimulator() { - C.InitVrSimulator() -} - -// CloseVrSimulator - Close VR simulator for current device -func CloseVrSimulator() { - C.CloseVrSimulator() -} - -// IsVrSimulatorReady - Detect if VR simulator is ready -func IsVrSimulatorReady() bool { - ret := C.IsVrSimulatorReady() - v := bool(ret) - return v -} - -// UpdateVrTracking - Update VR tracking (position and orientation) and camera -func UpdateVrTracking(camera *Camera) { - ccamera := camera.cptr() - C.UpdateVrTracking(ccamera) -} - -// ToggleVrMode - Enable/Disable VR experience (device or simulator) -func ToggleVrMode() { - C.ToggleVrMode() -} - -// BeginVrDrawing - Begin VR simulator stereo rendering -func BeginVrDrawing() { - C.BeginVrDrawing() -} - -// EndVrDrawing - End VR simulator stereo rendering -func EndVrDrawing() { - C.EndVrDrawing() -} diff --git a/raylib/shader_distortion.h b/raylib/shader_distortion.h deleted file mode 100644 index 3b37c63..0000000 --- a/raylib/shader_distortion.h +++ /dev/null @@ -1,106 +0,0 @@ - -// Vertex shader definition to embed, no external file required -static const char distortionVShaderStr[] = -#if defined(GRAPHICS_API_OPENGL_21) -"#version 120 \n" -#elif defined(GRAPHICS_API_OPENGL_ES2) -"#version 100 \n" -#endif -#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) -"attribute vec3 vertexPosition; \n" -"attribute vec2 vertexTexCoord; \n" -"attribute vec4 vertexColor; \n" -"varying vec2 fragTexCoord; \n" -"varying vec4 fragColor; \n" -#elif defined(GRAPHICS_API_OPENGL_33) -"#version 330 \n" -"in vec3 vertexPosition; \n" -"in vec2 vertexTexCoord; \n" -"in vec4 vertexColor; \n" -"out vec2 fragTexCoord; \n" -"out vec4 fragColor; \n" -#endif -"uniform mat4 mvp; \n" -"void main() \n" -"{ \n" -" fragTexCoord = vertexTexCoord; \n" -" fragColor = vertexColor; \n" -" gl_Position = mvp*vec4(vertexPosition, 1.0); \n" -"} \n"; - -// Fragment shader definition to embed, no external file required -static const char distortionFShaderStr[] = -#if defined(GRAPHICS_API_OPENGL_21) -"#version 120 \n" -#elif defined(GRAPHICS_API_OPENGL_ES2) -"#version 100 \n" -"precision mediump float; \n" // precision required for OpenGL ES2 (WebGL) -#endif -#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) -"varying vec2 fragTexCoord; \n" -"varying vec4 fragColor; \n" -#elif defined(GRAPHICS_API_OPENGL_33) -"#version 330 \n" -"in vec2 fragTexCoord; \n" -"in vec4 fragColor; \n" -"out vec4 finalColor; \n" -#endif -"uniform sampler2D texture0; \n" -#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) -"uniform vec2 leftLensCenter; \n" -"uniform vec2 rightLensCenter; \n" -"uniform vec2 leftScreenCenter; \n" -"uniform vec2 rightScreenCenter; \n" -"uniform vec2 scale; \n" -"uniform vec2 scaleIn; \n" -"uniform vec4 hmdWarpParam; \n" -"uniform vec4 chromaAbParam; \n" -#elif defined(GRAPHICS_API_OPENGL_33) -"uniform vec2 leftLensCenter = vec2(0.288, 0.5); \n" -"uniform vec2 rightLensCenter = vec2(0.712, 0.5); \n" -"uniform vec2 leftScreenCenter = vec2(0.25, 0.5); \n" -"uniform vec2 rightScreenCenter = vec2(0.75, 0.5); \n" -"uniform vec2 scale = vec2(0.25, 0.45); \n" -"uniform vec2 scaleIn = vec2(4, 2.2222); \n" -"uniform vec4 hmdWarpParam = vec4(1, 0.22, 0.24, 0); \n" -"uniform vec4 chromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); \n" -#endif -"void main() \n" -"{ \n" -" vec2 lensCenter = fragTexCoord.x < 0.5 ? leftLensCenter : rightLensCenter; \n" -" vec2 screenCenter = fragTexCoord.x < 0.5 ? leftScreenCenter : rightScreenCenter; \n" -" vec2 theta = (fragTexCoord - lensCenter)*scaleIn; \n" -" float rSq = theta.x*theta.x + theta.y*theta.y; \n" -" vec2 theta1 = theta*(hmdWarpParam.x + hmdWarpParam.y*rSq + hmdWarpParam.z*rSq*rSq + hmdWarpParam.w*rSq*rSq*rSq); \n" -" vec2 thetaBlue = theta1*(chromaAbParam.z + chromaAbParam.w*rSq); \n" -" vec2 tcBlue = lensCenter + scale*thetaBlue; \n" -" if (any(bvec2(clamp(tcBlue, screenCenter - vec2(0.25, 0.5), screenCenter + vec2(0.25, 0.5)) - tcBlue))) \n" -" { \n" -#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) -" gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); \n" -#elif defined(GRAPHICS_API_OPENGL_33) -" finalColor = vec4(0.0, 0.0, 0.0, 1.0); \n" -#endif -" } \n" -" else \n" -" { \n" -#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) -" float blue = texture2D(texture0, tcBlue).b; \n" -" vec2 tcGreen = lensCenter + scale*theta1; \n" -" float green = texture2D(texture0, tcGreen).g; \n" -#elif defined(GRAPHICS_API_OPENGL_33) -" float blue = texture(texture0, tcBlue).b; \n" -" vec2 tcGreen = lensCenter + scale*theta1; \n" -" float green = texture(texture0, tcGreen).g; \n" -#endif -" vec2 thetaRed = theta1*(chromaAbParam.x + chromaAbParam.y*rSq); \n" -" vec2 tcRed = lensCenter + scale*thetaRed; \n" -#if defined(GRAPHICS_API_OPENGL_ES2) || defined(GRAPHICS_API_OPENGL_21) -" float red = texture2D(texture0, tcRed).r; \n" -" gl_FragColor = vec4(red, green, blue, 1.0); \n" -#elif defined(GRAPHICS_API_OPENGL_33) -" float red = texture(texture0, tcRed).r; \n" -" finalColor = vec4(red, green, blue, 1.0); \n" -#endif -" } \n" -"} \n"; diff --git a/raylib/shapes.go b/raylib/shapes.go index 39e499f..e61d1e9 100644 --- a/raylib/shapes.go +++ b/raylib/shapes.go @@ -68,22 +68,22 @@ func DrawCircle(centerX, centerY int32, radius float32, color Color) { } // DrawCircleSector - Draw a piece of a circle -func DrawCircleSector(center Vector2, radius float32, startAngle, endAngle, segments int32, color Color) { +func DrawCircleSector(center Vector2, radius, startAngle, endAngle float32, segments int32, color Color) { ccenter := center.cptr() cradius := (C.float)(radius) - cstartAngle := (C.int)(startAngle) - cendAngle := (C.int)(endAngle) + cstartAngle := (C.float)(startAngle) + cendAngle := (C.float)(endAngle) csegments := (C.int)(segments) ccolor := color.cptr() C.DrawCircleSector(*ccenter, cradius, cstartAngle, cendAngle, csegments, *ccolor) } // DrawCircleSectorLines - -func DrawCircleSectorLines(center Vector2, radius float32, startAngle, endAngle, segments int32, color Color) { +func DrawCircleSectorLines(center Vector2, radius, startAngle, endAngle float32, segments int32, color Color) { ccenter := center.cptr() cradius := (C.float)(radius) - cstartAngle := (C.int)(startAngle) - cendAngle := (C.int)(endAngle) + cstartAngle := (C.float)(startAngle) + cendAngle := (C.float)(endAngle) csegments := (C.int)(segments) ccolor := color.cptr() C.DrawCircleSectorLines(*ccenter, cradius, cstartAngle, cendAngle, csegments, *ccolor) @@ -137,24 +137,24 @@ func DrawEllipseLines(centerX, centerY int32, radiusH, radiusV float32, color Co } // DrawRing - -func DrawRing(center Vector2, innerRadius, outerRadius float32, startAngle, endAngle, segments int32, color Color) { +func DrawRing(center Vector2, innerRadius, outerRadius, startAngle, endAngle float32, segments int32, color Color) { ccenter := center.cptr() cinnerRadius := (C.float)(innerRadius) couterRadius := (C.float)(outerRadius) - cstartAngle := (C.int)(startAngle) - cendAngle := (C.int)(endAngle) + cstartAngle := (C.float)(startAngle) + cendAngle := (C.float)(endAngle) csegments := (C.int)(segments) ccolor := color.cptr() C.DrawRing(*ccenter, cinnerRadius, couterRadius, cstartAngle, cendAngle, csegments, *ccolor) } // DrawRingLines - -func DrawRingLines(center Vector2, innerRadius, outerRadius float32, startAngle, endAngle, segments int32, color Color) { +func DrawRingLines(center Vector2, innerRadius, outerRadius, startAngle, endAngle float32, segments int32, color Color) { ccenter := center.cptr() cinnerRadius := (C.float)(innerRadius) couterRadius := (C.float)(outerRadius) - cstartAngle := (C.int)(startAngle) - cendAngle := (C.int)(endAngle) + cstartAngle := (C.float)(startAngle) + cendAngle := (C.float)(endAngle) csegments := (C.int)(segments) ccolor := color.cptr() C.DrawRingLines(*ccenter, cinnerRadius, couterRadius, cstartAngle, cendAngle, csegments, *ccolor) @@ -237,9 +237,9 @@ func DrawRectangleLines(posX, posY, width, height int32, color Color) { } // DrawRectangleLinesEx - Draw rectangle outline with extended parameters -func DrawRectangleLinesEx(rec Rectangle, lineThick int32, color Color) { +func DrawRectangleLinesEx(rec Rectangle, lineThick float32, color Color) { crec := rec.cptr() - clineThick := (C.int)(lineThick) + clineThick := (C.float)(lineThick) ccolor := color.cptr() C.DrawRectangleLinesEx(*crec, clineThick, *ccolor) } @@ -254,11 +254,11 @@ func DrawRectangleRounded(rec Rectangle, roundness float32, segments int32, colo } // DrawRectangleRoundedLines - Draw rectangle with rounded edges outline -func DrawRectangleRoundedLines(rec Rectangle, roundness float32, segments, lineThick int32, color Color) { +func DrawRectangleRoundedLines(rec Rectangle, roundness float32, segments, lineThick float32, color Color) { crec := rec.cptr() croundness := (C.float)(roundness) csegments := (C.int)(segments) - clineThick := (C.int)(lineThick) + clineThick := (C.float)(lineThick) ccolor := color.cptr() C.DrawRectangleRoundedLines(*crec, croundness, csegments, clineThick, *ccolor) } diff --git a/raylib/text.go b/raylib/text.go index 93fe417..2148539 100644 --- a/raylib/text.go +++ b/raylib/text.go @@ -56,14 +56,14 @@ func LoadFontFromImage(image Image, key Color, firstChar int32) Font { } // LoadFontData - Load font data for further use -func LoadFontData(fileName string, fontSize int32, fontChars *int32, charsCount, typ int32) *CharInfo { - cfileName := C.CString(fileName) - defer C.free(unsafe.Pointer(cfileName)) +func LoadFontData(fileData []byte, dataSize int32, fontSize int32, fontChars *int32, charsCount, typ int32) *CharInfo { + cfileData := (*C.uchar)(unsafe.Pointer(&fileData[0])) + cdataSize := (C.int)(dataSize) cfontSize := (C.int)(fontSize) cfontChars := (*C.int)(unsafe.Pointer(fontChars)) ccharsCount := (C.int)(charsCount) ctype := (C.int)(typ) - ret := C.LoadFontData(cfileName, cfontSize, cfontChars, ccharsCount, ctype) + ret := C.LoadFontData(cfileData, cdataSize, cfontSize, cfontChars, ccharsCount, ctype) v := newCharInfoFromPointer(unsafe.Pointer(&ret)) return &v } diff --git a/raylib/textures.go b/raylib/textures.go index b9c487a..3c836d5 100644 --- a/raylib/textures.go +++ b/raylib/textures.go @@ -113,13 +113,6 @@ func GetImageData(img *Image) []Color { return (*[1 << 24]Color)(unsafe.Pointer(ret))[0 : img.Width*img.Height] } -// GetImageDataNormalized - Get pixel data from image as Vector4 slice (float normalized) -func GetImageDataNormalized(img *Image) []Vector4 { - cimg := img.cptr() - ret := C.GetImageDataNormalized(*cimg) - return (*[1 << 24]Vector4)(unsafe.Pointer(ret))[0 : img.Width*img.Height] -} - // GetPixelDataSize - Get pixel data size in bytes (image or texture) func GetPixelDataSize(width, height, format int32) int32 { cwidth := (C.int)(width)