Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

glwin.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "glwin.h"
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
#include <GL/glx.h>
#include <GL/gl.h>

Go to the source code of this file.


Compounds

struct glsl_shader
struct glwin_ext_fctns
struct glwin_fbo_target
struct glwin_warp_hmd
struct oglhandle
struct spaceballevent
struct spaceballhandle

Defines

#define USEOPENGL
#define GL_GLEXT_PROTOTYPES 1
#define GLX_GLXEXT_PROTOTYPES 1
#define SBALL_COMMAND_NONE 0
#define SBALL_COMMAND_APP_WINDOW 27695
#define SBALL_COMMAND_APP_SENSITIVITY 27696
#define HMD_DIVCNT 10
#define SPHEREMAXRES 64

Typedefs

typedef void(APIENTRY * glwin_fctnptr )(void)

Functions

int glx_query_extension (Display *dpy, const char *extname)
void quat_rot_matrix (float *m, const float *q)
void * glwin_get_procaddress (const char *procname)
void glwin_init_exts (void *voidhandle)
spaceballhandle * spaceball_attach (Display *dpy, Window win)
void spaceball_close (spaceballhandle *handle)
int spaceball_decode_event (spaceballhandle *handle, const XEvent *xev, spaceballevent *sballevent)
void spaceball_init_event (spaceballevent *sballevent)
void spaceball_clear_event (spaceballevent *sballevent)
oglhandle * glwin_alloc_init (void)
void * glwin_create (const char *wintitle, int width, int height)
void glwin_destroy (void *voidhandle)
void glwin_swap_buffers (void *voidhandle)
int glwin_handle_events (void *voidhandle, int evblockmode)
int glwin_resize (void *voidhandle, int width, int height)
int glwin_reposition (void *voidhandle, int xpos, int ypos)
int glwin_fullscreen (void *voidhandle, int fson, int xinescreen)
int glwin_query_extension (const char *extname)
int glwin_query_vsync (void *voidhandle, int *onoff)
int glwin_fbo_target_bind (void *voidhandle, void *voidtarget)
int glwin_fbo_target_unbind (void *voidhandle, void *voidtarget)
int glwin_fbo_target_destroy (void *voidhandle, void *voidtarget)
int glwin_fbo_target_resize (void *voidhandle, void *voidtarget, int wsx, int wsy)
void * glwin_fbo_target_create (void *voidhandle, int wsx, int wsy)
int glwin_fbo_target_draw_normal (void *voidhandle, void *voidtarget)
int glwin_fbo_target_draw_fbo (void *voidhandle, void *voidtarget, int wsx, int wsy)
void hmd_compute_warped_coords (int divcnt, int wsx, int wsy, float rscale, float wscale, float *xcrds, float *ycrds, const float *user_distort_coeff5)
void hmd_draw_eye_lines (int divcnt, int xoff, int width, int height, float *xcrds, float *ycrds)
void hmd_draw_eye_texquads (int divcnt, int xoff, int width, int height, float *xcrds, float *ycrds)
void glwin_spheremap_update_hmd_warp (void *vwin, void *voidwarp, int wsx, int wsy, int warpdivs, int ixs, int iys, const float *barrel_coeff, int force)
void glwin_spheremap_destroy_hmd_warp (void *vwin, void *voidwarp)
void * glwin_spheremap_create_hmd_warp (void *vwin, int wsx, int wsy, int wrot, int warpdivs, int ixs, int iys, const float *user_coeff)
int glwin_spheremap_draw_hmd_warp (void *vwin, void *voidwarp, int drawimage, int drawlines, int chromcorr, int wsx, int wsy, int ixs, int iys, const float *hmdquat, float fov, float rad, int hmd_spres)
void glwin_print_glsl_infolog (void *voidhandle, GLhandleARB obj, const char *msg)
int glwin_compile_shaders (void *voidhandle, glsl_shader *sh, const GLubyte *vertexShader, const GLubyte *fragmentShader, int verbose)
int glwin_destroy_shaders (void *voidhandle, glsl_shader *sh)
int glwin_compile_hmd_shaders (void *voidhandle, glsl_shader *sh)
void glwin_draw_image (void *voidhandle, int ixs, int iys, unsigned char *img)
void glwin_draw_image_rgb3u (void *voidhandle, int stereomode, int ixs, int iys, const unsigned char *rgb3u)
void glwin_draw_image_tex_rgb3u (void *voidhandle, int stereomode, int ixs, int iys, const unsigned char *rgb3u)
void glwin_draw_sphere_tex (float rad, int res, float txlatstart, float txlatend)
void glwin_spheremap_draw_prepare (void *voidhandle)
void glwin_spheremap_upload_tex_rgb3u (void *voidhandle, int ixs, int iys, const unsigned char *rgb3u)
void glwin_spheremap_draw_tex (void *voidhandle, int stereomode, int ixs, int iys, const float *hmdquat, float fov, float rad, int res)
int glwin_get_wininfo (void *voidhandle, int *instereo, int *havestencil)
int glwin_get_winsize (void *voidhandle, int *xsize, int *ysize)
int glwin_get_winpos (void *voidhandle, int *xpos, int *ypos)
int glwin_get_mousepointer (void *voidhandle, int *x, int *y)
int glwin_get_lastevent (void *voidhandle, int *evdev, int *evval, char *evkey)
int glwin_spaceball_available (void *voidhandle)
int glwin_get_spaceball (void *voidhandle, int *rx, int *ry, int *rz, int *tx, int *ty, int *tz, int *buttons)

