Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
glest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
glest
Commits
bdddb357
Commit
bdddb357
authored
2 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Create and clear offscreen texture
parent
b1254327
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
glest.cabal
+1
-0
1 addition, 0 deletions
glest.cabal
src/Glest/Renderer.hs
+56
-1
56 additions, 1 deletion
src/Glest/Renderer.hs
with
57 additions
and
1 deletion
glest.cabal
+
1
−
0
View file @
bdddb357
...
...
@@ -70,6 +70,7 @@ library
containers,
exceptions,
filepath,
gl,
inline-c,
mtl,
network,
...
...
This diff is collapsed.
Click to expand it.
src/Glest/Renderer.hs
+
56
−
1
View file @
bdddb357
...
...
@@ -2,8 +2,63 @@ module Glest.Renderer (
testRenderer
)
where
import
Foreign
import
Glest.Egl
import
Graphics.GL.Embedded20
import
Graphics.GL.Types
import
Language.C.Inline
(
withPtr_
)
import
Quasar.Prelude
testRenderer
::
IO
()
testRenderer
=
initializeEgl
testRenderer
=
do
initializeEgl
renderToDmabuf
renderToDmabuf
::
IO
()
renderToDmabuf
=
do
texture
<-
genTexture
glBindTexture
GL_TEXTURE_2D
texture
let
width
=
512
height
=
512
glTexImage2D
GL_TEXTURE_2D
0
GL_RGBA
width
height
0
GL_RGBA
GL_UNSIGNED_BYTE
nullPtr
glTexParameteri
GL_TEXTURE_2D
GL_TEXTURE_MIN_FILTER
GL_NEAREST
glTexParameteri
GL_TEXTURE_2D
GL_TEXTURE_MAG_FILTER
GL_NEAREST
framebuffer
<-
alloca
\
ptr
->
do
glGenFramebuffers
1
ptr
peek
ptr
traceIO
$
mconcat
[
"Generated framebuffer@"
,
show
framebuffer
]
glBindFramebuffer
GL_FRAMEBUFFER
framebuffer
glFramebufferTexture2D
GL_FRAMEBUFFER
GL_COLOR_ATTACHMENT0
GL_TEXTURE_2D
texture
0
glClearColor
1
0
1
1
glClear
GL_COLOR_BUFFER_BIT
logErrors
genTexture
::
IO
GLuint
genTexture
=
do
texture
<-
alloca
\
ptr
->
do
glGenTextures
1
ptr
peek
ptr
traceIO
$
mconcat
[
"Generated texture@"
,
show
texture
]
pure
texture
logErrors
::
IO
()
logErrors
=
do
err
<-
glGetError
unless
(
err
==
GL_NO_ERROR
)
do
traceIO
$
errorMessage
err
logErrors
errorMessage
::
GLenum
->
String
errorMessage
GL_NO_ERROR
=
"GL_NO_ERROR"
errorMessage
GL_INVALID_ENUM
=
"GL_INVALID_ENUM"
errorMessage
GL_INVALID_VALUE
=
"GL_INVALID_VALUE"
errorMessage
GL_INVALID_OPERATION
=
"GL_INVALID_OPERATION"
errorMessage
GL_INVALID_FRAMEBUFFER_OPERATION
=
"GL_INVALID_FRAMEBUFFER_OPERATION"
errorMessage
GL_OUT_OF_MEMORY
=
"GL_OUT_OF_MEMORY"
errorMessage
_
=
"Invalid GL error number"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment