mdidillon Posted February 2, 2010 Share Posted February 2, 2010 Hello, i am currently working on 2D GUI for my game and i have some questions about the given 2D render function of the leadwerks engine. With the given c/c++ 2D render function (DrawText, DrawImage, etc.): Is it possible to set a clipping rectangle? Is there a way to draw a image with a source and destination rectangle? marc PS: The attached screenshot shows the current state of the implementation Quote Link to comment Share on other sites More sharing options...
Canardia Posted February 2, 2010 Share Posted February 2, 2010 Is it possible to set a clipping rectangle?You need to render to a smaller buffer and display the buffer either as 3D texture or also with DrawImage. Is there a way to draw a image with a source and destination rectangle?You can scale the image using it's height and width parameters. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Masterxilo Posted February 3, 2010 Share Posted February 3, 2010 You can draw using Opengl commands. There, everything you described is possible. Quote Hurricane-Eye Entertainment - Site, blog. Link to comment Share on other sites More sharing options...
omniglitch Posted March 26, 2012 Share Posted March 26, 2012 Since I'm also creating my own GUI code using just Leadwerks commands, I've run into the same problem. Using the advice above and my own shaky understanding of Leadwerks' buffer commands, I've come up with the following: // initialization before rendering loop int viewportWidth = 177; int viewportHeight = 12; TTexture viewportTexture = CreateTexture( viewportWidth, viewportHeight ); ClampTexture( viewportTexture ); TBuffer viewportBuffer = CreateBuffer( viewportWidth, viewportHeight ); // inside the rendering loop TBuffer previousBuffer = CurrentBuffer(); SetColorBuffer( viewportBuffer, viewportTexture ); SetBuffer( viewportBuffer ); ClearBuffer(); DrawText( 0, 0, "This is a test of view port clipping." ); TTexture tempTexture = GetColorBuffer( viewportBuffer ); SetBuffer( previousBuffer ); DrawImage( tempTexture, 0, 0, viewportWidth, -viewportHeight ); It seems to work correctly. One oddity is I had to make the height parameter, for the last DrawImage command, a negative value or it would draw the texture upside down. Not sure why that happens. Anyways, I was wondering if this is the method I should use. Is it prone to any bugs? Is there a more efficient method I should be using? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.