Variables

const char * hmd_vert
const char * hmd_frag

Define Documentation

#define GL_GLEXT_PROTOTYPES 1

Definition at line 37 of file glwin.c.

#define GLX_GLXEXT_PROTOTYPES 1

Definition at line 38 of file glwin.c.

#define HMD_DIVCNT 10

Definition at line 2290 of file glwin.c.

#define SBALL_COMMAND_APP_SENSITIVITY 27696

Definition at line 521 of file glwin.c.

#define SBALL_COMMAND_APP_WINDOW 27695

Definition at line 520 of file glwin.c.

Referenced by spaceball_attach.

#define SBALL_COMMAND_NONE 0

Definition at line 519 of file glwin.c.

#define SPHEREMAXRES 64

Definition at line 3013 of file glwin.c.

Referenced by glwin_draw_sphere_tex.

#define USEOPENGL

Definition at line 28 of file glwin.c.


Typedef Documentation

typedef void(APIENTRY * glwin_fctnptr)(void)

Definition at line 347 of file glwin.c.


Function Documentation

oglhandle* glwin_alloc_init ( void ) [static]

int glwin_compile_hmd_shaders ( void * voidhandle,
)

Definition at line 2838 of file glwin.c.

References glwin_compile_shaders, hmd_frag, and hmd_vert.

int glwin_compile_shaders ( void * voidhandle,
glsl_shader * sh,
const GLubyte * vertexShader,
const GLubyte * fragmentShader,
int verbose
) [static]

void* glwin_create ( const char * wintitle,
int width,
int height
)

void glwin_destroy ( void * voidhandle )

int glwin_destroy_shaders ( void * voidhandle,
)

void glwin_draw_image ( void * voidhandle,
int ixs,
int iys,
unsigned char * img
)

Definition at line 2847 of file glwin.c.

References glwin_swap_buffers.

void glwin_draw_image_rgb3u ( void * voidhandle,
int stereomode,
int ixs,
int iys,
const unsigned char * rgb3u
)

Definition at line 2854 of file glwin.c.

References glwin_get_winsize, GLWIN_STEREO_OVERUNDER, and glwin_swap_buffers.

void glwin_draw_image_tex_rgb3u ( void * voidhandle,
int stereomode,
int ixs,
int iys,
const unsigned char * rgb3u
)

Definition at line 2900 of file glwin.c.

References glwin_get_winsize, GLWIN_STEREO_OVERUNDER, and glwin_swap_buffers.

void glwin_draw_sphere_tex ( float rad,
int res,
float txlatstart,
float txlatend
)

Definition at line 3014 of file glwin.c.

References SPHEREMAXRES.

int glwin_fbo_target_bind ( void * voidhandle,
void * voidtarget
)

Definition at line 2088 of file glwin.c.

References oglhandle::ext, glwin_fbo_target::fbo, GLWIN_ERROR, GLWIN_SUCCESS, and NULL.

void* glwin_fbo_target_create ( void * voidhandle,
int wsx,
int wsy
)

int glwin_fbo_target_destroy ( void * voidhandle,
void * voidtarget
)

