Comments (2)
This library binds glfw only, not opengl. If you want to call opengl functions, you need to bind them separately. For example you can use this bindings (https://github.com/Playermet/luajit-gl/blob/master/gl.lua), but be aware, they do minimal wrapping (unlike luajit-glfw, which do all ffi job).
Then main example may look like this (tested on windows 7):
local glfw = require '../glfw' ('glfw3')
local gl = require 'gl' ('opengl32')
local GL = gl.const
-- Initialize the library
if glfw.Init() == 0 then
return
end
-- Create a windowed mode window and its OpenGL context
local window = glfw.CreateWindow(640, 480, "Hello World")
if window == 0 then
glfw.Terminate()
return
end
-- Make the window's context current
glfw.MakeContextCurrent(window)
-- Loop until the user closes the window
while glfw.WindowShouldClose(window) == 0 do
-- Render here
local width, height = window:GetFramebufferSize()
ratio = width / height
gl.Viewport(0, 0, width, height)
gl.Clear(GL.COLOR_BUFFER_BIT)
gl.MatrixMode(GL.PROJECTION)
gl.LoadIdentity()
gl.Ortho(-ratio, ratio, -1, 1, 1, -1)
gl.MatrixMode(GL.MODELVIEW)
gl.LoadIdentity()
gl.Rotatef(glfw.GetTime() * 50, 0, 0, 1)
gl.Begin(GL.TRIANGLES)
gl.Color3f(1, 0, 0)
gl.Vertex3f(-0.6, -0.4, 0)
gl.Color3f(0, 1, 0)
gl.Vertex3f(0.6, -0.4, 0)
gl.Color3f(0, 0, 1)
gl.Vertex3f(0, 0.6, 0)
gl.End()
-- Swap front and back buffers
glfw.SwapBuffers(window)
-- Poll for and process events
glfw.PollEvents()
end
glfw.Terminate()
I have to include opengl.dll on my program?
No.
from luajit-glfw.
It works! Thanks.
from luajit-glfw.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luajit-glfw.