public static void WriteArray(int r,int c,colorchar[,] array) { int h = array.GetLength(0); int w = array.GetLength(1); for(int i=0;i<h;++i){ for(int j=0;j<w;++j){ //WriteChar(i+r,j+c,array[i,j]); colorchar ch = array[i,j]; if(!memory[r+i,c+j].Equals(ch)){ ch.color = Colors.ResolveColor(ch.color); ch.bgcolor = Colors.ResolveColor(ch.bgcolor); //memory[r+i,c+j] = ch; array[i,j] = ch; if(!GLMode){ if(!memory[r+i,c+j].Equals(ch)){ //check again to avoid writing to console when possible memory[r+i,c+j] = ch; ConsoleColor co = Colors.GetColor(ch.color); if(co != ForegroundColor){ ForegroundColor = co; } co = Colors.GetColor(ch.bgcolor); if(co != Console.BackgroundColor || Global.LINUX){//voodoo here. not sure why this is needed. (possible Mono bug) BackgroundColor = co; } Console.SetCursorPosition(c+j,r+i); Console.Write(ch.c); } } else{ memory[r+i,c+j] = ch; } } } } if(GLMode && !NoGLUpdate){ UpdateGLBuffer(r,c,array); } }
public static void WriteArray(int r,int c,colorchar[,] array){ int h = array.GetLength(0); int w = array.GetLength(1); for(int i=0;i<h;++i){ for(int j=0;j<w;++j){ WriteChar(i+r,j+c,array[i,j]); } } }
public static void UpdateGLBuffer(int start_row,int start_col,colorchar[,] array) { int array_h = array.GetLength(0); int array_w = array.GetLength(1); int start_idx = start_col + start_row*Global.SCREEN_W; int end_idx = (start_col + array_w - 1) + (start_row + array_h - 1)*Global.SCREEN_W; int count = (end_idx - start_idx) + 1; int end_row = start_row + array_h - 1; int end_col = start_col + array_w - 1; int[] sprite_rows = new int[count]; int[] sprite_cols = new int[count]; float[][] color_info = new float[2][]; color_info[0] = new float[4 * count]; color_info[1] = new float[4 * count]; for(int n=0;n<count;++n){ int row = (n + start_col) / Global.SCREEN_W + start_row; //screen coords int col = (n + start_col) % Global.SCREEN_W; colorchar cch = (row >= start_row && row <= end_row && col >= start_col && col <= end_col)? array[row-start_row,col-start_col] : memory[row,col]; Color4 color = Colors.ConvertColor(cch.color); Color4 bgcolor = Colors.ConvertColor(cch.bgcolor); //sprite_rows[n] = 0; sprite_cols[n] = (int)cch.c; int idx4 = n * 4; color_info[0][idx4] = color.R; color_info[0][idx4 + 1] = color.G; color_info[0][idx4 + 2] = color.B; color_info[0][idx4 + 3] = color.A; color_info[1][idx4] = bgcolor.R; color_info[1][idx4 + 1] = bgcolor.G; color_info[1][idx4 + 2] = bgcolor.B; color_info[1][idx4 + 3] = bgcolor.A; } Game.gl.UpdateVertexArray(start_row,start_col,GLGame.text_surface,sprite_rows,sprite_cols,color_info); }