int glwin_fbo_target_draw_fbo ( void * voidhandle,
void * voidtarget,
int wsx,
int wsy
)

Definition at line 2258 of file glwin.c.

References GLWIN_ERROR, glwin_fbo_target_unbind, GLWIN_SUCCESS, NULL, and glwin_fbo_target::tex.

int glwin_fbo_target_draw_normal ( void * voidhandle,
void * voidtarget
)

Definition at line 2245 of file glwin.c.

References oglhandle::ext, GLWIN_ERROR, GLWIN_SUCCESS, and NULL.

int glwin_fbo_target_resize ( void * voidhandle,
void * voidtarget,
int wsx,
int wsy
)

int glwin_fbo_target_unbind ( void * voidhandle,
void * voidtarget
)

Definition at line 2101 of file glwin.c.

References oglhandle::ext, GLWIN_ERROR, GLWIN_SUCCESS, and NULL.

int glwin_fullscreen ( void * voidhandle,
int fson,
int xinescreen
)

Definition at line 1283 of file glwin.c.

References oglhandle::dpy, oglhandle::root, and oglhandle::win.

int glwin_get_lastevent ( void * voidhandle,
int * evdev,
int * evval,
char * evkey
)

Definition at line 3256 of file glwin.c.

References oglhandle::evdev, oglhandle::evkey, oglhandle::evval, and NULL.

int glwin_get_mousepointer ( void * voidhandle,
int * x,
int * y
)

Definition at line 3241 of file glwin.c.

References oglhandle::mousex, oglhandle::mousey, and NULL.

void* glwin_get_procaddress ( const char * procname )

Definition at line 350 of file glwin.c.

References NULL.

Referenced by glwin_init_exts.

int glwin_get_spaceball ( void * voidhandle,
int * rx,
int * ry,
int * rz,
int * tx,
int * ty,
int * tz,
int * buttons
)

int glwin_get_wininfo ( void * voidhandle,
int * instereo,
int * havestencil
)

Definition at line 3186 of file glwin.c.

References oglhandle::havestencil, oglhandle::instereo, and NULL.

int glwin_get_winpos ( void * voidhandle,
int * xpos,
int * ypos
)

Definition at line 3226 of file glwin.c.

References NULL, oglhandle::xpos, and oglhandle::ypos.

int glwin_get_winsize ( void * voidhandle,
int * xsize,
int * ysize
)

Definition at line 3201 of file glwin.c.

References oglhandle::dpy, oglhandle::height, NULL, oglhandle::width, and oglhandle::win.

int glwin_handle_events ( void * voidhandle,
int evblockmode
)

void glwin_init_exts ( void * voidhandle )

void glwin_print_glsl_infolog ( void * voidhandle,
GLhandleARB obj,
const char * msg
) [static]

Definition at line 2658 of file glwin.c.

References oglhandle::ext, GLGETINFOLOGARB, GLGETOBJECTPARAMETERIVARB, and NULL.

Referenced by glwin_compile_shaders.

int glwin_query_extension ( const char * extname )

Definition at line 2014 of file glwin.c.

References n, and NULL.

int glwin_query_vsync ( void * voidhandle,
int * onoff
)

int glwin_reposition ( void * voidhandle,
int xpos,
int ypos
)

Definition at line 1260 of file glwin.c.

References oglhandle::dpy, NULL, and oglhandle::win.

int glwin_resize ( void * voidhandle,
int width,
int height
)

Definition at line 1245 of file glwin.c.

References oglhandle::dpy, NULL, and oglhandle::win.

int glwin_spaceball_available ( void * voidhandle )

Definition at line 3274 of file glwin.c.

References NULL, and oglhandle::sball.

void* glwin_spheremap_create_hmd_warp ( void * vwin,
int wsx,
int wsy,
int wrot,
int warpdivs,
int ixs,
int iys,
const float * user_coeff
)

void glwin_spheremap_destroy_hmd_warp ( void * vwin,
void * voidwarp
)

int glwin_spheremap_draw_hmd_warp ( void * vwin,
void * voidwarp,
int drawimage,
int drawlines,
int chromcorr,
int wsx,
int wsy,
int ixs,
int iys,
const float * hmdquat,
float fov,
float rad,
int hmd_spres
)

void glwin_spheremap_draw_prepare ( void * voidhandle )

