Bläddra i källkod

added function key and renamed some variables

master
förälder
incheckning
2daf8f63a5
4 ändrade filer med 25 tillägg och 18 borttagningar
  1. +1
    -4
      neercs/neercs.cpp
  2. +19
    -10
      neercs/video/render.cpp
  3. +1
    -0
      neercs/video/render.h
  4. +4
    -4
      neercs/video/text.lolfx

+ 1
- 4
neercs/neercs.cpp Visa fil

@@ -59,6 +59,7 @@ void Neercs::TickGame(float seconds)

m_time += seconds;

/* draw something */
caca_set_color_argb(m_caca, 0xfff, 0x222);
caca_clear_canvas(m_caca);

@@ -85,10 +86,6 @@ void Neercs::TickGame(float seconds)

caca_put_str(m_caca, 0, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
caca_put_str(m_caca, 0, 1, " !\"#$%&'()*+,-./0123456789");

if (Input::GetButtonState(27 /*SDLK_ESCAPE*/))
Ticker::Shutdown();

}

void Neercs::TickDraw(float seconds)


+ 19
- 10
neercs/video/render.cpp Visa fil

@@ -46,10 +46,9 @@ extern char const *lolfx_simple;
* Various variables
*/

int keys[256]; // keyboard array
int active = true; // window active flag
bool fullscreen = DEBUG?false:true; // fullscreen flag
bool paused = false; // pause flag
bool m_paused = false; // pause flag
float nearplane = 0.1f; // nearplane
float farplane = 1000.0f; // farplane
bool polygon = true; // polygon mode
@@ -107,7 +106,7 @@ int key_code = 0; // keyboard code
/* common variable */
float value, angle, radius, scale, speed;
/* shader variable */
bool shader_flag = true;
bool m_shader = true; /* TO DELETE */
bool shader_blur_flag = true;
bool shader_glow_flag = true;
bool shader_effect_flag = true;
@@ -221,7 +220,7 @@ int InitGL(void)
glEnable(GL_CULL_FACE); // disable cull face
glCullFace(GL_BACK); // don't draw front face

if (shader_flag)
if (m_shader)
{
/* Initialise framebuffer objects */
fbo_back = new FrameBuffer(screen_size);
@@ -278,7 +277,7 @@ int InitGL(void)
return true;
}

int CreateGLWindow(char const *title)
int CreateGLWindow()
{
screen_size = Video::GetSize();
corner_w = 16*ratio_2d.x;
@@ -306,7 +305,8 @@ int CreateGLWindow(char const *title)

Render::Render(caca_canvas_t *caca)
: m_caca(caca),
m_ready(false)
m_ready(false),
m_shader(true)
{
text_render = new TextRender(m_caca, font_size);
}
@@ -318,18 +318,26 @@ void Render::TickGame(float seconds)

void Render::TickDraw(float seconds)
{
/* keyboard manager */
if (Input::GetButtonState(27/*SDLK_ESCAPE*/))
Ticker::Shutdown();
if (Input::GetButtonState(8 /*SDLK_BACKSPACE*/))
m_paused=!m_paused;
if (Input::GetButtonState(112 /*SDLK_F1*/))
m_shader=!m_shader;

Entity::TickDraw(seconds);

if (!m_ready)
{
CreateGLWindow("LOL");
CreateGLWindow();
text_render->Init();

m_ready = true;
}

// timer
if(!paused)
if(!m_paused)
main_angle += seconds * 100.0f * PID;
if(sync_flag)
{
@@ -381,7 +389,7 @@ void Render::Draw2D()
/* Draw text in an offline buffer */
text_render->Render();

if(shader_flag)
if(m_shader)
fbo_back->Bind();

glViewport(0, 0, screen_size.x, screen_size.y);
@@ -453,6 +461,7 @@ void Render::Draw2D()
// draw corner
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glColor3f(0, 1.0f, 0);
glVertexPointer(2, GL_INT, 0, corner_vtx);
glLoadIdentity();
glColor3f(0, 0, 0);
@@ -471,7 +480,7 @@ void Render::Draw2D()

void Render::Draw3D()
{
if (!shader_flag)
if (!m_shader)
return;

glDisable(GL_DEPTH_TEST);


+ 1
- 0
neercs/video/render.h Visa fil

@@ -22,6 +22,7 @@ protected:
private:
caca_canvas_t *m_caca;
bool m_ready;
bool m_shader;
};

#endif // __VIDEO_RENDER_H__


+ 4
- 4
neercs/video/text.lolfx Visa fil

@@ -22,10 +22,10 @@ void main()
float C = float((in_Attr >> 21u) & 0xfu) / 15.0;
float D = float((in_Attr >> 18u) & 0x7u) / 7.0;

float E = float((in_Attr >> 15u) & 0x7u) / 7.0;
float F = float((in_Attr >> 11u) & 0xfu) / 15.0;
float G = float((in_Attr >> 7u) & 0xfu) / 15.0;
float H = float((in_Attr >> 4u) & 0x7u) / 7.0;
float E = float((in_Attr >> 15u) & 0x7u) / 7.0;
float F = float((in_Attr >> 11u) & 0xfu) / 15.0;
float G = float((in_Attr >> 7u) & 0xfu) / 15.0;
float H = float((in_Attr >> 4u) & 0x7u) / 7.0;

pass_Background = vec4(B, C, D, 1.0 - A);
pass_Foreground = vec4(F, G, H, 1.0 - E);


Laddar…
Avbryt
Spara