source: trunk/src/video.cpp @ 105

Last change on this file since 105 was 105, checked in by sam, 10 years ago

Create a helper class for easy scene setup. Highly reduces the number
of includes in a few source files.

  • Property svn:keywords set to Id
File size: 1.1 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#ifdef WIN32
11#   define WIN32_LEAN_AND_MEAN
12#   include <windows.h>
13#endif
14#if defined __APPLE__ && defined __MACH__
15#   include <OpenGL/gl.h>
16#else
17#   define GL_GLEXT_PROTOTYPES
18#   include <GL/gl.h>
19#endif
20
21#include "video.h"
22
23/*
24 * Public Video class
25 */
26
27void Video::Setup(int width, int height)
28{
29    /* Initialise OpenGL */
30    glViewport(0, 0, width, height);
31    glMatrixMode(GL_PROJECTION);
32    glLoadIdentity();
33    glOrtho(0, width, height, 0, -1, 10);
34    glMatrixMode(GL_MODELVIEW);
35    glLoadIdentity();
36
37    glEnable(GL_TEXTURE_2D);
38    glShadeModel(GL_SMOOTH);
39    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
40    glClearDepth(1.0);
41    glEnable(GL_DEPTH_TEST);
42    glDepthFunc(GL_LEQUAL);
43    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
44
45    glEnable(GL_BLEND);
46    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
47}
48
49void Video::Clear()
50{
51    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
52    glLoadIdentity();
53}
54
Note: See TracBrowser for help on using the repository browser.