Definition at line 3092 of file glwin.c.

void glwin_spheremap_draw_tex ( void * voidhandle,
int stereomode,
int ixs,
int iys,
const float * hmdquat,
float fov,
float rad,
int res
)

void glwin_spheremap_update_hmd_warp ( void * vwin,
void * voidwarp,
int wsx,
int wsy,
int warpdivs,
int ixs,
int iys,
const float * barrel_coeff,
int force
)

void glwin_spheremap_upload_tex_rgb3u ( void * voidhandle,
int ixs,
int iys,
const unsigned char * rgb3u
)

Definition at line 3121 of file glwin.c.

void glwin_swap_buffers ( void * voidhandle )

Definition at line 1061 of file glwin.c.

References oglhandle::dpy, NULL, and oglhandle::win.

int glx_query_extension ( Display * dpy,
const char * extname
) [static]

Definition at line 297 of file glwin.c.

References n, and NULL.

Referenced by glwin_init_exts, and glwin_query_vsync.

void hmd_compute_warped_coords ( int divcnt,
int wsx,
int wsy,
float rscale,
float wscale,
float * xcrds,
float * ycrds,
const float * user_distort_coeff5
) [static]

Definition at line 2292 of file glwin.c.

Referenced by glwin_spheremap_update_hmd_warp.

void hmd_draw_eye_lines ( int divcnt,
int xoff,
int width,
int height,
float * xcrds,
float * ycrds
) [static]

Definition at line 2348 of file glwin.c.

Referenced by glwin_spheremap_draw_hmd_warp.

void hmd_draw_eye_texquads ( int divcnt,
int xoff,
int width,
int height,
float * xcrds,
float * ycrds
) [static]

Definition at line 2386 of file glwin.c.

Referenced by glwin_spheremap_draw_hmd_warp.

void quat_rot_matrix ( float * m,
const float * q
) [static]

Definition at line 323 of file glwin.c.

Referenced by glwin_spheremap_draw_tex, HMDMgr::rot_basis_quat, and HMDMgr::rot_point_quat.

spaceballhandle* spaceball_attach ( Display * dpy,
Window win
) [static]

void spaceball_clear_event ( spaceballevent * sballevent ) [static]

void spaceball_close ( spaceballhandle * handle ) [static]

Definition at line 589 of file glwin.c.

int spaceball_decode_event ( spaceballhandle * handle,
const XEvent * xev,
spaceballevent * sballevent
) [static]

void spaceball_init_event ( spaceballevent * sballevent ) [static]

Definition at line 630 of file glwin.c.


Variable Documentation

const char* hmd_frag

Initial value:

 
 " \n"
 " \n"
 " \n"
 " \n"
 "void main(void) { \n"
 " \n"
 " // Flip the surface normal if it is facing away from the viewer, \n"
 " // determined by polygon winding order provided by OpenGL. \n"
 " vec3 N = normalize(oglnormal); \n"
 " if (!gl_FrontFacing) { \n"
 " N = -N; \n"
 " } \n"
 " \n"
 " \n"
 " \n"
 " \n"
 " \n"
 " \n"
 "} \n"
 " \n"

Definition at line 2813 of file glwin.c.

Referenced by glwin_compile_hmd_shaders.

const char* hmd_vert

Initial value:

 
 "// requires GLSL version 1.10 \n"
 "#version 110 \n"
 " \n"
 " \n"
 " \n"
 "void main(void) { \n"
 " // transform vertex to Eye space for user clipping plane calculations \n"
 " vec4 ecpos = gl_ModelViewMatrix * gl_Vertex; \n"
 " gl_ClipVertex = ecpos; \n"
 " \n"
 " // transform, normalize, and output normal. \n"
 " oglnormal = normalize(gl_NormalMatrix * gl_Normal); \n"
 " \n"
 " // pass along vertex color for use fragment shading, \n"
 " // fragment shader will get an interpolated color. \n"
 " oglcolor = vec3(gl_Color); \n"
 " \n"
 " \n"
 " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \n"
 " \n"
 " \n"
 " \n"
 " \n"
 "} \n"
 " \n"

Definition at line 2781 of file glwin.c.

Referenced by glwin_compile_hmd_shaders.


Generated on Mon Nov 17 02:47:38 2025 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002

AltStyle によって変換されたページ (->オリジナル) /