Moved oscilloscope back to its original location, now uses new gfx api
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@727 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -196,10 +196,6 @@ SOURCE=..\sc2code\libs\graphics\sdl\opengl.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sc2code\libs\graphics\sdl\oscilloscope.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\sc2code\libs\graphics\sdl\primitives.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
uqm_CFILES="3do_blt.c 3do_funcs.c 3do_getbody.c dcqueue.c opengl.c
|
||||
primitives.c pure.c rndzoom.c rotozoom.c sdl_common.c oscilloscope.c
|
||||
primitives.c pure.c rndzoom.c rotozoom.c sdl_common.c
|
||||
canvas.c bbox.c 2xscalers.c"
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include "sdl_common.h"
|
||||
#include "primitives.h"
|
||||
#include "libs/sound/trackplayer.h"
|
||||
|
||||
static FRAMEPTR scope_frame;
|
||||
static int scope_init = 0;
|
||||
static SDL_Surface *scope_bg = NULL; // oscilloscope background (lbm/activity.9.png)
|
||||
static SDL_Surface *scope_surf = NULL;
|
||||
static UBYTE scope_data[RADAR_WIDTH];
|
||||
|
||||
|
||||
void
|
||||
InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME_DESC *f)
|
||||
{
|
||||
TFB_Image *img = f->image;
|
||||
|
||||
assert (((SDL_Surface *)img->NormalImg)->format->BytesPerPixel == 1);
|
||||
assert (((SDL_Surface *)img->NormalImg)->w == RADAR_WIDTH);
|
||||
assert (((SDL_Surface *)img->NormalImg)->h == RADAR_HEIGHT);
|
||||
|
||||
if (scope_init == 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
LockMutex (img->mutex);
|
||||
scope_bg = SDL_CreateRGBSurface (SDL_SWSURFACE, ((SDL_Surface *)img->NormalImg)->w,
|
||||
((SDL_Surface *)img->NormalImg)->h, 8,
|
||||
0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000);
|
||||
scope_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, ((SDL_Surface *)img->NormalImg)->w,
|
||||
((SDL_Surface *)img->NormalImg)->h, 8,
|
||||
0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000);
|
||||
|
||||
for (i = 0; i < 256; ++i)
|
||||
{
|
||||
scope_bg->format->palette->colors[i].r = scope_surf->format->palette->colors[i].r =
|
||||
((SDL_Surface *)img->NormalImg)->format->palette->colors[i].r;
|
||||
scope_bg->format->palette->colors[i].g = scope_surf->format->palette->colors[i].g =
|
||||
((SDL_Surface *)img->NormalImg)->format->palette->colors[i].g;
|
||||
scope_bg->format->palette->colors[i].b = scope_surf->format->palette->colors[i].b =
|
||||
((SDL_Surface *)img->NormalImg)->format->palette->colors[i].b;
|
||||
}
|
||||
|
||||
SDL_BlitSurface (img->NormalImg, NULL, scope_bg, NULL);
|
||||
UnlockMutex (img->mutex);
|
||||
scope_init = 1;
|
||||
}
|
||||
|
||||
scope_frame = f;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
UninitOscilloscope (void)
|
||||
{
|
||||
if (scope_bg)
|
||||
{
|
||||
SDL_FreeSurface (scope_bg);
|
||||
scope_bg = NULL;
|
||||
}
|
||||
if (scope_surf)
|
||||
{
|
||||
SDL_FreeSurface (scope_surf);
|
||||
scope_surf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// draws the oscilloscope
|
||||
void
|
||||
Oscilloscope (DWORD grab_data)
|
||||
{
|
||||
int i;
|
||||
TFB_Image *img;
|
||||
STAMP s;
|
||||
|
||||
if (!grab_data)
|
||||
return;
|
||||
|
||||
SDL_BlitSurface (scope_bg, NULL, scope_surf, NULL);
|
||||
if (GetSoundData (scope_data))
|
||||
{
|
||||
PutPixelFn scope_plot = putpixel_for (scope_surf);
|
||||
|
||||
SDL_LockSurface (scope_surf);
|
||||
for (i = 0; i < RADAR_WIDTH - 1; ++i)
|
||||
{
|
||||
line (i, scope_data[i], i + 1, scope_data[i + 1], 238, scope_plot, scope_surf);
|
||||
}
|
||||
SDL_UnlockSurface (scope_surf);
|
||||
}
|
||||
|
||||
img = scope_frame->image;
|
||||
LockMutex (img->mutex);
|
||||
SDL_BlitSurface (scope_surf, NULL, img->NormalImg, NULL);
|
||||
UnlockMutex (img->mutex);
|
||||
|
||||
s.frame = scope_frame;
|
||||
s.origin.x = s.origin.y = 0;
|
||||
DrawStamp (&s);
|
||||
}
|
||||
@@ -17,14 +17,78 @@
|
||||
*/
|
||||
|
||||
#include "libs/graphics/gfx_common.h"
|
||||
#include "libs/graphics/drawable.h"
|
||||
#include "libs/sound/trackplayer.h"
|
||||
|
||||
static FRAMEPTR scope_frame;
|
||||
static int scope_init = 0;
|
||||
static TFB_Image *scope_bg = NULL;
|
||||
static TFB_Image *scope_surf = NULL;
|
||||
static UBYTE scope_data[RADAR_WIDTH];
|
||||
|
||||
void
|
||||
InitOscilloscope (DWORD x, DWORD y, DWORD width, DWORD height, FRAME_DESC *f)
|
||||
{
|
||||
scope_frame = f;
|
||||
if (!scope_init)
|
||||
{
|
||||
TFB_Canvas scope_bg_canvas, scope_surf_canvas;
|
||||
scope_bg_canvas = TFB_DrawCanvas_New_Paletted (width, height, f->image->Palette, -1);
|
||||
scope_bg = TFB_DrawImage_New (scope_bg_canvas);
|
||||
scope_surf_canvas = TFB_DrawCanvas_New_Paletted (width, height, f->image->Palette, -1);
|
||||
scope_surf = TFB_DrawImage_New (scope_surf_canvas);
|
||||
TFB_DrawImage_Image (f->image, 0, 0, FALSE, NULL, scope_bg);
|
||||
scope_init = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UninitOscilloscope (void)
|
||||
{
|
||||
if (scope_bg)
|
||||
{
|
||||
TFB_DrawImage_Delete (scope_bg);
|
||||
scope_bg = NULL;
|
||||
}
|
||||
if (scope_surf)
|
||||
{
|
||||
TFB_DrawImage_Delete (scope_surf);
|
||||
scope_surf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// draws the oscilloscope
|
||||
void
|
||||
Oscilloscope (DWORD grab_data)
|
||||
{
|
||||
STAMP s;
|
||||
|
||||
if (!grab_data)
|
||||
return;
|
||||
|
||||
TFB_DrawImage_Image (scope_bg, 0, 0, FALSE, NULL, scope_surf);
|
||||
if (GetSoundData (scope_data))
|
||||
{
|
||||
int i, r, g, b;
|
||||
r = scope_surf->Palette[238].r;
|
||||
g = scope_surf->Palette[238].g;
|
||||
b = scope_surf->Palette[238].b;
|
||||
for (i = 0; i < RADAR_WIDTH - 1; ++i)
|
||||
TFB_DrawImage_Line (i, scope_data[i], i + 1, scope_data[i + 1], r, g, b, scope_surf);
|
||||
}
|
||||
TFB_DrawImage_Image (scope_surf, 0, 0, FALSE, NULL, scope_frame->image);
|
||||
|
||||
s.frame = scope_frame;
|
||||
s.origin.x = s.origin.y = 0;
|
||||
DrawStamp (&s);
|
||||
}
|
||||
|
||||
|
||||
static STAMP sliderStamp;
|
||||
static STAMP buttonStamp;
|
||||
static BOOLEAN sliderChanged = FALSE;
|
||||
int sliderSpace; // slider width - button width
|
||||
|
||||
|
||||
/*
|
||||
* Initialise the communication progress bar
|
||||
* x - x location of slider
|
||||
@@ -72,4 +136,3 @@ Slider (void)
|
||||
UnbatchGraphics ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user