From 198d7392560d1eb0dc7b9c8801a19492f753e734 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Tue, 1 May 2018 12:31:03 +0200 Subject: BREAKING CHANGE: Renamed Camera -> Camera3D Just added a fallback in the meantime... --- examples/core/core_3d_mode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/core') diff --git a/examples/core/core_3d_mode.c b/examples/core/core_3d_mode.c index 5f761655..a94ec648 100644 --- a/examples/core/core_3d_mode.c +++ b/examples/core/core_3d_mode.c @@ -21,7 +21,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode"); // Define the camera to look into our 3d world - Camera camera; + Camera3D camera; camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) -- cgit v1.2.3 From 6324697ffd7fd410274599457dd9f85119510898 Mon Sep 17 00:00:00 2001 From: Ray San Date: Fri, 4 May 2018 16:25:31 +0200 Subject: Rectangle parameters changed to float - Some examples tweaks - Reviewed ImageFormat() - Use float for text fontSize --- examples/core/core_3d_camera_free.c | 2 +- examples/textures/textures_image_generation.c | 2 +- examples/textures/textures_image_processing.c | 17 ++----- src/raylib.h | 16 +++--- src/shapes.c | 36 +++++++------- src/text.c | 8 +-- src/textures.c | 70 +++++++++++++-------------- 7 files changed, 71 insertions(+), 80 deletions(-) (limited to 'examples/core') diff --git a/examples/core/core_3d_camera_free.c b/examples/core/core_3d_camera_free.c index d446e14a..a583e706 100644 --- a/examples/core/core_3d_camera_free.c +++ b/examples/core/core_3d_camera_free.c @@ -21,7 +21,7 @@ int main() InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); // Define the camera to look into our 3d world - Camera camera; + Camera3D camera; camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) diff --git a/examples/textures/textures_image_generation.c b/examples/textures/textures_image_generation.c index 790c34f1..b9608c89 100644 --- a/examples/textures/textures_image_generation.c +++ b/examples/textures/textures_image_generation.c @@ -58,7 +58,7 @@ int main() { // Update //---------------------------------------------------------------------------------- - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsKeyPressed(KEY_RIGHT)) { currentTexture = (currentTexture + 1)%NUM_TEXTURES; // Cycle between the textures } diff --git a/examples/textures/textures_image_processing.c b/examples/textures/textures_image_processing.c index 58b746e0..427faa60 100644 --- a/examples/textures/textures_image_processing.c +++ b/examples/textures/textures_image_processing.c @@ -51,7 +51,7 @@ int main() // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) Image image = LoadImage("resources/parrots.png"); // Loaded in CPU memory (RAM) - ImageFormat(&image, UNCOMPRESSED_R8G8B8A8); // Format image to RGBA 32bit (required for texture update) + ImageFormat(&image, UNCOMPRESSED_R8G8B8A8); // Format image to RGBA 32bit (required for texture update) <-- ISSUE Texture2D texture = LoadTextureFromImage(image); // Image converted to texture, GPU memory (VRAM) int currentProcess = NONE; @@ -121,18 +121,9 @@ int main() // Draw rectangles for (int i = 0; i < NUM_PROCESSES; i++) { - if (i == currentProcess) - { - DrawRectangleRec(selectRecs[i], SKYBLUE); - DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, BLUE); - DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, DARKBLUE); - } - else - { - DrawRectangleRec(selectRecs[i], LIGHTGRAY); - DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, GRAY); - DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, DARKGRAY); - } + DrawRectangleRec(selectRecs[i], (i == currentProcess) ? SKYBLUE : LIGHTGRAY); + DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, (i == currentProcess) ? BLUE : GRAY); + DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, (i == currentProcess) ? DARKBLUE : DARKGRAY); } DrawTexture(texture, screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, WHITE); diff --git a/src/raylib.h b/src/raylib.h index 7afb9fe1..6d3aaaf9 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -349,10 +349,10 @@ typedef struct Color { // Rectangle type typedef struct Rectangle { - int x; - int y; - int width; - int height; + float x; + float y; + float width; + float height; } Rectangle; // Image type, bpp always RGBA (32bit) @@ -915,11 +915,11 @@ RLAPI void ImageResizeNN(Image *image,int newWidth,int newHeight); RLAPI void ImageMipmaps(Image *image); // Generate all mipmap levels for a provided image RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font) -RLAPI Image ImageTextEx(SpriteFont font, const char *text, float fontSize, int spacing, Color tint); // Create an image from text (custom sprite font) +RLAPI Image ImageTextEx(SpriteFont font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font) RLAPI void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec); // Draw a source image within a destination image RLAPI void ImageDrawRectangle(Image *dst, Vector2 position, Rectangle rec, Color color); // Draw rectangle within an image RLAPI void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color); // Draw text (default font) within an image (destination) -RLAPI void ImageDrawTextEx(Image *dst, Vector2 position, SpriteFont font, const char *text, float fontSize, int spacing, Color color); // Draw text (custom sprite font) within an image (destination) +RLAPI void ImageDrawTextEx(Image *dst, Vector2 position, SpriteFont font, const char *text, float fontSize, float spacing, Color color); // Draw text (custom sprite font) within an image (destination) RLAPI void ImageFlipVertical(Image *image); // Flip image vertically RLAPI void ImageFlipHorizontal(Image *image); // Flip image horizontally RLAPI void ImageColorTint(Image *image, Color color); // Modify image color: tint @@ -964,11 +964,11 @@ RLAPI void UnloadSpriteFont(SpriteFont font); // Text drawing functions RLAPI void DrawFPS(int posX, int posY); // Shows current FPS RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) -RLAPI void DrawTextEx(SpriteFont font, const char* text, Vector2 position, float fontSize, int spacing, Color tint); // Draw text using SpriteFont and additional parameters +RLAPI void DrawTextEx(SpriteFont font, const char* text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using SpriteFont and additional parameters // Text misc. functions RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font -RLAPI Vector2 MeasureTextEx(SpriteFont font, const char *text, float fontSize, int spacing); // Measure string size for SpriteFont +RLAPI Vector2 MeasureTextEx(SpriteFont font, const char *text, float fontSize, float spacing); // Measure string size for SpriteFont RLAPI const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed' RLAPI const char *SubText(const char *text, int position, int length); // Get a piece of a text string RLAPI int GetGlyphIndex(SpriteFont font, int character); // Returns index position for a unicode character on sprite font diff --git a/src/shapes.c b/src/shapes.c index d8e52b04..ed911b26 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -324,7 +324,7 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color rlEnableTexture(GetTextureDefault().id); rlPushMatrix(); - rlTranslatef((float)rec.x, (float)rec.y, 0); + rlTranslatef(rec.x, rec.y, 0); rlRotatef(rotation, 0, 0, 1); rlTranslatef(-origin.x, -origin.y, 0); @@ -333,9 +333,9 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color rlNormal3f(0.0f, 0.0f, 1.0f); // Normal vector pointing towards viewer rlVertex2f(0.0f, 0.0f); - rlVertex2f(0.0f, (float)rec.height); - rlVertex2f((float)rec.width, (float)rec.height); - rlVertex2f((float)rec.width, 0.0f); + rlVertex2f(0.0f, rec.height); + rlVertex2f(rec.width, rec.height); + rlVertex2f(rec.width, 0.0f); rlEnd(); rlPopMatrix(); @@ -369,23 +369,23 @@ void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, // NOTE: Default raylib font character 95 is a white square rlColor4ub(col1.r, col1.g, col1.b, col1.a); - rlTexCoord2f((float)GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width, - (float)GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height); + rlTexCoord2f(GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width, + GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height); rlVertex2f(rec.x, rec.y); rlColor4ub(col2.r, col2.g, col2.b, col2.a); - rlTexCoord2f((float)GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width, - (float)(GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height); + rlTexCoord2f(GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width, + (GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height); rlVertex2f(rec.x, rec.y + rec.height); rlColor4ub(col3.r, col3.g, col3.b, col3.a); - rlTexCoord2f((float)(GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width, - (float)(GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height); + rlTexCoord2f((GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width, + (GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height); rlVertex2f(rec.x + rec.width, rec.y + rec.height); rlColor4ub(col4.r, col4.g, col4.b, col4.a); - rlTexCoord2f((float)(GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width, - (float)GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height); + rlTexCoord2f((GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width, + GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height); rlVertex2f(rec.x + rec.width, rec.y); rlEnd(); @@ -667,14 +667,14 @@ bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec) float dx = fabsf(center.x - recCenterX); float dy = fabsf(center.y - recCenterY); - if (dx > ((float)rec.width/2.0f + radius)) { return false; } - if (dy > ((float)rec.height/2.0f + radius)) { return false; } + if (dx > (rec.width/2.0f + radius)) { return false; } + if (dy > (rec.height/2.0f + radius)) { return false; } - if (dx <= ((float)rec.width/2.0f)) { return true; } - if (dy <= ((float)rec.height/2.0f)) { return true; } + if (dx <= (rec.width/2.0f)) { return true; } + if (dy <= (rec.height/2.0f)) { return true; } - float cornerDistanceSq = (dx - (float)rec.width/2.0f)*(dx - (float)rec.width/2.0f) + - (dy - (float)rec.height/2.0f)*(dy - (float)rec.height/2.0f); + float cornerDistanceSq = (dx - rec.width/2.0f)*(dx - rec.width/2.0f) + + (dy - rec.height/2.0f)*(dy - rec.height/2.0f); return (cornerDistanceSq <= (radius*radius)); } diff --git a/src/text.c b/src/text.c index 1a9d386a..7cc091bc 100644 --- a/src/text.c +++ b/src/text.c @@ -364,13 +364,13 @@ void DrawText(const char *text, int posX, int posY, int fontSize, Color color) if (fontSize < defaultFontSize) fontSize = defaultFontSize; int spacing = fontSize/defaultFontSize; - DrawTextEx(GetDefaultFont(), text, position, (float)fontSize, spacing, color); + DrawTextEx(GetDefaultFont(), text, position, (float)fontSize, (float)spacing, color); } } // Draw text using SpriteFont // NOTE: chars spacing is NOT proportional to fontSize -void DrawTextEx(SpriteFont font, const char *text, Vector2 position, float fontSize, int spacing, Color tint) +void DrawTextEx(SpriteFont font, const char *text, Vector2 position, float fontSize, float spacing, Color tint) { int length = strlen(text); int textOffsetX = 0; // Offset between characters @@ -476,14 +476,14 @@ int MeasureText(const char *text, int fontSize) if (fontSize < defaultFontSize) fontSize = defaultFontSize; int spacing = fontSize/defaultFontSize; - vec = MeasureTextEx(GetDefaultFont(), text, (float)fontSize, spacing); + vec = MeasureTextEx(GetDefaultFont(), text, (float)fontSize, (float)spacing); } return (int)vec.x; } // Measure string size for SpriteFont -Vector2 MeasureTextEx(SpriteFont font, const char *text, float fontSize, int spacing) +Vector2 MeasureTextEx(SpriteFont font, const char *text, float fontSize, float spacing) { int len = strlen(text); int tempLen = 0; // Used to count longer text line num chars diff --git a/src/textures.c b/src/textures.c index eadb0c59..726257b8 100644 --- a/src/textures.c +++ b/src/textures.c @@ -713,7 +713,7 @@ void ImageFormat(Image *image, int newFormat) { image->data = (unsigned char *)malloc(image->width*image->height*3*sizeof(unsigned char)); - for (int i = 0; i < image->width*image->height*3; i += 3, k++) + for (int i = 0, k = 0; i < image->width*image->height*3; i += 3, k++) { ((unsigned char *)image->data)[i] = pixels[k].r; ((unsigned char *)image->data)[i + 1] = pixels[k].g; @@ -766,7 +766,7 @@ void ImageFormat(Image *image, int newFormat) { image->data = (unsigned char *)malloc(image->width*image->height*4*sizeof(unsigned char)); - for (int i = 0; i < image->width*image->height*3; i += 3, k++) + for (int i = 0, k = 0; i < image->width*image->height*4; i += 4, k++) { ((unsigned char *)image->data)[i] = pixels[k].r; ((unsigned char *)image->data)[i + 1] = pixels[k].g; @@ -787,7 +787,7 @@ void ImageFormat(Image *image, int newFormat) { image->data = (float *)malloc(image->width*image->height*3*sizeof(float)); - for (int i = 0; i < image->width*image->height*3; i += 3, k++) + for (int i = 0, k = 0; i < image->width*image->height*3; i += 3, k++) { ((float *)image->data)[i] = (float)pixels[k].r/255.0f; ((float *)image->data)[i + 1] = (float)pixels[k].g/255.0f; @@ -798,7 +798,7 @@ void ImageFormat(Image *image, int newFormat) { image->data = (float *)malloc(image->width*image->height*4*sizeof(float)); - for (int i = 0; i < image->width*image->height*4; i += 4, k++) + for (int i = 0, k = 0; i < image->width*image->height*4; i += 4, k++) { ((float *)image->data)[i] = (float)pixels[k].r/255.0f; ((float *)image->data)[i + 1] = (float)pixels[k].g/255.0f; @@ -977,13 +977,13 @@ void ImageCrop(Image *image, Rectangle crop) { // Start the cropping process Color *pixels = GetImageData(*image); // Get data as Color pixels array - Color *cropPixels = (Color *)malloc(crop.width*crop.height*sizeof(Color)); + Color *cropPixels = (Color *)malloc((int)crop.width*(int)crop.height*sizeof(Color)); - for (int j = crop.y; j < (crop.y + crop.height); j++) + for (int j = (int)crop.y; j < (int)(crop.y + crop.height); j++) { - for (int i = crop.x; i < (crop.x + crop.width); i++) + for (int i = (int)crop.x; i < (int)(crop.x + crop.width); i++) { - cropPixels[(j - crop.y)*crop.width + (i - crop.x)] = pixels[j*image->width + i]; + cropPixels[(j - (int)crop.y)*(int)crop.width + (i - (int)crop.x)] = pixels[j*image->width + i]; } } @@ -993,7 +993,7 @@ void ImageCrop(Image *image, Rectangle crop) UnloadImage(*image); - *image = LoadImageEx(cropPixels, crop.width, crop.height); + *image = LoadImageEx(cropPixels, (int)crop.width, (int)crop.height); free(cropPixels); @@ -1316,14 +1316,14 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec) // Blit pixels, copy source image into destination // TODO: Probably out-of-bounds blitting could be considered here instead of so much cropping... - for (int j = dstRec.y; j < (dstRec.y + dstRec.height); j++) + for (int j = (int)dstRec.y; j < (int)(dstRec.y + dstRec.height); j++) { - for (int i = dstRec.x; i < (dstRec.x + dstRec.width); i++) + for (int i = (int)dstRec.x; i < (int)(dstRec.x + dstRec.width); i++) { // Alpha blending (https://en.wikipedia.org/wiki/Alpha_compositing) - fdst = ColorNormalize(dstPixels[j*dst->width + i]); - fsrc = ColorNormalize(srcPixels[(j - dstRec.y)*dstRec.width + (i - dstRec.x)]); + fdst = ColorNormalize(dstPixels[j*(int)dst->width + i]); + fsrc = ColorNormalize(srcPixels[(j - (int)dstRec.y)*(int)dstRec.width + (i - (int)dstRec.x)]); fout.w = fsrc.w + fdst.w*(1.0f - fsrc.w); @@ -1340,10 +1340,10 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec) fout.z = (fsrc.z*fsrc.w + fdst.z*fdst.w*(1 - fsrc.w))/fout.w; } - dstPixels[j*dst->width + i] = (Color){ (unsigned char)(fout.x*255.0f), - (unsigned char)(fout.y*255.0f), - (unsigned char)(fout.z*255.0f), - (unsigned char)(fout.w*255.0f) }; + dstPixels[j*(int)dst->width + i] = (Color){ (unsigned char)(fout.x*255.0f), + (unsigned char)(fout.y*255.0f), + (unsigned char)(fout.z*255.0f), + (unsigned char)(fout.w*255.0f) }; // TODO: Support other blending options } @@ -1351,7 +1351,7 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec) UnloadImage(*dst); // NOTE: Only dst->data is unloaded - *dst = LoadImageEx(dstPixels, dst->width, dst->height); + *dst = LoadImageEx(dstPixels, (int)dst->width, (int)dst->height); ImageFormat(dst, dst->format); free(srcPixels); @@ -1363,15 +1363,15 @@ Image ImageText(const char *text, int fontSize, Color color) { int defaultFontSize = 10; // Default Font chars height in pixel if (fontSize < defaultFontSize) fontSize = defaultFontSize; - int spacing = fontSize/defaultFontSize; + int spacing = (float)fontSize/defaultFontSize; - Image imText = ImageTextEx(GetDefaultFont(), text, (float)fontSize, spacing, color); + Image imText = ImageTextEx(GetDefaultFont(), text, (float)fontSize, (float)spacing, color); return imText; } // Create an image from text (custom sprite font) -Image ImageTextEx(SpriteFont font, const char *text, float fontSize, int spacing, Color tint) +Image ImageTextEx(SpriteFont font, const char *text, float fontSize, float spacing, Color tint) { int length = strlen(text); int posX = 0; @@ -1451,7 +1451,7 @@ void ImageDrawRectangle(Image *dst, Vector2 position, Rectangle rec, Color color { Image imRec = GenImageColor(rec.width, rec.height, color); - Rectangle dstRec = { (int)position.x, (int)position.y, imRec.width, imRec.height }; + Rectangle dstRec = { position.x, position.y, imRec.width, imRec.height }; ImageDraw(dst, imRec, rec, dstRec); @@ -1462,16 +1462,16 @@ void ImageDrawRectangle(Image *dst, Vector2 position, Rectangle rec, Color color void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color) { // NOTE: For default font, sapcing is set to desired font size / default font size (10) - ImageDrawTextEx(dst, position, GetDefaultFont(), text, (float)fontSize, fontSize/10, color); + ImageDrawTextEx(dst, position, GetDefaultFont(), text, (float)fontSize, (float)fontSize/10, color); } // Draw text (custom sprite font) within an image (destination) -void ImageDrawTextEx(Image *dst, Vector2 position, SpriteFont font, const char *text, float fontSize, int spacing, Color color) +void ImageDrawTextEx(Image *dst, Vector2 position, SpriteFont font, const char *text, float fontSize, float spacing, Color color) { Image imText = ImageTextEx(font, text, fontSize, spacing, color); Rectangle srcRec = { 0, 0, imText.width, imText.height }; - Rectangle dstRec = { (int)position.x, (int)position.y, imText.width, imText.height }; + Rectangle dstRec = { position.x, position.y, imText.width, imText.height }; ImageDraw(dst, imText, srcRec, dstRec); @@ -2020,7 +2020,7 @@ void DrawTextureV(Texture2D texture, Vector2 position, Color tint) void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint) { Rectangle sourceRec = { 0, 0, texture.width, texture.height }; - Rectangle destRec = { (int)position.x, (int)position.y, texture.width*scale, texture.height*scale }; + Rectangle destRec = { position.x, position.y, texture.width*scale, texture.height*scale }; Vector2 origin = { 0, 0 }; DrawTexturePro(texture, sourceRec, destRec, origin, rotation, tint); @@ -2029,7 +2029,7 @@ void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float sc // Draw a part of a texture (defined by a rectangle) void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint) { - Rectangle destRec = { (int)position.x, (int)position.y, abs(sourceRec.width), abs(sourceRec.height) }; + Rectangle destRec = { position.x, position.y, sourceRec.width, sourceRec.height }; Vector2 origin = { 0, 0 }; DrawTexturePro(texture, sourceRec, destRec, origin, 0.0f, tint); @@ -2048,7 +2048,7 @@ void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, V rlEnableTexture(texture.id); rlPushMatrix(); - rlTranslatef((float)destRec.x, (float)destRec.y, 0); + rlTranslatef(destRec.x, destRec.y, 0); rlRotatef(rotation, 0, 0, 1); rlTranslatef(-origin.x, -origin.y, 0); @@ -2057,20 +2057,20 @@ void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, V rlNormal3f(0.0f, 0.0f, 1.0f); // Normal vector pointing towards viewer // Bottom-left corner for texture and quad - rlTexCoord2f((float)sourceRec.x/texture.width, (float)sourceRec.y/texture.height); + rlTexCoord2f(sourceRec.x/texture.width, sourceRec.y/texture.height); rlVertex2f(0.0f, 0.0f); // Bottom-right corner for texture and quad - rlTexCoord2f((float)sourceRec.x/texture.width, (float)(sourceRec.y + sourceRec.height)/texture.height); - rlVertex2f(0.0f, (float)destRec.height); + rlTexCoord2f(sourceRec.x/texture.width, (sourceRec.y + sourceRec.height)/texture.height); + rlVertex2f(0.0f, destRec.height); // Top-right corner for texture and quad - rlTexCoord2f((float)(sourceRec.x + sourceRec.width)/texture.width, (float)(sourceRec.y + sourceRec.height)/texture.height); - rlVertex2f((float)destRec.width, (float)destRec.height); + rlTexCoord2f((sourceRec.x + sourceRec.width)/texture.width, (sourceRec.y + sourceRec.height)/texture.height); + rlVertex2f(destRec.width, destRec.height); // Top-left corner for texture and quad - rlTexCoord2f((float)(sourceRec.x + sourceRec.width)/texture.width, (float)sourceRec.y/texture.height); - rlVertex2f((float)destRec.width, 0.0f); + rlTexCoord2f((sourceRec.x + sourceRec.width)/texture.width, sourceRec.y/texture.height); + rlVertex2f(destRec.width, 0.0f); rlEnd(); rlPopMatrix(); -- cgit v1.2.3 From 6045062a05a0cc5bd654ad2c2e7d88f94579cd73 Mon Sep 17 00:00:00 2001 From: Ray San Date: Fri, 4 May 2018 16:54:05 +0200 Subject: Renamed some functions - Renamed Begin3dMode() --> BeginMode3D() - Renamed Begin2dMode() --> BeginMode2D() - Renamed End3dMode() --> EndMode3D() - Renamed End2dMode() --> EndMode2D() --- examples/core/core_2d_camera.c | 4 ++-- examples/core/core_3d_camera_first_person.c | 4 ++-- examples/core/core_3d_camera_free.c | 4 ++-- examples/core/core_3d_mode.c | 4 ++-- examples/core/core_3d_picking.c | 4 ++-- examples/core/core_vr_simulator.c | 4 ++-- examples/core/core_world_screen.c | 4 ++-- examples/models/models_billboard.c | 4 ++-- examples/models/models_box_collisions.c | 4 ++-- examples/models/models_cubicmap.c | 4 ++-- examples/models/models_geometric_shapes.c | 4 ++-- examples/models/models_heightmap.c | 4 ++-- examples/models/models_material_pbr.c | 4 ++-- examples/models/models_mesh_generation.c | 4 ++-- examples/models/models_mesh_picking.c | 4 ++-- examples/models/models_obj_loading.c | 4 ++-- examples/models/models_orthographic_projection.c | 4 ++-- examples/models/models_skybox.c | 4 ++-- examples/models/models_yaw_pitch_roll.c | 4 ++-- examples/others/oculus_rift.c | 4 ++-- examples/others/standard_lighting.c | 4 ++-- examples/shaders/shaders_custom_uniform.c | 4 ++-- examples/shaders/shaders_model_shader.c | 4 ++-- examples/shaders/shaders_postprocessing.c | 4 ++-- src/core.c | 12 ++++++------ src/raylib.h | 10 +++++----- src/rlgl.c | 2 +- 27 files changed, 60 insertions(+), 60 deletions(-) (limited to 'examples/core') diff --git a/examples/core/core_2d_camera.c b/examples/core/core_2d_camera.c index f2f219ef..7c35c907 100644 --- a/examples/core/core_2d_camera.c +++ b/examples/core/core_2d_camera.c @@ -97,7 +97,7 @@ int main() ClearBackground(RAYWHITE); - Begin2dMode(camera); + BeginMode2D(camera); DrawRectangle(-6000, 320, 13000, 8000, DARKGRAY); @@ -108,7 +108,7 @@ int main() DrawRectangle(camera.target.x, -500, 1, screenHeight*4, GREEN); DrawRectangle(-500, camera.target.y, screenWidth*4, 1, GREEN); - End2dMode(); + EndMode2D(); DrawText("SCREEN AREA", 640, 10, 20, RED); diff --git a/examples/core/core_3d_camera_first_person.c b/examples/core/core_3d_camera_first_person.c index 775e6c57..d3a8f2e4 100644 --- a/examples/core/core_3d_camera_first_person.c +++ b/examples/core/core_3d_camera_first_person.c @@ -61,7 +61,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawPlane((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector2){ 32.0f, 32.0f }, LIGHTGRAY); // Draw ground DrawCube((Vector3){ -16.0f, 2.5f, 0.0f }, 1.0f, 5.0f, 32.0f, BLUE); // Draw a blue wall @@ -75,7 +75,7 @@ int main() DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, MAROON); } - End3dMode(); + EndMode3D(); DrawRectangle( 10, 10, 220, 70, Fade(SKYBLUE, 0.5f)); DrawRectangleLines( 10, 10, 220, 70, BLUE); diff --git a/examples/core/core_3d_camera_free.c b/examples/core/core_3d_camera_free.c index a583e706..81f04c13 100644 --- a/examples/core/core_3d_camera_free.c +++ b/examples/core/core_3d_camera_free.c @@ -50,14 +50,14 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); DrawGrid(10, 1.0f); - End3dMode(); + EndMode3D(); DrawRectangle( 10, 10, 320, 133, Fade(SKYBLUE, 0.5f)); DrawRectangleLines( 10, 10, 320, 133, BLUE); diff --git a/examples/core/core_3d_mode.c b/examples/core/core_3d_mode.c index a94ec648..705bcb7a 100644 --- a/examples/core/core_3d_mode.c +++ b/examples/core/core_3d_mode.c @@ -46,14 +46,14 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); DrawGrid(10, 1.0f); - End3dMode(); + EndMode3D(); DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY); diff --git a/examples/core/core_3d_picking.c b/examples/core/core_3d_picking.c index 56e80f2a..cd390d91 100644 --- a/examples/core/core_3d_picking.c +++ b/examples/core/core_3d_picking.c @@ -63,7 +63,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); if (collision) { @@ -81,7 +81,7 @@ int main() DrawRay(ray, MAROON); DrawGrid(10, 1.0f); - End3dMode(); + EndMode3D(); DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY); diff --git a/examples/core/core_vr_simulator.c b/examples/core/core_vr_simulator.c index d919c410..35136114 100644 --- a/examples/core/core_vr_simulator.c +++ b/examples/core/core_vr_simulator.c @@ -57,14 +57,14 @@ int main() BeginVrDrawing(); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); DrawGrid(40, 1.0f); - End3dMode(); + EndMode3D(); EndVrDrawing(); diff --git a/examples/core/core_world_screen.c b/examples/core/core_world_screen.c index 78ca6eb4..460f6b85 100644 --- a/examples/core/core_world_screen.c +++ b/examples/core/core_world_screen.c @@ -54,14 +54,14 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); DrawGrid(10, 1.0f); - End3dMode(); + EndMode3D(); DrawText("Enemy: 100 / 100", cubeScreenPosition.x - MeasureText("Enemy: 100 / 100", 20) / 2, cubeScreenPosition.y, 20, BLACK); DrawText("Text is always on top of the cube", (screenWidth - MeasureText("Text is always on top of the cube", 20)) / 2, 25, 20, GRAY); diff --git a/examples/models/models_billboard.c b/examples/models/models_billboard.c index 3b3efc47..8ce6a44f 100644 --- a/examples/models/models_billboard.c +++ b/examples/models/models_billboard.c @@ -51,13 +51,13 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawBillboard(camera, bill, billPosition, 2.0f, WHITE); DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawFPS(10, 10); diff --git a/examples/models/models_box_collisions.c b/examples/models/models_box_collisions.c index eb72c54c..41f6056c 100644 --- a/examples/models/models_box_collisions.c +++ b/examples/models/models_box_collisions.c @@ -87,7 +87,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); // Draw enemy-box DrawCube(enemyBoxPos, enemyBoxSize.x, enemyBoxSize.y, enemyBoxSize.z, GRAY); @@ -102,7 +102,7 @@ int main() DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawText("Move player with cursors to collide", 220, 40, 20, GRAY); diff --git a/examples/models/models_cubicmap.c b/examples/models/models_cubicmap.c index 47b88748..c8d62c46 100644 --- a/examples/models/models_cubicmap.c +++ b/examples/models/models_cubicmap.c @@ -56,11 +56,11 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(model, mapPosition, 1.0f, WHITE); - End3dMode(); + EndMode3D(); DrawTextureEx(cubicmap, (Vector2){ screenWidth - cubicmap.width*4 - 20, 20 }, 0.0f, 4.0f, WHITE); DrawRectangleLines(screenWidth - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN); diff --git a/examples/models/models_geometric_shapes.c b/examples/models/models_geometric_shapes.c index 7a1e7e48..82ca4c60 100644 --- a/examples/models/models_geometric_shapes.c +++ b/examples/models/models_geometric_shapes.c @@ -45,7 +45,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED); DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD); @@ -63,7 +63,7 @@ int main() DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawFPS(10, 10); diff --git a/examples/models/models_heightmap.c b/examples/models/models_heightmap.c index 55474185..d131b127 100644 --- a/examples/models/models_heightmap.c +++ b/examples/models/models_heightmap.c @@ -53,13 +53,13 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(model, mapPosition, 1.0f, RED); DrawGrid(20, 1.0f); - End3dMode(); + EndMode3D(); DrawTexture(texture, screenWidth - texture.width - 20, 20, WHITE); DrawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, GREEN); diff --git a/examples/models/models_material_pbr.c b/examples/models/models_material_pbr.c index ee13fddf..33f13e2c 100644 --- a/examples/models/models_material_pbr.c +++ b/examples/models/models_material_pbr.c @@ -73,13 +73,13 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(model, Vector3Zero(), 1.0f, WHITE); DrawGrid(10, 1.0f); - End3dMode(); + EndMode3D(); DrawFPS(10, 10); diff --git a/examples/models/models_mesh_generation.c b/examples/models/models_mesh_generation.c index d9c28ac2..c02bd91a 100644 --- a/examples/models/models_mesh_generation.c +++ b/examples/models/models_mesh_generation.c @@ -72,13 +72,13 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(models[currentModel], position, 1.0f, WHITE); DrawGrid(10, 1.0); - End3dMode(); + EndMode3D(); DrawRectangle(30, 400, 310, 30, Fade(SKYBLUE, 0.5f)); DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f)); diff --git a/examples/models/models_mesh_picking.c b/examples/models/models_mesh_picking.c index e09f9860..17b8812d 100644 --- a/examples/models/models_mesh_picking.c +++ b/examples/models/models_mesh_picking.c @@ -120,7 +120,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); // Draw the tower DrawModel(tower, towerPos, 1.0, WHITE); @@ -151,7 +151,7 @@ int main() DrawGrid(100, 1.0f); - End3dMode(); + EndMode3D(); // Draw some debug GUI text DrawText(FormatText("Hit Object: %s", hitObjectName), 10, 50, 10, BLACK); diff --git a/examples/models/models_obj_loading.c b/examples/models/models_obj_loading.c index 4f89130f..4e9b2986 100644 --- a/examples/models/models_obj_loading.c +++ b/examples/models/models_obj_loading.c @@ -50,7 +50,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture @@ -58,7 +58,7 @@ int main() DrawGizmo(position); // Draw gizmo - End3dMode(); + EndMode3D(); DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY); diff --git a/examples/models/models_orthographic_projection.c b/examples/models/models_orthographic_projection.c index cb5ea053..f9b54b6d 100644 --- a/examples/models/models_orthographic_projection.c +++ b/examples/models/models_orthographic_projection.c @@ -57,7 +57,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED); DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD); @@ -75,7 +75,7 @@ int main() DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawText("Press Spacebar to switch camera type", 10, GetScreenHeight() - 30, 20, DARKGRAY); diff --git a/examples/models/models_skybox.c b/examples/models/models_skybox.c index 700824d3..589f139b 100644 --- a/examples/models/models_skybox.c +++ b/examples/models/models_skybox.c @@ -60,13 +60,13 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(skybox, (Vector3){0, 0, 0}, 1.0f, WHITE); DrawGrid(10, 1.0f); - End3dMode(); + EndMode3D(); DrawFPS(10, 10); diff --git a/examples/models/models_yaw_pitch_roll.c b/examples/models/models_yaw_pitch_roll.c index c559e67b..0dcf8c70 100644 --- a/examples/models/models_yaw_pitch_roll.c +++ b/examples/models/models_yaw_pitch_roll.c @@ -137,12 +137,12 @@ int main() EndTextureMode(); // Draw 3D model (recomended to draw 3D always before 2D) - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(model, (Vector3){ 0, 6.0f, 0 }, 1.0f, WHITE); // Draw 3d model with texture DrawGrid(10, 10.0f); - End3dMode(); + EndMode3D(); // Draw 2D GUI stuff DrawAngleGauge(texAngleGauge, 80, 70, roll, "roll", RED); diff --git a/examples/others/oculus_rift.c b/examples/others/oculus_rift.c index af2a87c1..cdfa5f11 100644 --- a/examples/others/oculus_rift.c +++ b/examples/others/oculus_rift.c @@ -151,14 +151,14 @@ int main() if (vrDeviceReady) BeginOculusDrawing(); else BeginVrDrawing(); - Begin3dMode(camera); + BeginMode3D(camera); DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED); DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON); DrawGrid(40, 1.0f); - End3dMode(); + EndMode3D(); if (vrDeviceReady) EndOculusDrawing(); else EndVrDrawing(); diff --git a/examples/others/standard_lighting.c b/examples/others/standard_lighting.c index a7f634e2..f450a2a5 100644 --- a/examples/others/standard_lighting.c +++ b/examples/others/standard_lighting.c @@ -159,7 +159,7 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture @@ -169,7 +169,7 @@ int main() DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY); diff --git a/examples/shaders/shaders_custom_uniform.c b/examples/shaders/shaders_custom_uniform.c index 4e160455..ddee4187 100644 --- a/examples/shaders/shaders_custom_uniform.c +++ b/examples/shaders/shaders_custom_uniform.c @@ -85,13 +85,13 @@ int main() BeginTextureMode(target); // Enable drawing to texture - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, RED); diff --git a/examples/shaders/shaders_model_shader.c b/examples/shaders/shaders_model_shader.c index 51acc836..3ce9c6a3 100644 --- a/examples/shaders/shaders_model_shader.c +++ b/examples/shaders/shaders_model_shader.c @@ -66,13 +66,13 @@ int main() ClearBackground(RAYWHITE); - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY); diff --git a/examples/shaders/shaders_postprocessing.c b/examples/shaders/shaders_postprocessing.c index 5eeda896..80660d68 100644 --- a/examples/shaders/shaders_postprocessing.c +++ b/examples/shaders/shaders_postprocessing.c @@ -130,13 +130,13 @@ int main() BeginTextureMode(target); // Enable drawing to texture - Begin3dMode(camera); + BeginMode3D(camera); DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture DrawGrid(10, 1.0f); // Draw a grid - End3dMode(); + EndMode3D(); EndTextureMode(); // End drawing to texture (now we have a texture available for next passes) diff --git a/src/core.c b/src/core.c index 3f071fc6..5587f82b 100644 --- a/src/core.c +++ b/src/core.c @@ -117,7 +117,7 @@ #include // Required for: malloc(), free(), rand(), atexit() #include // Required for: typedef unsigned long long int uint64_t, used by hi-res timer #include // Required for: time() - Android/RPI hi-res timer (NOTE: Linux only!) -#include // Required for: tan() [Used in Begin3dMode() to set perspective] +#include // Required for: tan() [Used in BeginMode3D() to set perspective] #include // Required for: strrchr(), strcmp() //#include // Macros for reporting and retrieving error conditions through error codes #include // Required for: tolower() [Used in IsFileExtension()] @@ -888,7 +888,7 @@ void EndDrawing(void) } // Initialize 2D mode with custom camera (2D) -void Begin2dMode(Camera2D camera) +void BeginMode2D(Camera2D camera) { rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2) @@ -906,7 +906,7 @@ void Begin2dMode(Camera2D camera) } // Ends 2D mode with custom camera -void End2dMode(void) +void EndMode2D(void) { rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2) @@ -914,7 +914,7 @@ void End2dMode(void) } // Initializes 3D mode with custom camera (3D) -void Begin3dMode(Camera camera) +void BeginMode3D(Camera3D camera) { rlglDraw(); // Draw Buffers (Only OpenGL 3+ and ES2) @@ -954,7 +954,7 @@ void Begin3dMode(Camera camera) } // Ends 3D mode and returns to default 2D orthographic mode -void End3dMode(void) +void EndMode3D(void) { rlglDraw(); // Process internal buffers (update + draw) @@ -2912,7 +2912,7 @@ static void WindowSizeCallback(GLFWwindow *window, int width, int height) rlLoadIdentity(); // Reset current matrix (MODELVIEW) rlClearScreenBuffers(); // Clear screen buffers (color and depth) - // Window size must be updated to be used on 3D mode to get new aspect ratio (Begin3dMode()) + // Window size must be updated to be used on 3D mode to get new aspect ratio (BeginMode3D()) // NOTE: Be careful! GLFW3 will choose the closest fullscreen resolution supported by current monitor, // for example, if reescaling back to 800x450 (desired), it could set 720x480 (closest fullscreen supported) screenWidth = width; diff --git a/src/raylib.h b/src/raylib.h index 6d3aaaf9..b5a6a191 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -6,7 +6,7 @@ * - Written in plain C code (C99) in PascalCase/camelCase notation * - Hardware accelerated with OpenGL (1.1, 2.1, 3.3 or ES2 - choose at compile) * - Unique OpenGL abstraction layer (usable as standalone module): [rlgl] -* - Powerful fonts module with SpriteFonts support (XNA fonts, AngelCode fonts, TTF) +* - Powerful fonts module with Fonts support (XNA fonts, AngelCode fonts, TTF) * - Outstanding texture formats support, including compressed formats (DXT, ETC, ASTC) * - Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more! * - Flexible Materials system, supporting classic maps and PBR maps @@ -728,10 +728,10 @@ RLAPI void DisableCursor(void); // Disables cu RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color) RLAPI void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing RLAPI void EndDrawing(void); // End canvas drawing and swap buffers (double buffering) -RLAPI void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D) -RLAPI void End2dMode(void); // Ends 2D mode with custom camera -RLAPI void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D) -RLAPI void End3dMode(void); // Ends 3D mode and returns to default 2D orthographic mode +RLAPI void BeginMode2D(Camera2D camera); // Initialize 2D mode with custom camera (2D) +RLAPI void EndMode2D(void); // Ends 2D mode with custom camera +RLAPI void BeginMode3D(Camera3D camera); // Initializes 3D mode with custom camera (3D) +RLAPI void EndMode3D(void); // Ends 3D mode and returns to default 2D orthographic mode RLAPI void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing RLAPI void EndTextureMode(void); // Ends drawing to render texture diff --git a/src/rlgl.c b/src/rlgl.c index 68bd3670..93a0b0f8 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -1947,7 +1947,7 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform) if (material.shader.locs[LOC_MATRIX_PROJECTION] != -1) SetShaderValueMatrix(material.shader, material.shader.locs[LOC_MATRIX_PROJECTION], projection); // At this point the modelview matrix just contains the view matrix (camera) - // That's because Begin3dMode() sets it an no model-drawing function modifies it, all use rlPushMatrix() and rlPopMatrix() + // That's because BeginMode3D() sets it an no model-drawing function modifies it, all use rlPushMatrix() and rlPopMatrix() Matrix matView = modelview; // View matrix (camera) Matrix matProjection = projection; // Projection matrix (perspective) -- cgit v1.2.3 From 245704df723343fd274f77589164c6e9984aef8b Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 11 May 2018 18:14:51 +0200 Subject: Reviewed examples --- examples/core/core_3d_camera_free.c | 1 + examples/core/core_3d_mode.c | 1 + examples/core/core_3d_picking.c | 1 + examples/core/core_input_keys.c | 8 ++++---- examples/models/models_mesh_picking.c | 1 + examples/models/models_obj_loading.c | 10 +++++----- 6 files changed, 13 insertions(+), 9 deletions(-) (limited to 'examples/core') diff --git a/examples/core/core_3d_camera_free.c b/examples/core/core_3d_camera_free.c index 81f04c13..9131ddf8 100644 --- a/examples/core/core_3d_camera_free.c +++ b/examples/core/core_3d_camera_free.c @@ -26,6 +26,7 @@ int main() camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) camera.fovy = 45.0f; // Camera field-of-view Y + camera.type = CAMERA_PERSPECTIVE; // Camera mode type Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; diff --git a/examples/core/core_3d_mode.c b/examples/core/core_3d_mode.c index 705bcb7a..39c0752a 100644 --- a/examples/core/core_3d_mode.c +++ b/examples/core/core_3d_mode.c @@ -26,6 +26,7 @@ int main() camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) camera.fovy = 45.0f; // Camera field-of-view Y + camera.type = CAMERA_PERSPECTIVE; // Camera mode type Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; diff --git a/examples/core/core_3d_picking.c b/examples/core/core_3d_picking.c index cd390d91..1c63e2a7 100644 --- a/examples/core/core_3d_picking.c +++ b/examples/core/core_3d_picking.c @@ -26,6 +26,7 @@ int main() camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) camera.fovy = 45.0f; // Camera field-of-view Y + camera.type = CAMERA_PERSPECTIVE; // Camera mode type Vector3 cubePosition = { 0.0f, 1.0f, 0.0f }; Vector3 cubeSize = { 2.0f, 2.0f, 2.0f }; diff --git a/examples/core/core_input_keys.c b/examples/core/core_input_keys.c index b2305246..69384fd9 100644 --- a/examples/core/core_input_keys.c +++ b/examples/core/core_input_keys.c @@ -30,10 +30,10 @@ int main() { // Update //---------------------------------------------------------------------------------- - if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 0.8f; - if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 0.8f; - if (IsKeyDown(KEY_UP)) ballPosition.y -= 0.8f; - if (IsKeyDown(KEY_DOWN)) ballPosition.y += 0.8f; + if (IsKeyDown(KEY_RIGHT)) ballPosition.x += 2.0f; + if (IsKeyDown(KEY_LEFT)) ballPosition.x -= 2.0f; + if (IsKeyDown(KEY_UP)) ballPosition.y -= 2.0f; + if (IsKeyDown(KEY_DOWN)) ballPosition.y += 2.0f; //---------------------------------------------------------------------------------- // Draw diff --git a/examples/models/models_mesh_picking.c b/examples/models/models_mesh_picking.c index 17b8812d..56b9397a 100644 --- a/examples/models/models_mesh_picking.c +++ b/examples/models/models_mesh_picking.c @@ -30,6 +30,7 @@ int main() camera.target = (Vector3){ 0.0f, 2.3f, 0.0f }; // Camera looking at point camera.up = (Vector3){ 0.0f, 1.6f, 0.0f }; // Camera up vector (rotation towards target) camera.fovy = 45.0f; // Camera field-of-view Y + camera.type = CAMERA_PERSPECTIVE; // Camera mode type Ray ray; // Picking ray diff --git a/examples/models/models_obj_loading.c b/examples/models/models_obj_loading.c index 4e9b2986..45eb3e98 100644 --- a/examples/models/models_obj_loading.c +++ b/examples/models/models_obj_loading.c @@ -22,11 +22,11 @@ int main() // Define the camera to look into our 3d world Camera camera = { 0 }; - camera.position = (Vector3){ 3.0f, 3.0f, 3.0f }; - camera.target = (Vector3){ 0.0f, 1.5f, 0.0f }; - camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; - camera.fovy = 45.0f; - camera.type = CAMERA_PERSPECTIVE; + camera.position = (Vector3){ 3.0f, 3.0f, 3.0f }; // Camera position + camera.target = (Vector3){ 0.0f, 1.5f, 0.0f }; // Camera looking at point + camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target) + camera.fovy = 45.0f; // Camera field-of-view Y + camera.type = CAMERA_PERSPECTIVE; // Camera mode type Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture -- cgit v1.2.3