Giter VIP home page Giter VIP logo

ljit2x11's Introduction

LJIT2X11

These bindings go to 11!

X11 is the graphics subsytem that is commonly found atop the Linux operating system. Using X11 you can open Windows, use mouse and keyboard interaction, and draw graphics in general.

This binding covers the core parts of the X11 system required to open windows, draw graphics, and generally interact with keyboard and mouse. It does not cover the entirety of X11, as the parts not covered are not as required for basic GUI apps.

X11.lua is the primary entry point. You can gain access to everything with one 'require' statement.

local X11 = require("x11.X11")

-- to create a connection to the default display
-- on the current machine
local display = X11.XOpenDisplay(nil);

Of course, that's just the beginning. To get a Window up, with mouse and keyboard events...

local myEvents = bor(X11.ExposureMask, 
		X11.KeyPressMask, X11.KeyReleaseMask,
		X11.ButtonPressMask,X11.ButtonReleaseMask,
		X11.PointerMotionMask)


screen = X11.DefaultScreen(disdisplay);
visual = X11.XDefaultVisual(display, X11.DefaultScreen(display));

	local blackPixel = X11.BlackPixel(display, screen);
	local whitePixel = X11.WhitePixel(display, screen);


   	Window = X11.XCreateSimpleWindow(self.dis,
   		X11.DefaultRootWindow(self.dis),
   		0,0,	
		awidth, aheight, 
		5,
		blackPixel, whitePixel);

	X11.XSetStandardProperties(display,Window,Title,"Hi",X11.None,nil,0,nil);


	X11.XSelectInput(display, Window, myEvents);
    
    gcontext = X11.XCreateGC(display, Window, 0,nil);        
	
	X11.XSetBackground(display,gcontext,whitePixel);
	X11.XSetForeground(display,gcontext,blackPixel);
	X11.XClearWindow(display, Window);
	X11.XMapRaised(display, Window);

You can essentially program as if you were writing X11 code in C, just put the 'X11.' in front of all references to functions, types, and constants. Of course this is Lua, so you could also make those local references, and write your code exactly as you would in C, with some Lua goodness wrapping it up for convenience.

ljit2x11's People

Contributors

wiladams avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.