source: trunk/src/video.cpp @ 135

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

Better near/far values.

  • Property svn:keywords set to Id
File size: 1.2 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
32    glEnable(GL_TEXTURE_2D);
33    glShadeModel(GL_SMOOTH);
34    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
35    glClearDepth(1.0);
36    glEnable(GL_DEPTH_TEST);
37    glDepthFunc(GL_LEQUAL);
38    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
39
40    glEnable(GL_BLEND);
41    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
42
43    /* Projection matrix: once and for all */
44    glMatrixMode(GL_PROJECTION);
45    glLoadIdentity();
46    glOrtho(0, width, height, 0, -(width + height), width + height);
47}
48
49void Video::Clear()
50{
51    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
52
53    /* Model view matrix: for each frame, just in case */
54    glMatrixMode(GL_MODELVIEW);
55    glLoadIdentity();
56}
Note: See TracBrowser for help on using the repository browser.