Subversion Repositories gelsvn

Rev

Rev 563 | Rev 627 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 563 Rev 597
Line -... Line 1...
-
 
1
/* ----------------------------------------------------------------------- *
-
 
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
-
 
3
 * Copyright (C) the authors and DTU Informatics
-
 
4
 * For license and list of authors, see ../../doc/intro.pdf
-
 
5
 * ----------------------------------------------------------------------- */
-
 
6
 
1
/**
7
/**
2
 * @file   Console.cpp
8
 * @file   Console.cpp
3
 * @author Anders Wang Kristensen <awk@imm.dtu.dk>
9
 * @author Anders Wang Kristensen <awk@imm.dtu.dk>
4
 * @date   Fri Oct 22 18:36:58 2011
10
 * @date   Fri Oct 22 18:36:58 2011
5
 */
11
 */
Line 12... Line 18...
12
#include <iostream> //cerr
18
#include <iostream> //cerr
13
#include <iterator> //back_inserter
19
#include <iterator> //back_inserter
14
#include <fstream>
20
#include <fstream>
15
#include <utility> //min
21
#include <utility> //min
16
 
22
 
17
#include <GLGraphics/stb_image.h>
23
#include <GLGraphics/stb_image_aug.h>
18
 
24
 
19
static const char* history_filename = "history.txt";
25
static const char* history_filename = "history.txt";
20
 
26
 
21
static const int line_spacing = 13;
27
static const int line_spacing = 13;
22
static const int char_spacing = 7;
28
static const int char_spacing = 7;
Line 111... Line 117...
111
            GL_ALPHA, GL_UNSIGNED_BYTE, data);
117
            GL_ALPHA, GL_UNSIGNED_BYTE, data);
112
        stbi_image_free(data);
118
        stbi_image_free(data);
113
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
119
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
114
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
120
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
115
        glBindTexture(GL_TEXTURE_2D, 0);
121
        glBindTexture(GL_TEXTURE_2D, 0);
116
        assert(glGetError() == GL_NO_ERROR);
-
 
117
    }
122
    }
118
 
123
 
119
    //setup matrices
124
    //setup matrices
120
    int vp[4];
125
    int vp[4];
121
    glGetIntegerv(GL_VIEWPORT, vp);
126
    glGetIntegerv(GL_VIEWPORT, vp);
Line 130... Line 135...
130
    glPushMatrix();
135
    glPushMatrix();
131
    glLoadIdentity();
136
    glLoadIdentity();
132
 
137
 
133
    //gray background + separator
138
    //gray background + separator
134
    glPushAttrib(GL_COLOR_BUFFER_BIT);
139
    glPushAttrib(GL_COLOR_BUFFER_BIT);
-
 
140
    glPushAttrib(GL_ENABLE_BIT);
135
    glEnable(GL_BLEND);
141
    glEnable(GL_BLEND);
136
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
142
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
 
143
    glDisable(GL_LIGHTING);
137
 
144
 
138
    glColor4f(0.15f, 0.15f, 0.15f, 0.75f);
145
    glColor4f(0.15f, 0.15f, 0.15f, 0.75f);
139
    glRecti(0, 0, width, height);
146
    glRecti(0, 0, width, height);
140
    glColor3f(0.7f, 0.7f, 0.7f);
147
    glColor4f(0.7f, 0.7f, 0.7f, 0.75f);
141
    glRecti(0, 1, width, 2);
148
    glRecti(0, 1, width, 2);
142
    glColor3f(0.5f, 0.5f, 0.5f);
149
    glColor4f(0.5f, 0.5f, 0.5f, 0.75f);
143
    glRecti(0, 0, width, 1);
150
    glRecti(0, 0, width, 1);
144
 
151
 
145
    glPopAttrib();
152
    glPopAttrib();
-
 
153
    glPopAttrib();
146
 
154
 
147
    int current = 3;
155
    int current = 3;
148
 
156
 
149
    //draw caret
157
    //draw caret
150
    if (!m_is_executing)
158
    if (!m_is_executing)
Line 189... Line 197...
189
                        const char* buffer)
197
                        const char* buffer)
190
{
198
{
191
    //save OpenGL state
199
    //save OpenGL state
192
    glPushAttrib(GL_ENABLE_BIT);
200
    glPushAttrib(GL_ENABLE_BIT);
193
    glPushAttrib(GL_COLOR_BUFFER_BIT);
201
    glPushAttrib(GL_COLOR_BUFFER_BIT);
-
 
202
    glPushAttrib(GL_DEPTH_BUFFER_BIT);
194
 
203
 
195
    //setup texture mapping + blending
204
    //setup texture mapping + blending
196
    glDisable(GL_DEPTH_TEST);
205
    glDisable(GL_DEPTH_TEST);
197
    glDisable(GL_LIGHTING);
206
    glDisable(GL_LIGHTING);
198
    glEnable(GL_TEXTURE_2D);
207
    glEnable(GL_TEXTURE_2D);
Line 256... Line 265...
256
    glPopMatrix();
265
    glPopMatrix();
257
 
266
 
258
    //and attributes
267
    //and attributes
259
    glPopAttrib();
268
    glPopAttrib();
260
    glPopAttrib();
269
    glPopAttrib();
-
 
270
    glPopAttrib();
261
}
271
}
262
 
272
 
263
void Console::draw_textf(int x, int y,
273
void Console::draw_textf(int x, int y,
264
                         float r, float g, float b,
274
                         float r, float g, float b,
265
                         const char* fmt, ...)
275
                         const char* fmt, ...)