Exemplo n.º 1
0
void SDLFontGL::initGL(unsigned int x, unsigned int y, unsigned int w, unsigned int h) {
	clearGL();
	checkGLError();

	m_openglActive = true;

	m_charShader.program = loadProgram(char_vertex_shader, char_fragment_shader);
	if (m_charShader.program) {
		glUseProgram(m_charShader.program);
		checkGLError();

		m_charShader.aDim = glGetUniformLocation(m_charShader.program, "dim");
		m_charShader.aPos = glGetAttribLocation(m_charShader.program, "pos");
		m_charShader.aCells = glGetUniformLocation(m_charShader.program, "cells");
		m_charShader.aGlyphs = glGetUniformLocation(m_charShader.program, "glyphs");
		m_charShader.aColors = glGetUniformLocation(m_charShader.program, "colors");
		m_charShader.aGlyphsize = glGetUniformLocation(m_charShader.program, "glyphsize");
		m_charShader.aCellsize = glGetUniformLocation(m_charShader.program, "cellsize");
		m_charShader.aColorsize = glGetUniformLocation(m_charShader.program, "colorsize");
		m_charShader.aBlink = glGetUniformLocation(m_charShader.program, "blink");
		checkGLError();

		glVertexAttribPointer(m_charShader.aPos, 2, GL_FLOAT, GL_FALSE, 0, vertices);
		checkGLError();

		glUniform1i(m_charShader.aCells, 0);
		checkGLError();

		glUniform1i(m_charShader.aGlyphs, 1);
		checkGLError();

		glUniform1i(m_charShader.aColors, 2);
		checkGLError();
	}

	m_cursorShader.program = loadProgram(cursor_vertex_shader, cursor_fragment_shader);
	if (m_cursorShader.program) {
		glUseProgram(m_cursorShader.program);
		checkGLError();

		m_cursorShader.aDim = glGetUniformLocation(m_cursorShader.program, "dim");
		m_cursorShader.aPos = glGetAttribLocation(m_cursorShader.program, "pos");
		m_cursorShader.aCursorpos = glGetUniformLocation(m_cursorShader.program, "cursorpos");
		m_cursorShader.aCursorcolor = glGetUniformLocation(m_cursorShader.program, "cursorcolor");
		m_cursorShader.aCursorstyle = glGetUniformLocation(m_cursorShader.program, "cursorstyle");
		checkGLError();

		glVertexAttribPointer(m_cursorShader.aPos, 2, GL_FLOAT, GL_FALSE, 0, vertices);
		checkGLError();
	}

	m_dimX = x; m_dimY = y; m_dimW = w; m_dimH = h;

	updateFonts();
	updateDimensions();
	updateColors();
	updateCursor();

	checkGLError();
}
Exemplo n.º 2
0
void SDLFontGL::setupFontGL(int fnCount, TTF_Font** fnts, int colCount, SDL_Color *cols) {
	clearGL();

	assert(fnts && cols);
	assert((fnCount > 0) && (colCount > 0));

	nFonts = fnCount;
	nCols = colCount;

	this->fnts = (TTF_Font**)malloc(nFonts*sizeof(TTF_Font*));
	memcpy(this->fnts, fnts, nFonts*sizeof(TTF_Font*));

	this->cols = (SDL_Color*)malloc(nCols*sizeof(SDL_Color));
	memcpy(this->cols, cols, nCols*sizeof(SDL_Color));

	GlyphCache = 0;

	haveCacheLine = (bool*)malloc(nFonts*MAX_CHARSETS*sizeof(bool));
	memset(haveCacheLine, 0, nFonts*MAX_CHARSETS*sizeof(bool));

	const Uint16 OStr[] = {'O', 0};
	if (TTF_SizeUNICODE(fnts[0], OStr, &nWidth, &nHeight) != 0)
		assert(0 && "Failed to size font");
	assert((nWidth > 0) && (nHeight > 0));
}
Exemplo n.º 3
0
void GLGroundPlane::initGL() {
  if (GL_ID) {
    clearGL();
  }
  GL_ID = glGenLists(1);
  glNewList(GL_ID, GL_COMPILE);
  // draw grid
  plotGL();
  glEndList();
}
Exemplo n.º 4
0
void SDLFontGL::setupFontGL(int fnCount, TTF_Font** fnts, int colCount, SDL_Color *cols) {
	clearGL();

	assert(fnts && cols);
	assert((fnCount > 0) && (colCount > 0));

	nFonts = fnCount;
	nCols = colCount;

	this->fnts = (TTF_Font**)malloc(nFonts*sizeof(TTF_Font*));
	memcpy(this->fnts, fnts, nFonts*sizeof(TTF_Font*));

	this->cols = (SDL_Color*)malloc(nCols*sizeof(SDL_Color));
	memcpy(this->cols, cols, nCols*sizeof(SDL_Color));

	GlyphCache = 0;

	haveFontLine = (bool*)malloc(nFonts*sizeof(bool));
	memset(haveFontLine, 0, nFonts*sizeof(bool));

	if (TTF_SizeText(fnts[0], "O", &nWidth, &nHeight) != 0)
		assert(0 && "Failed to size font");
	assert((nWidth > 0) && (nHeight > 0));
}
Exemplo n.º 5
0
void GLGroundPlane::setMinorCount(int count) {
  if (_minorCount != count) clearGL();
  _minorCount = count;
}
Exemplo n.º 6
0
void GLGroundPlane::setMajorDistance(float dist) {
  if (_majorDist != dist) clearGL();
  _majorDist = dist;
}
Exemplo n.º 7
0
void GLGroundPlane::setHeight(float h) {
  if (_height != h) clearGL();
  _height = h;
}
Exemplo n.º 8
0
void GLGroundPlane::setWidth(float w) {
  if (_width != w) clearGL();
  _width = w;
}
Exemplo n.º 9
0
GLGroundPlane::~GLGroundPlane(void) {
  if (GL_ID) clearGL();
}
Exemplo n.º 10
0
SDLFontGL::~SDLFontGL() {
	clearGL();
}
Exemplo n.º 11
0
SDLFontGL::~SDLFontGL() {
	clearGL();
	clearFonts();
}