Jump to content

Lua bindings to glScissor


Averice
 Share

Recommended Posts

It let's you specify a rectangle on the screen in which anything drawn outside it during that pass is not actually drawn, it's part of openGL I was just wondering if it had been bound to Lua for leadwerks at all.

glScissor(x, y, width, height) -- small rect

-- Draw stuff

glScissor(0, 0, screenwidth, screenheight) -- return to normal

Link to comment
Share on other sites

Sorry for the double post, but if anyone else is looking for a working glScissor ( or other gl functions ) I've managed to get it working using luajits ffi library.

 

ffi = require "ffi";
gl = ffi.load("OPENGL"); -- windows.
ffi.cdef[[
enum {
GL_SCISSOR_TEST = 0x0C11
};
typedef unsigned int GLenum;
typedef int GLint;
typedef int GLsizei;

void glEnable(GLenum cap);
void glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
]]

 

Usage:

gl.glEnable(gl.GL_SCISSOR_TEST);
gl.glScissor(0, 0, 100, 100);
-- draw stuff
gl.glScissor(0, 0, scrwidth, scrheight);

The only difference is the origin is bottom left instead of top left so I've provided this.

 

function math.glreverse(y, objH) -- y is the position on the y axise, objH is the height of the obj you want to place at y
return (App and App.context) and App.context:GetHeight() - y - objH or 0;
end

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...