Skip to content

Instantly share code, notes, and snippets.

@Emiel45
Created March 13, 2012 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Emiel45/2025845 to your computer and use it in GitHub Desktop.
Save Emiel45/2025845 to your computer and use it in GitHub Desktop.
CCGPU multimonitor script
if not initialized then
-- make sure all monitors are the same resolution
-- set initial resolution
local width, height
local tempWidth, tempHeight
width, height = gpuGetResolution(1)
tempWidth, tempHeight = gpuGetResolution(2)
if not (tempWidth == width and tempHeight == height) then
error("Monitor 2 does not match monitor 1 it's resolution.")
end
tempWidth, tempHeight = gpuGetResolution(3)
if not (tempWidth == width and tempHeight == height) then
error("Monitor 3 does not match monitor 1 it's resolution.")
end
tempWidth, tempHeight = gpuGetResolution(4)
if not (tempWidth == width and tempHeight == height) then
error("Monitor 4 does not match monitor 1 it's resolution.")
end
_G.monitorWidth = width
_G.monitorHeight = height
_G.bufferWidth = width * 2
_G.bufferHeight = height * 2
_G.buffer = gpuCreateBuffer(bufferWidth, bufferHeight)
_G.initialized = true
end
gpuBindBuffer(buffer)
-- Render to a buffer as big as the 4 screens together
-- Render our screens
gpuBindMonitor(1)
glBindTexture(GL_TEXTURE_2D, buffer)
glBegin(GL_QUADS)
-- {
glTextCoord2f(0.0, 0.0) glVertex2f(0, 0)
glTextCoord2f(0.5, 0.0) glVertex2f(monitorWidth, 0)
glTextCoord2f(0.5, 0.5) glVertex2f(monitorWidth, monitorHeight)
glTextCoord2f(0.0, 0.5) glVertex2f(0, monitorHeight)
-- }
gpuBindMonitor(2)
glBindTexture(GL_TEXTURE_2D, buffer)
glBegin(GL_QUADS)
-- {
glTextCoord2f(0.5, 0.0) glVertex2f(0, 0)
glTextCoord2f(1.0, 0.0) glVertex2f(monitorWidth, 0)
glTextCoord2f(1.0, 0.5) glVertex2f(monitorWidth, monitorHeight)
glTextCoord2f(0.5, 0.5) glVertex2f(0, monitorHeight)
-- }
gpuBindMonitor(3)
glBindTexture(GL_TEXTURE_2D, buffer)
glBegin(GL_QUADS)
-- {
glTextCoord2f(0.0, 0.5) glVertex2f(0, 0)
glTextCoord2f(0.5, 0.5) glVertex2f(monitorWidth, 0)
glTextCoord2f(0.5, 1.0) glVertex2f(monitorWidth, monitorHeight)
glTextCoord2f(0.0, 1.0) glVertex2f(0, monitorHeight)
-- }
gpuBindMonitor(4)
glBindTexture(GL_TEXTURE_2D, buffer)
glBegin(GL_QUADS)
-- {
glTextCoord2f(0.5, 0.5) glVertex2f(0, 0)
glTextCoord2f(1.0, 0.5) glVertex2f(monitorWidth, 0)
glTextCoord2f(1.0, 1.0) glVertex2f(monitorWidth, monitorHeight)
glTextCoord2f(0.5, 1.0) glVertex2f(0, monitorHeight)
-- }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment