naev 0.12.6
opengl_render.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
6#include "colour.h"
7#include "mat4.h"
8#include "opengl_tex.h"
9#include "opengl_vbo.h"
10#include "shaders.gen.h"
11
12/*
13 * Init/cleanup.
14 */
15int gl_initRender( void );
16void gl_exitRender( void );
17
18/*
19 * Coordinate translation.
20 */
21void gl_gameToScreenCoords( double *nx, double *ny, double bx, double by );
22__attribute__( ( const ) ) mat4 gl_gameToScreenMatrix( mat4 lhs );
23void gl_screenToGameCoords( double *nx, double *ny, int bx, int by );
24
25/*
26 * Rendering.
27 */
28/* Depth only. */
29void gl_renderDepthRawH( GLuint depth, const mat4 *projection,
30 const mat4 *tex_mat );
31void gl_renderDepthRaw( GLuint depth, uint8_t flags, double x, double y,
32 double w, double h, double tx, double ty, double tw,
33 double th, double angle );
34/* With depth. */
35void gl_renderTextureDepthRawH( GLuint texture, GLuint depth,
36 const mat4 *projection, const mat4 *tex_mat,
37 const glColour *c );
38void gl_renderTextureDepthRaw( GLuint texture, GLuint depth, uint8_t flags,
39 double x, double y, double w, double h,
40 double tx, double ty, double tw, double th,
41 const glColour *c, double angle );
42/* blits texture */
43void gl_renderTextureRawH( GLuint texture, const mat4 *projection,
44 const mat4 *tex_mat, const glColour *c );
45void gl_renderTextureRaw( GLuint texture, uint8_t flags, double x, double y,
46 double w, double h, double tx, double ty, double tw,
47 double th, const glColour *c, double angle );
48void gl_renderTexture( const glTexture *texture, double x, double y, double w,
49 double h, double tx, double ty, double tw, double th,
50 const glColour *c, double angle );
51void gl_renderTextureInterpolateRawH( GLuint ta, GLuint tb, double inter,
52 const mat4 *projection,
53 const mat4 *tex_mat, const glColour *c );
54void gl_renderTextureInterpolate( const glTexture *ta, const glTexture *tb,
55 double inter, double x, double y, double w,
56 double h, double tx, double ty, double tw,
57 double th, const glColour *c );
58/* blits a sprite, relative pos */
59void gl_renderSprite( const glTexture *sprite, double bx, double by, int sx,
60 int sy, const glColour *c );
61void gl_renderSpriteScale( const glTexture *sprite, double bx, double by,
62 double scalew, double scaleh, int sx, int sy,
63 const glColour *c );
64void gl_renderSpriteRotate( const glTexture *sprite, double bx, double by,
65 double angle, int sx, int sy, const glColour *c );
66void gl_renderSpriteScaleRotate( const glTexture *sprite, double bx, double by,
67 double scalew, double scaleh, double angle,
68 int sx, int sy, const glColour *c );
69/* Blits a sprite interpolating between textures, relative pos. */
70void gl_renderSpriteInterpolate( const glTexture *sa, const glTexture *sb,
71 double inter, double bx, double by, int sx,
72 int sy, const glColour *c );
74 double inter, double bx, double by,
75 int sx, int sy, const glColour *c );
77 const glTexture *sb, double inter,
78 double bx, double by, double scalew,
79 double scaleh, int sx, int sy,
80 const glColour *c );
81/* Blits a sprite interpolating between textures and scaling, relative pos. */
82void gl_renderSpriteInterpolateScale( const glTexture *sa, const glTexture *sb,
83 double inter, double bx, double by,
84 double scalew, double scaleh, int sx,
85 int sy, const glColour *c );
86/* blits a sprite, absolute pos */
87void gl_renderStaticSprite( const glTexture *sprite, double bx, double by,
88 int sx, int sy, const glColour *c );
89/* blits a scaled sprite, absolute pos */
90void gl_renderScaleSprite( const glTexture *sprite, double bx, double by,
91 int sx, int sy, double bw, double bh,
92 const glColour *c );
93/* blits a texture scaled, absolute pos */
94void gl_renderScale( const glTexture *texture, double bx, double by, double bw,
95 double bh, const glColour *c );
96/* blits a texture scaled to a rectangle, but conserve aspect ratio, absolute
97 * pos */
98void gl_renderScaleAspect( const glTexture *texture, double bx, double by,
99 double bw, double bh, const glColour *c );
100/* blits the entire image, absolute pos */
101void gl_renderStatic( const glTexture *texture, double bx, double by,
102 const glColour *c );
103void gl_renderSDF( const glTexture *texture, double x, double y, double w,
104 double h, const glColour *c, double angle, double outline );
105
106extern gl_vbo *gl_squareVBO;
107extern gl_vbo *gl_circleVBO;
108void gl_beginSolidProgram( mat4 projection, const glColour *c );
109void gl_endSolidProgram( void );
110void gl_beginSmoothProgram( mat4 projection );
111void gl_endSmoothProgram( void );
112
113/* Simple Shaders. */
114void gl_renderShader( double x, double y, double w, double h, double r,
115 const SimpleShader *shd, const glColour *c, int center );
116void gl_renderShaderH( const SimpleShader *shd, const mat4 *H,
117 const glColour *c, int center );
118
119/* Circles. */
120void gl_renderCircle( double x, double y, double r, const glColour *c,
121 int filled );
122void gl_renderCircleH( const mat4 *H, const glColour *c, int filled );
123
124/* Lines. */
125void gl_renderLine( double x1, double y1, double x2, double y2,
126 const glColour *c );
127
128/* Rectangles. */
129void gl_renderRect( double x, double y, double w, double h, const glColour *c );
130void gl_renderRectEmpty( double x, double y, double w, double h,
131 const glColour *c );
132void gl_renderRectH( const mat4 *H, const glColour *c, int filled );
133
134/* Cross. */
135void gl_renderCross( double x, double y, double r, const glColour *c );
136
137/* Triangle. */
138void gl_renderTriangleEmpty( double x, double y, double a, double s,
139 double length, const glColour *c );
140
141/* Clipping. */
142void gl_clipRect( int x, int y, int w, int h );
143void gl_unclipRect( void );
void gl_exitRender(void)
Cleans up the OpenGL rendering routines.
void gl_renderShader(double x, double y, double w, double h, double r, const SimpleShader *shd, const glColour *c, int center)
Renders a simple shader.
void gl_renderShaderH(const SimpleShader *shd, const mat4 *H, const glColour *c, int center)
Renders a simple shader with a transformation.
void gl_renderRect(double x, double y, double w, double h, const glColour *c)
Renders a rectangle.
void gl_renderLine(double x1, double y1, double x2, double y2, const glColour *c)
Draws a line.
void gl_gameToScreenCoords(double *nx, double *ny, double bx, double by)
Converts in-game coordinates to screen coordinates.
void gl_renderSpriteInterpolate(const glTexture *sa, const glTexture *sb, double inter, double bx, double by, int sx, int sy, const glColour *c)
Blits a sprite interpolating, position is relative to the player.
int gl_initRender(void)
Initializes the OpenGL rendering routines.
void gl_renderCircleH(const mat4 *H, const glColour *c, int filled)
Draws a circle.
void gl_renderTexture(const glTexture *texture, double x, double y, double w, double h, double tx, double ty, double tw, double th, const glColour *c, double angle)
Texture blitting backend.
void gl_renderTriangleEmpty(double x, double y, double a, double s, double length, const glColour *c)
Renders a triangle at a given position.
void gl_unclipRect(void)
Clears the 2d clipping planes.
void gl_renderSpriteScale(const glTexture *sprite, double bx, double by, double scalew, double scaleh, int sx, int sy, const glColour *c)
Blits a sprite, position is relative to the player.
void gl_renderSpriteScaleRotate(const glTexture *sprite, double bx, double by, double scalew, double scaleh, double angle, int sx, int sy, const glColour *c)
Blits a sprite, position is relative to the player with scaling and rotation.
void gl_renderStatic(const glTexture *texture, double bx, double by, const glColour *c)
Blits a texture to a position.
void gl_renderSDF(const glTexture *texture, double x, double y, double w, double h, const glColour *c, double angle, double outline)
SDF Texture blitting backend.
void gl_renderScale(const glTexture *texture, double bx, double by, double bw, double bh, const glColour *c)
Blits a texture scaling it.
void gl_renderScaleSprite(const glTexture *sprite, double bx, double by, int sx, int sy, double bw, double bh, const glColour *c)
Blits a scaled sprite, position is in absolute screen coordinates.
void gl_renderTextureInterpolate(const glTexture *ta, const glTexture *tb, double inter, double x, double y, double w, double h, double tx, double ty, double tw, double th, const glColour *c)
Texture blitting backend for interpolated texture.
void gl_renderScaleAspect(const glTexture *texture, double bx, double by, double bw, double bh, const glColour *c)
Blits a texture scaling it to fit a rectangle, but conserves aspect ratio.
void gl_renderTextureRaw(GLuint texture, uint8_t flags, double x, double y, double w, double h, double tx, double ty, double tw, double th, const glColour *c, double angle)
Texture blitting backend.
void gl_renderSprite(const glTexture *sprite, double bx, double by, int sx, int sy, const glColour *c)
Blits a sprite, position is relative to the player.
void gl_renderStaticSpriteInterpolate(const glTexture *sa, const glTexture *sb, double inter, double bx, double by, int sx, int sy, const glColour *c)
Blits a sprite interpolating, position is relative to the player.
void gl_screenToGameCoords(double *nx, double *ny, int bx, int by)
Converts screen coordinates to in-game coordinates.
void gl_renderStaticSprite(const glTexture *sprite, double bx, double by, int sx, int sy, const glColour *c)
Blits a sprite, position is in absolute screen coordinates.
void gl_renderTextureRawH(GLuint texture, const mat4 *projection, const mat4 *tex_mat, const glColour *c)
Texture blitting backend.
void gl_renderRectEmpty(double x, double y, double w, double h, const glColour *c)
Renders a rectangle.
void gl_renderCross(double x, double y, double r, const glColour *c)
Renders a cross at a given position.
void gl_renderSpriteRotate(const glTexture *sprite, double bx, double by, double angle, int sx, int sy, const glColour *c)
Blits a sprite, position is relative to the player with rotation.
void gl_renderTextureInterpolateRawH(GLuint ta, GLuint tb, double inter, const mat4 *projection, const mat4 *tex_mat, const glColour *c)
Texture blitting backend for interpolated texture.
void gl_renderStaticSpriteInterpolateScale(const glTexture *sa, const glTexture *sb, double inter, double bx, double by, double scalew, double scaleh, int sx, int sy, const glColour *c)
Blits a sprite interpolating, position is relative to the player.
void gl_renderSpriteInterpolateScale(const glTexture *sa, const glTexture *sb, double inter, double bx, double by, double scalew, double scaleh, int sx, int sy, const glColour *c)
Blits a sprite interpolating, position is relative to the player.
void gl_renderRectH(const mat4 *H, const glColour *c, int filled)
Renders a rectangle.
mat4 gl_gameToScreenMatrix(mat4 lhs)
Return a transformation which converts in-game coordinates to screen coordinates.
void gl_clipRect(int x, int y, int w, int h)
Sets up 2d clipping planes around a rectangle.
void gl_renderCircle(double cx, double cy, double r, const glColour *c, int filled)
Draws a circle.
static const double c[]
Definition rng.c:256
Abstraction for rendering sprite sheets.
Definition opengl_tex.h:43
Definition mat4.h:12