sorry it took so long to get back
here it is
include msgbox.e
include C:\EUPHORIA\GLFW\Euphoria\gl\gl.e
include C:\EUPHORIA\GLFW\Euphoria\gl\glu.e
include C:\EUPHORIA\GLFW\Euphoria\gl\glfw.e
atom t1, t0, fps, texidone, texidtwo --, texidthree, texidfour, texidfive, texidsix
integer running, frames, width, height, x, y
sequence titlestr, pos, lptex
frames = 0
t0 = glfwGetTime()
lptex = ({0, 0})
---------- setup window
procedure setupwindow()
running = glfwInit()
if not(glfwOpenWindow(1280, 1024, 0,0,0,0, 0,0, GLFW_FULLSCREEN)) then
glfwTerminate()
running = message_box("unable to open an opengl window.", "Error", MB_ICONERROR)
abort(1)
end if
glShadeModel(GL_FLAT)
glEnable(GL_DEPTH_TEST)
glfwSwapInterval(0)
glfwEnable(GLFW_STICKY_KEYS)
glfwSwapInterval(1)
end procedure
---------- setup textures
procedure setuptexture()
lptex[1] = allocate(4)
lptex[2] = allocate(4)
glGenTextures(1, lptex[1])
texidone = peek4u(lptex[1])
free(lptex[1])
glBindTexture(GL_TEXTURE_2D, texidone)
if not(glfwLoadTexture2D("imgs\\one.tga", GLFW_ORIGIN_UL_BIT)) then
glfwTerminate()
running = message_box("Unable to Open imgs\\one.tga.", "Error", MB_ICONERROR)
abort(1)
end if
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glGenTextures(1, lptex[2])
texidtwo = peek4u(lptex[2])
free(lptex[2])
glBindTexture(GL_TEXTURE_2D, texidtwo)
if not(glfwLoadTexture2D("imgs\ wo.tga", GLFW_ORIGIN_UL_BIT)) then
glfwTerminate()
running = message_box("Unable to Open imgs\ wo.tga.", "Error", MB_ICONERROR)
abort(1)
end if
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
end procedure
---------- call setups
setupwindow()
setuptexture()
---------- main loop
while running do
----- determine fps
t1 = glfwGetTime()
if (t1-t0) > 1.0 then
fps = frames / (t1 - t0)
frames = 0
t0 = t1
titlestr = sprintf("FPS: %.1f", {fps})
glfwSetWindowTitle(titlestr)
end if
----- get mouse position
pos = glfwGetMousePos()
x = pos[1]
y = pos[2]
----- determine actual screen size
pos = glfwGetWindowSize()
width = pos[1]
height = pos[2]
if height <= 0 then
height = 1
end if
glViewport(0, 0, width, height)
----- clear buffer
glClearColor(0, 0, 0, 0)
glClear(GL_COLOR_BUFFER_BIT)
glClear(GL_DEPTH_BUFFER_BIT)
----- setup viewing angles
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(65, width / height, 0.0, 10.0)
glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LEQUAL)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
gluLookAt({0.0, 0.0, -10.0}, -- Eye-position
{0.0, 0.0, 0.0}, -- View-point
{0.0, 1.0, 0.0}) -- Up-vector
----- Draw a textured quad
glPushMatrix()
glTranslatef(({0, 0, 5}))
glRotatef(0.05 * x, {0.0, 1.0, 0.0})
glRotatef(0.05 * y, {1.0, 0.0, 0.0})
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, texidtwo)
glBegin(GL_QUADS)
glTexCoord2f({1, 0})
glVertex3f({1, 1, 0})
glTexCoord2f({0, 0})
glVertex3f({1, 1, 2})
glTexCoord2f({0, 1})
glVertex3f({1, -1, 2})
glTexCoord2f({1, 1})
glVertex3f({1, -1, 0})
glEnd()
glBindTexture(GL_TEXTURE_2D, texidone)
glBegin(GL_QUADS)
glTexCoord2f({1, 0})
glVertex3f({-1, 1, 0})
glTexCoord2f({0, 0})
glVertex3f({1, 1, 0})
glTexCoord2f({0, 1})
glVertex3f({1, -1, 0})
glTexCoord2f({1, 1})
glVertex3f({-1, -1, 0})
glEnd()
glFlush()
glDisable(GL_TEXTURE_2D)
----- swap buffer and add frame
glfwSwapBuffers()
frames += 1
----- check for key presses and continue
running = not(glfwGetKey(GLFW_KEY_ESC)) and glfwGetWindowParam(GLFW_OPENED)
end while
glfwTerminate()