LoadGraphic uses LoadSprite

This commit is contained in:
jsalmon3 2004-03-13 20:22:34 +00:00
parent a134fea46c
commit 260266cf5c
8 changed files with 121 additions and 245 deletions

View file

@ -421,9 +421,6 @@ global void ShowIntro(const Intro* intro)
background = LoadGraphic(intro->Background);
ResizeGraphic(background, VideoWidth, VideoHeight);
#ifdef USE_OPENGL
MakeTexture(background, background->Width, background->Height);
#endif
LibraryFileName(intro->TextFile, buf);
if (!(file = CLopen(buf, CL_OPEN_READ))) {
@ -610,9 +607,6 @@ global void ShowCredits(Credits* credits)
if (credits->Background) {
background = LoadGraphic(credits->Background);
ResizeGraphic(background, VideoWidth, VideoHeight);
#ifdef USE_OPENGL
MakeTexture(background, background->Width, background->Height);
#endif
}
// play different music?
@ -763,9 +757,6 @@ global void ShowPicture(CampaignChapter* chapter)
background = LoadGraphic(chapter->Data.Picture.Image);
ResizeGraphic(background, VideoWidth, VideoHeight);
#ifdef USE_OPENGL
MakeTexture(background, background->Width, background->Height);
#endif
IntroNoEvent = 1;
text = chapter->Data.Picture.Text;

View file

@ -69,10 +69,10 @@ extern unsigned AllocatedGraphicMemory; /// Allocated memory for objects
#endif
/**
** Event call back.
** Event call back.
**
** This is placed in the video part, because it depends on the video
** hardware driver.
** This is placed in the video part, because it depends on the video
** hardware driver.
*/
typedef struct _event_callback_ {
@ -99,22 +99,22 @@ typedef struct _event_callback_ {
} EventCallback;
/// Graphic reference used during config/setup
/// Graphic reference used during config/setup
typedef struct _graphic_config_ {
char* File; /// config graphic name or file
Graphic* Graphic; /// graphic pointer to use to run time
} GraphicConfig;
/// Creates a shared hardware palette from an independent Palette struct.
/// Creates a shared hardware palette from an independent Palette struct.
extern SDL_Palette* VideoCreateSharedPalette(const SDL_Palette* palette);
/// Free a shared hardware palette.
/// Free a shared hardware palette.
extern void VideoFreeSharedPalette(SDL_Palette* palette);
extern int ColorCycleAll; /// Flag color cycle palettes
/**
** Typedef for palette links.
** Typedef for palette links.
*/
typedef struct _palette_link_ PaletteLink;
@ -132,48 +132,48 @@ extern void VideoPaletteListAdd(SDL_Surface* surface);
extern void VideoPaletteListRemove(SDL_Surface* surface);
/**
** Video synchronization speed. Synchronization time in percent.
** If =0, video framerate is not synchronized. 100 is exact
** CYCLES_PER_SECOND (30). Game will try to redraw screen within
** intervals of VideoSyncSpeed, not more, not less.
** @see CYCLES_PER_SECOND @see VideoInterrupts
** Video synchronization speed. Synchronization time in percent.
** If =0, video framerate is not synchronized. 100 is exact
** CYCLES_PER_SECOND (30). Game will try to redraw screen within
** intervals of VideoSyncSpeed, not more, not less.
** @see CYCLES_PER_SECOND @see VideoInterrupts
*/
extern int VideoSyncSpeed;
extern volatile int VideoInterrupts;
/// Wanted videomode, fullscreen or windowed.
/// Wanted videomode, fullscreen or windowed.
extern char VideoFullScreen;
/// Fullscreen or windowed set from commandline.
/// Fullscreen or windowed set from commandline.
extern char VideoForceFullScreen;
/// Initialize Pixels[] for all players.
/// (bring Players[] in sync with Pixels[])
/// Initialize Pixels[] for all players.
/// (bring Players[] in sync with Pixels[])
extern void SetPlayersPalette(void);
/// Lock the screen for display
/// Lock the screen for display
extern void VideoLockScreen(void);
/// Unlock the screen for display
/// Unlock the screen for display
extern void VideoUnlockScreen(void);
/// Wanted videomode, fullscreen or windowed.
/// Wanted videomode, fullscreen or windowed.
extern char VideoFullScreen;
/**
** Architecture-dependant video depth. Set by InitVideoXXX, if 0.
** (8,15,16,24,32)
** @see InitVideo @see InitVideoSdl
** @see main
** Architecture-dependent video depth. Set by InitVideoXXX, if 0.
** (8,15,16,24,32)
** @see InitVideo @see InitVideoSdl
** @see main
*/
extern int VideoDepth;
/**
** Architecture-dependant videomemory. Set by InitVideoXXX.
** FIXME: need a new function to set it, see #ifdef SDL code
** @see InitVideo @see InitVideoSdl
** @see VMemType
** Architecture-dependant videomemory. Set by InitVideoXXX.
** FIXME: need a new function to set it, see #ifdef SDL code
** @see InitVideo @see InitVideoSdl
** @see VMemType
*/
extern SDL_Surface* TheScreen;
@ -195,7 +195,7 @@ extern void InitVideo(void);
/// Resize a graphic
extern void ResizeGraphic(Graphic* g, int w, int h);
/// Load graphic from PNG file
/// Load graphic from PNG file
extern Graphic* LoadGraphicPNG(const char* name);
#ifdef USE_OPENGL
@ -212,20 +212,17 @@ extern Graphic* LoadGraphic(const char* file);
/// Flip graphic and store in graphic->SurfaceFlip
extern void FlipGraphic(Graphic* graphic);
/// New graphic
extern Graphic* NewGraphic(unsigned d, int w, int h);
/// Initializes video synchronization.
/// Initializes video synchronization.
extern void SetVideoSync(void);
/// Clear video screen
/// Clear video screen
extern void VideoClearScreen(void);
/// Make graphic
extern Graphic* MakeGraphic(unsigned, int, int, void*, unsigned);
/// Load a picture and display it on the screen (full screen),
/// changing the colormap and so on..
/// Load a picture and display it on the screen (full screen),
/// changing the colormap and so on..
extern void DisplayPicture(const char *name);
/// Init graphic
@ -240,15 +237,15 @@ extern void InitLineDraw(void);
/// Simply invalidates whole window or screen.
extern void Invalidate(void);
/// Invalidates selected area on window or screen. Use for accurate
/// redrawing. in so
/// Invalidates selected area on window or screen. Use for accurate
/// redrawing. in so
extern void InvalidateArea(int x, int y, int w, int h);
/// Set clipping for nearly all vector primitives. Functions which support
/// clipping will be marked Clip. Set the system-wide clipping rectangle.
/// Set clipping for nearly all vector primitives. Functions which support
/// clipping will be marked Clip. Set the system-wide clipping rectangle.
extern void SetClipping(int left, int top, int right, int bottom);
/// Realize video memory.
/// Realize video memory.
extern void RealizeVideoMemory(void);
/// Load sprite
@ -257,33 +254,33 @@ extern Graphic* LoadSprite(const char* file, int w, int h);
/// Make shadow sprite
extern void MakeShadowSprite(Graphic* graphic);
/// Draw a graphic clipped and with alpha.
/// Draw a graphic clipped and with alpha.
extern void VideoDrawSubTrans(const Graphic* graphic, int gx, int gy,
int w, int h, int x, int y, unsigned char alpha);
/// Draw part of a graphic clipped and with alpha.
/// Draw part of a graphic clipped and with alpha.
extern void VideoDrawSubClipTrans(const Graphic* graphic, int gx, int gy,
int w, int h, int x, int y, unsigned char alpha);
/// Save a screenshot to a PNG file
/// Save a screenshot to a PNG file
extern void SaveScreenshotPNG(const char* name);
/// Creates a hardware palette from an independent Palette struct.
/// Creates a hardware palette from an independent Palette struct.
extern SDL_Palette* VideoCreateNewPalette(const SDL_Palette* palette);
/// Prints warning if video is too slow..
extern void CheckVideoInterrupts(void);
/// Process all system events. Returns if the time for a frame is over
/// Process all system events. Returns if the time for a frame is over
extern void WaitEventsOneFrame(const EventCallback* callbacks);
/// Toggle full screen mode
extern void ToggleFullScreen(void);
/// Push current clipping.
/// Push current clipping.
extern void PushClipping(void);
/// Pop current clipping.
/// Pop current clipping.
extern void PopClipping(void);
/// Returns the ticks in ms since start
@ -320,191 +317,191 @@ extern int ColorBuildingCycleEnd; /// color # end for color cycling
#endif
#ifndef USE_OPENGL
/// Draw pixel unclipped.
/// Draw pixel unclipped.
extern void (*VideoDrawPixel)(Uint32 color, int x, int y);
/// Draw translucent pixel unclipped.
/// Draw translucent pixel unclipped.
extern void (*VideoDrawTransPixel)(Uint32 color, int x, int y,
unsigned char alpha);
#else
/// Draw pixel unclipped.
/// Draw pixel unclipped.
extern void VideoDrawPixel(Uint32 color, int x, int y);
/// Draw translucent pixel unclipped.
/// Draw translucent pixel unclipped.
extern void VideoDrawTransPixel(Uint32 color, int x, int y,
unsigned char alpha);
#endif
/// Draw pixel clipped to current clip setting.
/// Draw pixel clipped to current clip setting.
extern void VideoDrawPixelClip(Uint32 color, int x, int y);
/// Draw translucent pixel clipped to current clip setting.
/// Draw translucent pixel clipped to current clip setting.
extern void VideoDrawTransPixelClip(Uint32 color, int x, int y,
unsigned char alpha);
/// Draw vertical line unclipped.
/// Draw vertical line unclipped.
extern void VideoDrawVLine(Uint32 color, int x, int y,
int height);
/// Draw translucent vertical line unclipped.
/// Draw translucent vertical line unclipped.
extern void VideoDrawTransVLine(Uint32 color, int x, int y,
int height, unsigned char alpha);
/// Draw vertical line clipped to current clip setting
/// Draw vertical line clipped to current clip setting
extern void VideoDrawVLineClip(Uint32 color, int x, int y,
int height);
/// Draw translucent vertical line clipped to current clip setting
/// Draw translucent vertical line clipped to current clip setting
extern void VideoDrawTransVLineClip(Uint32 color, int x, int y,
int height, unsigned char alpha);
/// Draw horizontal line unclipped.
/// Draw horizontal line unclipped.
extern void VideoDrawHLine(Uint32 color, int x, int y,
int width);
/// Draw translucent horizontal line unclipped.
/// Draw translucent horizontal line unclipped.
extern void VideoDrawTransHLine(Uint32 color, int x, int y,
int width, unsigned char alpha);
/// Draw horizontal line clipped to current clip setting
/// Draw horizontal line clipped to current clip setting
extern void VideoDrawHLineClip(Uint32 color, int x, int y,
int width);
/// Draw translucent horizontal line clipped to current clip setting
/// Draw translucent horizontal line clipped to current clip setting
extern void VideoDrawTransHLineClip(Uint32 color, int x, int y,
int width, unsigned char alpha);
/// Draw line unclipped.
/// Draw line unclipped.
extern void VideoDrawLine(Uint32 color, int sx, int sy, int dx, int dy);
/// Draw translucent line unclipped.
/// Draw translucent line unclipped.
extern void VideoDrawTransLine(Uint32 color, int sx, int sy, int dx, int dy,
unsigned char alpha);
/// Draw line clipped to current clip setting
/// Draw line clipped to current clip setting
extern void VideoDrawLineClip(Uint32 color, int sx, int sy, int dx, int dy);
/// Draw translucent line clipped to current clip setting
/// Draw translucent line clipped to current clip setting
extern void VideoDrawTransLineClip(Uint32 color, int sx, int sy,
int dx, int dy, unsigned char alpha);
/// Draw rectangle.
/// Draw rectangle.
extern void VideoDrawRectangle(Uint32 color, int x, int y,
int w, int h);
/// Draw translucent rectangle.
/// Draw translucent rectangle.
extern void VideoDrawTransRectangle(Uint32 color, int x, int y,
int w, int h, unsigned char alpha);
/// Draw rectangle clipped.
/// Draw rectangle clipped.
extern void VideoDrawRectangleClip(Uint32 color, int x, int y,
int w, int h);
/// Draw translucent rectangle clipped.
/// Draw translucent rectangle clipped.
extern void VideoDrawTransRectangleClip(Uint32 color, int x, int y,
int w, int h, unsigned char alpha);
/// Draw 8bit raw graphic data clipped, using given pixel pallette
/// Draw 8bit raw graphic data clipped, using given pixel pallette
extern void VideoDrawRawClip(SDL_Surface *surface, int x, int y, int w, int h);
/// Does ColorCycling..
extern void ColorCycle(void);
/// Draw circle.
/// Draw circle.
extern void VideoDrawCircle(Uint32 color, int x, int y, int r);
/// Draw translucent circle.
/// Draw translucent circle.
extern void VideoDrawTransCircle(Uint32 color, int x, int y, int r,
unsigned char alpha);
/// Draw circle clipped.
/// Draw circle clipped.
extern void VideoDrawCircleClip(Uint32 color, int x, int y, int r);
/// Draw translucent circle clipped.
/// Draw translucent circle clipped.
extern void VideoDrawTransCircleClip(Uint32 color, int x, int y, int r,
unsigned char alpha);
/// Fill rectangle.
/// Fill rectangle.
extern void VideoFillRectangle(Uint32 color, int x, int y,
int w, int h);
/// Fill translucent rectangle.
/// Fill translucent rectangle.
extern void VideoFillTransRectangle(Uint32 color, int x, int y,
int w, int h, unsigned char alpha);
/// Fill rectangle clipped.
/// Fill rectangle clipped.
extern void VideoFillRectangleClip(Uint32 color, int x, int y,
int w, int h);
/// Fill translucent rectangle clipped.
/// Fill translucent rectangle clipped.
extern void VideoFillTransRectangleClip(Uint32 color, int x, int y,
int w, int h, unsigned char alpha);
/// Fill circle.
/// Fill circle.
extern void VideoFillCircle(Uint32 color, int x, int y, int r);
/// Fill translucent circle.
/// Fill translucent circle.
extern void VideoFillTransCircle(Uint32 color, int x, int y, int r,
unsigned char alpha);
/// Fill circle clipped.
/// Fill circle clipped.
extern void VideoFillCircleClip(Uint32 color, int x, int y, int r);
/// Fill translucent circle clipped.
/// Fill translucent circle clipped.
extern void VideoFillTransCircleClip(Uint32 color, int x, int y, int r,
unsigned char alpha);
/// Draw a graphic object unclipped.
/// Draw a graphic object unclipped.
extern void VideoDraw(const Graphic*, unsigned, int, int);
/// Draw a graphic object clipped to the current clipping.
/// Draw a graphic object clipped to the current clipping.
extern void VideoDrawSub(const Graphic*, int, int, int, int, int, int);
/// Draw a graphic object clipped to the current clipping.
/// Draw a graphic object clipped to the current clipping.
extern void VideoDrawClip(const Graphic*, unsigned frame, int x, int y);
/// Draw a graphic object clipped to the current clipping.
/// Draw a graphic object clipped to the current clipping.
extern void VideoDrawSubClip(const Graphic*, int ix, int iy, int w,
int h, int x, int y);
/// Draw a graphic object unclipped and flipped in X direction.
/// Draw a graphic object unclipped and flipped in X direction.
extern void VideoDrawX(const Graphic*, unsigned frame, int x, int y);
/// Draw a graphic object clipped and flipped in X direction.
/// Draw a graphic object clipped and flipped in X direction.
extern void VideoDrawClipX(const Graphic*, unsigned frame, int x, int y);
/// Translucent Functions
/// Draw a graphic object unclipped.
/// Draw a graphic object unclipped.
extern void VideoDrawTrans(const Graphic*, unsigned, int, int, int);
/// Draw a graphic object clipped to the current clipping.
/// Draw a graphic object clipped to the current clipping.
extern void VideoDrawClipTrans(const Graphic*, unsigned frame, int x, int y, int);
/// Draw a graphic object unclipped and flipped in X direction.
/// Draw a graphic object unclipped and flipped in X direction.
extern void VideoDrawTransX(const Graphic*, unsigned frame, int x, int y, int alpha);
/// Draw a graphic object clipped and flipped in X direction.
/// Draw a graphic object clipped and flipped in X direction.
extern void VideoDrawClipTransX(const Graphic*, unsigned frame, int x, int y, int alpha);
/// Draw a graphic object unclipped.
#define VideoDrawTrans50(o, f, x, y) VideoDrawTrans((o), (f), (x), (y), 128)
/// Draw a graphic object unclipped and flipped in X direction.
#define VideoDrawXTrans50(o, f, x, y) VideoDrawTransX((o), (f), (x), (y), 128)
/// Draw a graphic object clipped to the current clipping.
#define VideoDrawClipTrans50(o, f, x, y) VideoDrawClipTrans((o), (f), (x), (y), 128)
/// Draw a graphic object clipped and flipped in X direction.
#define VideoDrawClipXTrans50(o, f, x, y) VideoDrawClipTransX((o), (f), (x), (y), 128)
/// Draw a graphic object unclipped.
#define VideoDrawTrans50(o, f, x, y) VideoDrawTrans((o), (f), (x), (y), 128)
/// Draw a graphic object unclipped and flipped in X direction.
#define VideoDrawXTrans50(o, f, x, y) VideoDrawTransX((o), (f), (x), (y), 128)
/// Draw a graphic object clipped to the current clipping.
#define VideoDrawClipTrans50(o, f, x, y) VideoDrawClipTrans((o), (f), (x), (y), 128)
/// Draw a graphic object clipped and flipped in X direction.
#define VideoDrawClipXTrans50(o, f, x, y) VideoDrawClipTransX((o), (f), (x), (y), 128)
/// Free a graphic object.
/// Free a graphic object.
extern void VideoFree(Graphic* o);
/// Safely (NULL) frees a graphic object.
/// Safely (NULL) frees a graphic object.
#define VideoSafeFree(o) do { if ((o)) { VideoFree((o)); } } while (0)
/// Get the width of a single frame of a graphic object
#define VideoGraphicWidth(o) ((o)->Width)
#define VideoGraphicWidth(o) ((o)->Width)
/// Get the height of a single frame of a graphic object
#define VideoGraphicHeight(o) ((o)->Height)
#define VideoGraphicFrames(o) ((o)->NumFrames)
#define VideoGraphicHeight(o) ((o)->Height)
#define VideoGraphicFrames(o) ((o)->NumFrames)
/// MACRO defines speed of colorcycling FIXME: should be made configurable
#define COLOR_CYCLE_SPEED (CYCLES_PER_SECOND/4)
#define COLOR_CYCLE_SPEED (CYCLES_PER_SECOND / 4)
//@}

View file

@ -126,9 +126,6 @@ global void LoadTileset(void)
strcat(strcpy(buf, "graphics/"), Tilesets[i]->ImageFile);
ShowLoadProgress("Tileset `%s'", Tilesets[i]->ImageFile);
TheMap.TileGraphic = LoadGraphic(buf);
#ifdef USE_OPENGL
MakeTexture(TheMap.TileGraphic, TheMap.TileGraphic->Width, TheMap.TileGraphic->Height);
#endif
TileSizeX = Tilesets[i]->TileSizeX;
TileSizeY = Tilesets[i]->TileSizeY;

View file

@ -188,9 +188,6 @@ global void MenusSetBackground(void)
if (!Menusbgnd) {
Menusbgnd = LoadGraphic(MenuBackground);
ResizeGraphic(Menusbgnd, VideoWidth, VideoHeight);
#ifdef USE_OPENGL
MakeTexture(Menusbgnd, Menusbgnd->Width, Menusbgnd->Height);
#endif
}
VideoDrawSubClip(Menusbgnd, 0, 0,

View file

@ -208,18 +208,10 @@ global void LoadUserInterface(void)
for (i = 0; i < TheUI.NumFillers; ++i) {
if (TheUI.Filler[i].File) {
TheUI.Filler[i].Graphic = LoadGraphic(TheUI.Filler[i].File);
#ifdef USE_OPENGL
MakeTexture(TheUI.Filler[i].Graphic, TheUI.Filler[i].Graphic->Width,
TheUI.Filler[i].Graphic->Height);
#endif
}
}
if (TheUI.Resource.File && *TheUI.Resource.File) {
TheUI.Resource.Graphic = LoadGraphic(TheUI.Resource.File);
#ifdef USE_OPENGL
MakeTexture(TheUI.Resource.Graphic, TheUI.Resource.Graphic->Width,
TheUI.Resource.Graphic->Height);
#endif
}
for (i = 0; i < MaxCosts; ++i) {
@ -227,76 +219,36 @@ global void LoadUserInterface(void)
if (TheUI.Resources[i].Icon.File) {
TheUI.Resources[i].Icon.Graphic =
LoadGraphic(TheUI.Resources[i].Icon.File);
#ifdef USE_OPENGL
MakeTexture(TheUI.Resources[i].Icon.Graphic,
TheUI.Resources[i].Icon.Graphic->Width,
TheUI.Resources[i].Icon.Graphic->Height);
#endif
}
}
// FIXME: reuse same graphics?
if (TheUI.Resources[FoodCost].Icon.File) {
TheUI.Resources[FoodCost].Icon.Graphic = LoadGraphic(TheUI.Resources[FoodCost].Icon.File);
#ifdef USE_OPENGL
MakeTexture(TheUI.Resources[FoodCost].Icon.Graphic,
TheUI.Resources[FoodCost].Icon.Graphic->Width,
TheUI.Resources[FoodCost].Icon.Graphic->Height);
#endif
}
// FIXME: reuse same graphics?
if (TheUI.Resources[ScoreCost].Icon.File) {
TheUI.Resources[ScoreCost].Icon.Graphic = LoadGraphic(TheUI.Resources[ScoreCost].Icon.File);
#ifdef USE_OPENGL
MakeTexture(TheUI.Resources[ScoreCost].Icon.Graphic,
TheUI.Resources[ScoreCost].Icon.Graphic->Width,
TheUI.Resources[ScoreCost].Icon.Graphic->Height);
#endif
}
if (TheUI.InfoPanel.File) {
TheUI.InfoPanel.Graphic = LoadGraphic(TheUI.InfoPanel.File);
#ifdef USE_OPENGL
MakeTexture(TheUI.InfoPanel.Graphic,
TheUI.InfoPanel.Graphic->Width,
TheUI.InfoPanel.Graphic->Height);
#endif
}
if (TheUI.ButtonPanel.File) {
TheUI.ButtonPanel.Graphic = LoadGraphic(TheUI.ButtonPanel.File);
#ifdef USE_OPENGL
MakeTexture(TheUI.ButtonPanel.Graphic,
TheUI.ButtonPanel.Graphic->Width,
TheUI.ButtonPanel.Graphic->Height);
#endif
}
if (TheUI.MenuPanel.File) {
TheUI.MenuPanel.Graphic = LoadGraphic(TheUI.MenuPanel.File);
#ifdef USE_OPENGL
MakeTexture(TheUI.MenuPanel.Graphic,
TheUI.MenuPanel.Graphic->Width,
TheUI.MenuPanel.Graphic->Height);
#endif
}
if (TheUI.MinimapPanel.File) {
TheUI.MinimapPanel.Graphic = LoadGraphic(TheUI.MinimapPanel.File);
#ifdef USE_OPENGL
MakeTexture(TheUI.MinimapPanel.Graphic,
TheUI.MinimapPanel.Graphic->Width,
TheUI.MinimapPanel.Graphic->Height);
#endif
}
if (TheUI.StatusLine.File) {
TheUI.StatusLine.Graphic = LoadGraphic(TheUI.StatusLine.File);
#ifdef USE_OPENGL
MakeTexture(TheUI.StatusLine.Graphic,
TheUI.StatusLine.Graphic->Width,
TheUI.StatusLine.Graphic->Height);
#endif
}
//
// Resolve cursors
// Resolve cursors
//
TheUI.Point.Cursor = CursorTypeByIdent(TheUI.Point.Name);
TheUI.Glass.Cursor = CursorTypeByIdent(TheUI.Glass.Name);
@ -319,11 +271,6 @@ global void LoadUserInterface(void)
while (menupanel) {
if (menupanel->Panel.File) {
menupanel->Panel.Graphic = LoadGraphic(menupanel->Panel.File);
#ifdef USE_OPENGL
MakeTexture(menupanel->Panel.Graphic,
menupanel->Panel.Graphic->Width,
menupanel->Panel.Graphic->Height);
#endif
}
menupanel = menupanel->Next;
}

View file

@ -41,8 +41,6 @@
#include "stratagus.h"
#include "video.h"
#include "map.h"
#include "iolib.h"
#include "iocompat.h"
#include "intern_video.h"
/*----------------------------------------------------------------------------
@ -317,27 +315,6 @@ global void FlipGraphic(Graphic* graphic)
#endif
}
/**
** Make a new graphic object.
**
** @param depth Pixel depth of the object (8,16,32)
** @param width Pixel width.
** @param height Pixel height.
*/
global Graphic* NewGraphic(unsigned depth, int width, int height)
{
void* data;
int size;
size = width * height * (depth + 7) / 8;
data = malloc(size);
#ifdef DEBUG
AllocatedGraphicMemory += size;
#endif
return MakeGraphic(depth, width, height, data, size);
}
/**
** Make an OpenGL texture or textures out of a graphic object.
**
@ -493,8 +470,7 @@ global void MakePlayerColorTexture(Graphic** g, Graphic* graphic, int frame,
SDL_UnlockSurface(graphic->Surface);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tex);
#ifdef DEBUG
i = glGetError();
if (i) {
if ((i = glGetError())) {
DebugLevel0Fn("glTexImage2D(%x)\n" _C_ i);
}
#endif
@ -555,6 +531,12 @@ global void ResizeGraphic(Graphic* g, int w, int h)
g->Height = h;
free(g->Data);
g->Data = data;
#ifdef USE_OPENGL
glDeleteTextures(g->NumTextureNames, g->TextureNames);
free(g->TextureNames);
MakeTexture(g, g->Width, g->Height);
#endif
}
/**
@ -566,19 +548,7 @@ global void ResizeGraphic(Graphic* g, int w, int h)
*/
global Graphic* LoadGraphic(const char* name)
{
Graphic* graphic;
char buf[PATH_MAX];
// TODO: More formats?
if (!(graphic = LoadGraphicPNG(LibraryFileName(name, buf)))) {
fprintf(stderr, "Can't load the graphic `%s'\n", name);
ExitFatal(-1);
}
graphic->NumFrames = 1;
VideoPaletteListAdd(graphic->Surface);
return graphic;
return LoadSprite(name, 0, 0);
}
/**

View file

@ -41,6 +41,8 @@
#include "stratagus.h"
#include "video.h"
#include "iocompat.h"
#include "iolib.h"
#include "intern_video.h"
@ -408,8 +410,14 @@ local void FreeSprite(Graphic* graphic)
global Graphic* LoadSprite(const char* name, int width, int height)
{
Graphic* g;
char buf[PATH_MAX];
g = LoadGraphic(name);
// TODO: More formats?
if (!(g = LoadGraphicPNG(LibraryFileName(name, buf)))) {
fprintf(stderr, "Can't load the graphic `%s'\n", name);
ExitFatal(-1);
}
VideoPaletteListAdd(g->Surface);
if (!width) {
width = g->Width;

View file

@ -395,9 +395,6 @@ global void DisplayPicture(const char* name)
picture = LoadGraphic(name);
ResizeGraphic(picture, VideoWidth, VideoHeight);
#ifdef USE_OPENGL
MakeTexture(picture, picture->Width, picture->Height);
#endif
#ifndef USE_OPENGL
// Unset the alpha color key, not needed
@ -411,34 +408,6 @@ global void DisplayPicture(const char* name)
VideoFree(picture);
}
// FIXME: this isn't 100% correct
// Color cycling info - forest:
// 3 flash red/green (attacked building on minimap)
// 38-47 cycle (water)
// 48-56 cycle (water-coast boundary)
// 202 pulsates red (Circle of Power)
// 240-244 cycle (water around ships, Runestone, Dark Portal)
// Color cycling info - swamp:
// 3 flash red/green (attacked building on minimap)
// 4 pulsates red (Circle of Power)
// 5-9 cycle (Runestone, Dark Portal)
// 38-47 cycle (water)
// 88-95 cycle (waterholes in coast and ground)
// 240-244 cycle (water around ships)
// Color cycling info - wasteland:
// 3 flash red/green (attacked building on minimap)
// 38-47 cycle (water)
// 64-70 cycle (coast)
// 202 pulsates red (Circle of Power)
// 240-244 cycle (water around ships, Runestone, Dark Portal)
// Color cycling info - winter:
// 3 flash red/green (attacked building on minimap)
// 40-47 cycle (water)
// 48-54 cycle (half-sunken ice-floe)
// 202 pulsates red (Circle of Power)
// 205-207 cycle (lights on christmas tree)
// 240-244 cycle (water around ships, Runestone, Dark Portal)
/**
** Color cycle.
*/