Ver código fonte

neercs: added a better check for forkpty(), and moved the GL_POINTS

size and texture logic to the vertex shader.
master
Sam Hocevar 12 anos atrás
pai
commit
d8ef25c9ce
7 arquivos alterados com 29 adições e 18 exclusões
  1. +1
    -1
      neercs/old/attach.c
  2. +1
    -0
      neercs/old/effects.c
  3. +1
    -1
      neercs/old/grab.c
  4. +7
    -7
      neercs/term/pty.cpp
  5. +10
    -3
      neercs/video/text-render.cpp
  6. +3
    -1
      neercs/video/text-render.h
  7. +6
    -5
      neercs/video/text.lolfx

+ 1
- 1
neercs/old/attach.c Ver arquivo

@@ -16,7 +16,7 @@
# include "config.h"
#endif

#if !defined _WIN32
#if !defined _WIN32 && defined HAVE_GLOB_H

#include <errno.h>
#include <fcntl.h>


+ 1
- 0
neercs/old/effects.c Ver arquivo

@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <endian.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <caca.h>


+ 1
- 1
neercs/old/grab.c Ver arquivo

@@ -14,7 +14,7 @@
# include "config.h"
#endif

#if !defined _WIN32
#if !defined _WIN32 && defined HAVE_GLOB_H

#define _XOPEN_SOURCE 500 /* getsid() */



+ 7
- 7
neercs/term/pty.cpp Ver arquivo

@@ -14,7 +14,7 @@
# include "config.h"
#endif

#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
#if defined HAVE_FORKPTY
# define _XOPEN_SOURCE
# include <stdlib.h>
# include <stdio.h>
@@ -53,7 +53,7 @@ Pty::Pty()

Pty::~Pty()
{
#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
#if defined HAVE_FORKPTY
delete[] m_unread_data;

if (m_fd >= 0)
@@ -65,7 +65,7 @@ Pty::~Pty()

void Pty::Run(char const *command, ivec2 size)
{
#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
#if defined HAVE_FORKPTY
int fd;
pid_t pid;

@@ -112,7 +112,7 @@ bool Pty::IsEof() const

size_t Pty::ReadData(char *data, size_t maxlen)
{
#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
#if defined HAVE_FORKPTY
/* Do we have data from previous call? */
if (m_unread_len)
{
@@ -172,7 +172,7 @@ size_t Pty::ReadData(char *data, size_t maxlen)

void Pty::UnreadData(char *data, size_t len)
{
#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
#if defined HAVE_FORKPTY
char *new_data;

if (m_unread_data)
@@ -193,7 +193,7 @@ void Pty::UnreadData(char *data, size_t len)

size_t Pty::WriteData(char const *data, size_t len)
{
#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
#if defined HAVE_FORKPTY
/* FIXME: can we be more naive than that? */
return write((int)m_fd, data, len);
#endif
@@ -203,7 +203,7 @@ size_t Pty::WriteData(char const *data, size_t len)

void Pty::SetWindowSize(ivec2 size, int64_t fd /* = -1 */)
{
#if defined HAVE_PTY_H || defined HAVE_UTIL_H || defined HAVE_LIBUTIL_H
#if defined HAVE_FORKPTY
if (m_size == size)
return;



+ 10
- 3
neercs/video/text-render.cpp Ver arquivo

@@ -50,8 +50,9 @@ void TextRender::Init()
VertexUsage::Color, 0);
m_char = m_shader->GetAttribLocation("in_Char",
VertexUsage::Color, 1);
m_texture = m_shader->GetUniformLocation("in_Texture");
m_transform = m_shader->GetUniformLocation("in_Transform");
m_texture = m_shader->GetUniformLocation("u_Texture");
m_transform = m_shader->GetUniformLocation("u_Transform");
m_pointsize = m_shader->GetUniformLocation("u_PointSize");
m_vdecl
= new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position),
VertexStream<uint32_t>(VertexUsage::Color),
@@ -128,14 +129,18 @@ void TextRender::Render()
m_fbo->Bind();
glViewport(0, 0, m_fbo_size.x, m_fbo_size.y);
glDisable(GL_DEPTH_TEST);
#if !defined HAVE_GLES_2X
glEnable(GL_POINT_SPRITE);
//glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
glDisable(GL_POINT_SMOOTH);
glPointSize((float)max(m_font_size.x, m_font_size.y));
#endif
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
m_shader->Bind();
m_font->Bind();
m_shader->SetUniform(m_texture, 0);
m_shader->SetUniform(m_transform, xform);
m_shader->SetUniform(m_pointsize, (float)max(m_font_size.x, m_font_size.y));
m_vdecl->SetStream(m_vbo1, m_coord);
m_vdecl->SetStream(m_vbo2, m_color);
m_vdecl->SetStream(m_vbo3, m_char);
@@ -144,7 +149,9 @@ void TextRender::Render()
m_vdecl->Unbind();
m_font->Unbind();
m_shader->Unbind();
#if !defined HAVE_GLES_2X
glDisable(GL_POINT_SPRITE);
#endif
m_fbo->Unbind();
}



+ 3
- 1
neercs/video/text-render.h Ver arquivo

@@ -20,11 +20,13 @@ private:
int m_cells;

TileSet *m_font;

Shader *m_shader;
ShaderAttrib m_coord, m_color, m_char;
ShaderUniform m_texture, m_transform;
ShaderUniform m_texture, m_transform, m_pointsize;
VertexDeclaration *m_vdecl;
VertexBuffer *m_vbo1, *m_vbo2, *m_vbo3;

FrameBuffer *m_fbo;
};



+ 6
- 5
neercs/video/text.lolfx Ver arquivo

@@ -15,7 +15,8 @@ varying vec4 pass_Foreground;
varying vec4 pass_Background;
varying vec2 pass_UV;

uniform mat4 in_Transform;
uniform float u_PointSize;
uniform mat4 u_Transform;

void main()
{
@@ -56,9 +57,9 @@ void main()
if (F + G + H < 0.01) E = 1.0;

// This only works with glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
//gl_PointSize = 40;
gl_PointSize = u_PointSize;

gl_Position = in_Transform * vec4(in_Position, 0.0, 1.0);
gl_Position = u_Transform * vec4(in_Position, 0.0, 1.0);
}

[frag.glsl]
@@ -69,11 +70,11 @@ varying vec4 pass_Foreground;
varying vec4 pass_Background;
varying vec2 pass_UV;

uniform sampler2D in_Texture;
uniform sampler2D u_Texture;

void main(void)
{
vec2 c = gl_PointCoord * (1.0 / 32.0) + pass_UV;
float t = texture2D(in_Texture, c).x;
float t = texture2D(u_Texture, c).x;
gl_FragColor = mix(pass_Background, pass_Foreground, t);
}

Carregando…
Cancelar
Salvar