Skip to content

svenssonjoel/Graphics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graphics

  • Graphics hobby projects
  • Gfx2 is the active project.

Examples

Currently only a few of these examples are in working order. This is because of a change to the graphics library.

  • dungeon: is working ok.
  • feigenbaum: working
  • ground_mesh
  • info3ds: working
  • show_feig: working
  • simple2d
  • space
  • space2
  • view3ds: working but with bugs. (SHADOWMAPPING is broken)
  • viewmd2: working but with bugs. (SHADOWMAPPING is broken)’
  • TODO: a stand alone shadowmapping example (as simple as possible)

Gfx2/Graphics

  • diff_ms.h: Timing helpers/utils
  • error.c/h: Print OpenGL error messages
  • frame.c/h: Frames to transforms
  • image.c/h: Image loading and storing (supports RAW and PNG using libpng). Also contains a set of 2d painting functions on images.
  • matrix.c/h: Matrix library. Newer versions of OpenGL does not provide matrix manipulation functionality.
  • md2.c/h: Provides md2 loading and rendering (NEEDS TO BE UPDATED TO WORK)
  • mesh.c/h: Meshes, collections of triangles that can be rendered in one “go”.
  • multimesh.c/h: A wrapper around mesh to handle many “related” meshes at once. (NEEDS TO BE UPDATED TO WORK)
  • shader.c/h: Load and compile GLSL shaders.
  • shapes.c/h: Tools to generate some simple shapes.
  • sse_detect.h: Helpers if you want to detect SSE
  • text.c/h: Put text on Images.
  • texture.c/h: Helpers to manage OpenGL textures.
  • tools.c/h: Currently only contains a drawLine function..
  • vector.c/h: 2D/3D vector library

Meshes

A collection of vertices,normals,colors,texels and a set of indices that point out how those form triangles.

Uses OpenGL VBOs (Vertex Buffer Objects) for rendering. This means that the data is stored in GPU memory.

Also a VAO (Vertex Array Object) is used to manage the VBOs. This is right now causing some problems in my understanding of OpenGL, It seems to me that once you have created a VAO the kind of Shaders you can use to render the data is limited. The shader used MUST be compatible with the VAO in the sence that if the VAO has vertices as attrib 0 the shader must accept vertices at attrib 0. Feels like this should be captured in “types”, of the VAO and shader..

Thoughts.. Maybe I should split up meshes slightly and have a new kind of mesh that creates the VAO at the render call. This version could match up the attributes to the shader supplied and render. Slightly more general I guess. Then another kind of mesh could be compiled into a VAO and from that point on only be used with entirely compatible shaders, but more efficiently so…

Different GL buffers

  • VBO: a Vertex Buffer Object can hold for example vertices,normals…
  • VAO: a bunch of VBOs can be composed into a VAO. The VAO contains almost all the info needed to render the data. A single function call is needed to render the Object stored in the VBOs under the VAO. if glDrawElements is used then a GL_ELEMENT_ARRAY_BUFFER is also needed.
  • GL_ELEMENT_ARRAY_BUFFER: contains a set of indices.

TODO:

  • Learn more about shaders and vertex attributes. Make the mesh rendering routines “work” again.

About

Graphics hobby projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published