This commit is contained in:
parent
4b8f6991e9
commit
ffdd5e3d14
15 changed files with 406 additions and 80 deletions
|
@ -20,6 +20,8 @@
|
||||||
#include "LayerTile.h"
|
#include "LayerTile.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include "ExportAGB.h"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -33,7 +35,6 @@ CCore::CCore()
|
||||||
MapCam=Vec(0,0,0);
|
MapCam=Vec(0,0,0);
|
||||||
TileCam=Vec(0,0,0);
|
TileCam=Vec(0,0,0);
|
||||||
Is3dFlag=TRUE;
|
Is3dFlag=TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -516,4 +517,20 @@ void CCore::Toggle2d3d(CMapEditView *View)
|
||||||
{
|
{
|
||||||
Is3dFlag=!Is3dFlag;
|
Is3dFlag=!Is3dFlag;
|
||||||
UpdateView(View);
|
UpdateView(View);
|
||||||
|
|
||||||
|
Export();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CCore::Export()
|
||||||
|
{
|
||||||
|
int LayerCount=Layer.size();
|
||||||
|
CExportAGB Exp("c:/temp/test.c");
|
||||||
|
|
||||||
|
for (int i=0;i<LayerCount;i++)
|
||||||
|
{
|
||||||
|
Layer[i]->Export(Exp);
|
||||||
|
}
|
||||||
|
Exp.ExportAll(this);
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
const float FileVersion=1.0f;
|
const float FileVersion=1.0f;
|
||||||
|
|
||||||
|
//#define UseLighting
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
class CMapEditView;
|
class CMapEditView;
|
||||||
class CCore
|
class CCore
|
||||||
|
@ -37,6 +39,8 @@ public:
|
||||||
void Render(CMapEditView *View,BOOL ForceRender=FALSE);
|
void Render(CMapEditView *View,BOOL ForceRender=FALSE);
|
||||||
void RenderLayers(CMapEditView *View);
|
void RenderLayers(CMapEditView *View);
|
||||||
void RenderTileView(CMapEditView *View);
|
void RenderTileView(CMapEditView *View);
|
||||||
|
void Export();
|
||||||
|
|
||||||
|
|
||||||
// Control
|
// Control
|
||||||
void SetMode(int NewMode);
|
void SetMode(int NewMode);
|
||||||
|
@ -50,7 +54,7 @@ public:
|
||||||
void UpdateTileView(CMapEditView *View,BOOL Toggle=FALSE);
|
void UpdateTileView(CMapEditView *View,BOOL Toggle=FALSE);
|
||||||
|
|
||||||
CTileBank &GetTileBank() {return(TileBank);}
|
CTileBank &GetTileBank() {return(TileBank);}
|
||||||
CTile GetTile(int Bank,int TileNo) {return(TileBank.GetTile(Bank,TileNo));}
|
CTile &GetTile(int Bank,int TileNo) {return(TileBank.GetTile(Bank,TileNo));}
|
||||||
void TileBankLoad(char *Filename);
|
void TileBankLoad(char *Filename);
|
||||||
void TileBankReload();
|
void TileBankReload();
|
||||||
void TileBankSet();
|
void TileBankSet();
|
||||||
|
|
133
Utils/MapEdit/Export.cpp
Normal file
133
Utils/MapEdit/Export.cpp
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
/**************/
|
||||||
|
/*** Export ***/
|
||||||
|
/**************/
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include <Vector>
|
||||||
|
|
||||||
|
#include "Core.h"
|
||||||
|
#include "TileSet.h"
|
||||||
|
#include "Map.h"
|
||||||
|
|
||||||
|
#include "Export.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
CExport::CExport(char *Filename)
|
||||||
|
{
|
||||||
|
_splitpath(Filename,0,0,Name,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
CExport::~CExport()
|
||||||
|
{
|
||||||
|
fclose(File);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CExport::ExportAll(CCore *Core)
|
||||||
|
{
|
||||||
|
ExportTiles(Core);
|
||||||
|
|
||||||
|
}
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CExport::ExportTileMap(char *LayerName,CMap &Map)
|
||||||
|
{
|
||||||
|
int Width=Map.GetWidth();
|
||||||
|
int Height=Map.GetHeight();
|
||||||
|
|
||||||
|
ExportTileMapStart(LayerName,Width,Height);
|
||||||
|
for (int Y=0; Y<Height; Y++)
|
||||||
|
{
|
||||||
|
for (int X=0; X<Width; X++)
|
||||||
|
{
|
||||||
|
sMapElem &ThisElem=Map.Get(X,Y);
|
||||||
|
int Idx=AddTileToList(ThisElem);
|
||||||
|
ExportTileMap(ThisElem,Idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
ExportTileMapEnd(LayerName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CExport::PrintTileList()
|
||||||
|
{
|
||||||
|
int ListSize=UsedTileList.size();
|
||||||
|
|
||||||
|
for (int i=0; i<ListSize; i++)
|
||||||
|
{
|
||||||
|
// TRACE3("%02d: %i %i\n",i,UsedTileList[i].Set,UsedTileList[i].Tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
int CExport::FindTileInList(sMapElem &Tile)
|
||||||
|
{
|
||||||
|
int ListSize=UsedTileList.size();
|
||||||
|
|
||||||
|
for (int Idx=0; Idx<ListSize; Idx++)
|
||||||
|
{
|
||||||
|
sMapElem &ListTile=UsedTileList[Idx];
|
||||||
|
|
||||||
|
if (ListTile.Set==Tile.Set && ListTile.Tile==Tile.Tile) return(Idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
int CExport::AddTileToList(sMapElem &Tile)
|
||||||
|
{
|
||||||
|
int Idx=FindTileInList(Tile);
|
||||||
|
|
||||||
|
if (Idx==-1)
|
||||||
|
{ // New tile!!
|
||||||
|
Idx=UsedTileList.size();
|
||||||
|
UsedTileList.push_back(Tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(Idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CExport::ExportTiles(CCore *Core)
|
||||||
|
{
|
||||||
|
CTileBank &TileBank=Core->GetTileBank();
|
||||||
|
int ListSize=UsedTileList.size(),i;
|
||||||
|
|
||||||
|
PrintTileList();
|
||||||
|
for (i=0; i<ListSize; i++)
|
||||||
|
{
|
||||||
|
sMapElem &ThisElem=UsedTileList[i];
|
||||||
|
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
|
||||||
|
|
||||||
|
ParseTile(ThisTile);
|
||||||
|
}
|
||||||
|
CreateTilePalette();
|
||||||
|
ExportTileStart();
|
||||||
|
for (i=0; i<ListSize; i++)
|
||||||
|
{
|
||||||
|
sMapElem &ThisElem=UsedTileList[i];
|
||||||
|
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
|
||||||
|
|
||||||
|
ExportTile(ThisTile);
|
||||||
|
}
|
||||||
|
ExportTileEnd();
|
||||||
|
|
||||||
|
|
||||||
|
// Palette
|
||||||
|
ExportPaletteStart();
|
||||||
|
ExportPalette();
|
||||||
|
ExportPaletteEnd();
|
||||||
|
|
||||||
|
}
|
||||||
|
/*****************************************************************************/
|
62
Utils/MapEdit/Export.h
Normal file
62
Utils/MapEdit/Export.h
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/**************/
|
||||||
|
/*** Export ***/
|
||||||
|
/**************/
|
||||||
|
|
||||||
|
#ifndef __EXPORT_HEADER__
|
||||||
|
#define __EXPORT_HEADER__
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include <Vector>
|
||||||
|
|
||||||
|
#include "Quantize.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
class CCore;
|
||||||
|
class CMap;
|
||||||
|
class CTile;
|
||||||
|
|
||||||
|
class CExport
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CExport(char *Filename);
|
||||||
|
~CExport();
|
||||||
|
|
||||||
|
void ExportTileMap(char *LayerName,CMap &Map);
|
||||||
|
void ExportAll(CCore *Core);
|
||||||
|
|
||||||
|
void PrintTileList();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int FindTileInList(sMapElem &Tile);
|
||||||
|
int AddTileToList(sMapElem &Tile);
|
||||||
|
|
||||||
|
void ExportTiles(CCore *Core);
|
||||||
|
void ExportPalette(CCore *Core);
|
||||||
|
|
||||||
|
virtual void ExportTileMapStart(char *LayerName,int Width,int Height)=0;
|
||||||
|
virtual void ExportTileMap(sMapElem &Elem,int NewIdx)=0;
|
||||||
|
virtual void ExportTileMapEnd(char *LayerName)=0;
|
||||||
|
|
||||||
|
virtual void ExportTileStart()=0;
|
||||||
|
virtual void ParseTile(CTile &ThisTile)=0;
|
||||||
|
virtual void CreateTilePalette()=0;
|
||||||
|
virtual void ExportTile(CTile &ThisTile)=0;
|
||||||
|
virtual void ExportTileEnd()=0;
|
||||||
|
|
||||||
|
virtual void ExportPaletteStart()=0;
|
||||||
|
virtual void ExportPalette()=0;
|
||||||
|
virtual void ExportPaletteEnd()=0;
|
||||||
|
|
||||||
|
|
||||||
|
char Name[256];
|
||||||
|
FILE *File;
|
||||||
|
int Count;
|
||||||
|
std::vector<sMapElem> UsedTileList;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
#endif
|
|
@ -26,6 +26,7 @@ enum LAYER_TYPE
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
class CCore;
|
class CCore;
|
||||||
class CMapEditView;
|
class CMapEditView;
|
||||||
|
class CExport;
|
||||||
class CLayer
|
class CLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -57,6 +58,8 @@ virtual void Resize(int Width,int Height)=0;
|
||||||
virtual void Load(CFile *File,float Version)=0;
|
virtual void Load(CFile *File,float Version)=0;
|
||||||
virtual void Save(CFile *File)=0;
|
virtual void Save(CFile *File)=0;
|
||||||
|
|
||||||
|
virtual void Export(CExport &Exp)=0;
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
virtual BOOL SetMode(int NewMode)=0;
|
virtual BOOL SetMode(int NewMode)=0;
|
||||||
virtual BOOL InitMode()=0;
|
virtual BOOL InitMode()=0;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "LayerTile.h"
|
#include "LayerTile.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "Export.h"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -187,7 +188,9 @@ float OverVal=0.5;
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
|
#ifdef UseLighting
|
||||||
glNormal3f( 1,1,1);
|
glNormal3f( 1,1,1);
|
||||||
|
#endif
|
||||||
glColor3ub(255,255,255);
|
glColor3ub(255,255,255);
|
||||||
|
|
||||||
for (int YLoop=0; YLoop<Height+1; YLoop++)
|
for (int YLoop=0; YLoop<Height+1; YLoop++)
|
||||||
|
@ -484,3 +487,8 @@ BOOL CLayerTile::Paint(CMap &Blk,CPoint &CursorPos)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CLayerTile::Export(CExport &Exp)
|
||||||
|
{
|
||||||
|
Exp.ExportTileMap(Name,Map);
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
{
|
{
|
||||||
MouseFlagMirrorX=1<<0,
|
MouseFlagMirrorX=1<<0,
|
||||||
MouseFlagMirrorY=1<<1,
|
MouseFlagMirrorY=1<<1,
|
||||||
|
MouseFlagMirrorXY=MouseFlagMirrorX|MouseFlagMirrorY,
|
||||||
};
|
};
|
||||||
|
|
||||||
CLayerTile(char *_Name,int Width,int Height,float MapDiv,float ZDiv,BOOL Is3d,BOOL Resizable); // New Layer
|
CLayerTile(char *_Name,int Width,int Height,float MapDiv,float ZDiv,BOOL Is3d,BOOL Resizable); // New Layer
|
||||||
|
@ -57,6 +58,8 @@ public:
|
||||||
void Load(CFile *File,float Version);
|
void Load(CFile *File,float Version);
|
||||||
void Save(CFile *File);
|
void Save(CFile *File);
|
||||||
|
|
||||||
|
void Export(CExport &Exp);
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
BOOL SetMode(int NewMode);
|
BOOL SetMode(int NewMode);
|
||||||
BOOL InitMode();
|
BOOL InitMode();
|
||||||
|
|
|
@ -24,7 +24,7 @@ Resource3=IDD_GFXTOOLBAR
|
||||||
Resource4=IDD_DIALOGBAR (English (U.S.))
|
Resource4=IDD_DIALOGBAR (English (U.S.))
|
||||||
Resource5=IDR_MAPEDITYPE (English (U.S.))
|
Resource5=IDR_MAPEDITYPE (English (U.S.))
|
||||||
Class8=CMultiBar
|
Class8=CMultiBar
|
||||||
Resource6=IDR_TOOLBAR (English (U.S.))
|
Resource6=IDD_MAPSIZE
|
||||||
Resource7=IDD_TILESET_DIALOG
|
Resource7=IDD_TILESET_DIALOG
|
||||||
Class9=CLayerList
|
Class9=CLayerList
|
||||||
Class10=CTileSetDlg
|
Class10=CTileSetDlg
|
||||||
|
@ -32,7 +32,7 @@ Resource8=IDR_MAINFRAME (English (U.S.))
|
||||||
Class11=CGfxToolBar
|
Class11=CGfxToolBar
|
||||||
Resource9=IDD_LAYER_LIST_DIALOG
|
Resource9=IDD_LAYER_LIST_DIALOG
|
||||||
Class12=CMapSizeDlg
|
Class12=CMapSizeDlg
|
||||||
Resource10=IDD_MAPSIZE
|
Resource10=IDR_TOOLBAR (English (U.S.))
|
||||||
|
|
||||||
[CLS:CChildFrame]
|
[CLS:CChildFrame]
|
||||||
Type=0
|
Type=0
|
||||||
|
@ -79,7 +79,7 @@ Type=0
|
||||||
BaseClass=CGLEnabledView
|
BaseClass=CGLEnabledView
|
||||||
HeaderFile=MapEditView.h
|
HeaderFile=MapEditView.h
|
||||||
ImplementationFile=MapEditView.cpp
|
ImplementationFile=MapEditView.cpp
|
||||||
LastObject=ID_2D_3D_TOGGLE
|
LastObject=CMapEditView
|
||||||
Filter=C
|
Filter=C
|
||||||
VirtualFilter=VWC
|
VirtualFilter=VWC
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,55 @@ SOURCE=.\LayerTile.cpp
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\LayerTile.h
|
SOURCE=.\LayerTile.h
|
||||||
|
# End Source File
|
||||||
|
# End Group
|
||||||
|
# Begin Group "Export"
|
||||||
|
|
||||||
|
# PROP Default_Filter ""
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\Export.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\Export.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ExportAGB.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\ExportAGB.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\Quantize.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\Quantize.h
|
||||||
|
# End Source File
|
||||||
|
# End Group
|
||||||
|
# Begin Group "TestLevels"
|
||||||
|
|
||||||
|
# PROP Default_Filter ""
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\agbtypes.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\temp\test.c
|
||||||
|
|
||||||
|
!IF "$(CFG)" == "MapEdit - Win32 Release"
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "MapEdit - Win32 Debug"
|
||||||
|
|
||||||
|
# PROP Exclude_From_Build 1
|
||||||
|
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
# End Source File
|
# End Source File
|
||||||
# End Group
|
# End Group
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
|
@ -76,9 +76,11 @@ void CMapEditView::OnCreateGL()
|
||||||
glClearDepth(1.0f); // Depth Buffer Setup
|
glClearDepth(1.0f); // Depth Buffer Setup
|
||||||
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
|
||||||
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
|
||||||
|
#ifdef UseLighting
|
||||||
glEnable(GL_LIGHT0); // Quick And Dirty Lighting (Assumes Light0 Is SetUp)
|
glEnable(GL_LIGHT0); // Quick And Dirty Lighting (Assumes Light0 Is SetUp)
|
||||||
glEnable(GL_LIGHTING); // Enable Lighting
|
glEnable(GL_LIGHTING); // Enable Lighting
|
||||||
glEnable(GL_COLOR_MATERIAL); // Enable Material Coloring
|
glEnable(GL_COLOR_MATERIAL); // Enable Material Coloring
|
||||||
|
#endif
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
|
||||||
// glDisable(GL_BLEND); // Enable Alpha Channel
|
// glDisable(GL_BLEND); // Enable Alpha Channel
|
||||||
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
|
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
|
||||||
|
|
|
@ -91,7 +91,7 @@ AUX_RGBImageRec *Aux;
|
||||||
Aux=auxDIBImageLoad(Filename);
|
Aux=auxDIBImageLoad(Filename);
|
||||||
RGBData.Width=Aux->sizeX;
|
RGBData.Width=Aux->sizeX;
|
||||||
RGBData.Height=Aux->sizeY;
|
RGBData.Height=Aux->sizeY;
|
||||||
RGBData.RGB=(char*)Aux->data;
|
RGBData.RGB=Aux->data;
|
||||||
free(Aux); // Safe to free aux now, contents copied (I HATE AUX)
|
free(Aux); // Safe to free aux now, contents copied (I HATE AUX)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,13 @@
|
||||||
#include <gl\glu.h>
|
#include <gl\glu.h>
|
||||||
#include <gl\glut.h>
|
#include <gl\glut.h>
|
||||||
#include <Vector>
|
#include <Vector>
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
struct sRGBData
|
struct sRGBData
|
||||||
{
|
{
|
||||||
int Width;
|
int Width;
|
||||||
int Height;
|
int Height;
|
||||||
char *RGB;
|
u8 *RGB;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sTex
|
struct sTex
|
||||||
|
|
|
@ -44,7 +44,7 @@ CTileBank::CTileBank()
|
||||||
SelStart=-1;
|
SelStart=-1;
|
||||||
SelEnd=1;
|
SelEnd=1;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUGx
|
||||||
AddTileSet("c:/temp/rockp/rockp.gin");
|
AddTileSet("c:/temp/rockp/rockp.gin");
|
||||||
// AddTileSet("c:/temp/3/test.gin");
|
// AddTileSet("c:/temp/3/test.gin");
|
||||||
|
|
||||||
|
@ -397,7 +397,9 @@ int SelFlag;
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
#ifdef UseLighting
|
||||||
glNormal3f( 1,1,1);
|
glNormal3f( 1,1,1);
|
||||||
|
#endif
|
||||||
switch(SelFlag)
|
switch(SelFlag)
|
||||||
{
|
{
|
||||||
case 1: // L
|
case 1: // L
|
||||||
|
@ -463,8 +465,9 @@ int MaxTile=Tile.size();
|
||||||
glTranslatef(CamPos.x+X*(1+TileBrowserGap),CamPos.y-Y*(1+TileBrowserGap),CamPos.z);
|
glTranslatef(CamPos.x+X*(1+TileBrowserGap),CamPos.y-Y*(1+TileBrowserGap),CamPos.z);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
#ifdef UseLighting
|
||||||
glNormal3f( 1,1,1);
|
glNormal3f( 1,1,1);
|
||||||
|
#endif
|
||||||
glColor4f(1,1,0,0.5);
|
glColor4f(1,1,0,0.5);
|
||||||
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0);
|
BuildGLQuad(TileBrowserX0,TileBrowserX1,TileBrowserY0,TileBrowserY1,0);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
@ -494,7 +497,9 @@ int TileID=0;
|
||||||
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
glTranslatef(CamPos.x+Pos.x*(1+TileBrowserGap),CamPos.y-Pos.y*(1+TileBrowserGap),CamPos.z);
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
|
#ifdef UseLighting
|
||||||
glNormal3f( 1,1,1);
|
glNormal3f( 1,1,1);
|
||||||
|
#endif
|
||||||
glColor3ub(255,255,255);
|
glColor3ub(255,255,255);
|
||||||
|
|
||||||
glVertex3f( TileBrowserX0,TileBrowserY0,0);
|
glVertex3f( TileBrowserX0,TileBrowserY0,0);
|
||||||
|
|
|
@ -33,37 +33,49 @@ char szBuf[256];
|
||||||
void BuildGLBox(float XMin,float XMax,float YMin,float YMax,float ZMin,float ZMax)
|
void BuildGLBox(float XMin,float XMax,float YMin,float YMax,float ZMin,float ZMax)
|
||||||
{
|
{
|
||||||
// Bottom Face
|
// Bottom Face
|
||||||
|
#ifdef UseLighting
|
||||||
glNormal3f( 0.0f,-1.0f, 0.0f);
|
glNormal3f( 0.0f,-1.0f, 0.0f);
|
||||||
|
#endif
|
||||||
glVertex3f( XMin, YMin, ZMin);
|
glVertex3f( XMin, YMin, ZMin);
|
||||||
glVertex3f( XMax, YMin, ZMin);
|
glVertex3f( XMax, YMin, ZMin);
|
||||||
glVertex3f( XMax, YMin, ZMax);
|
glVertex3f( XMax, YMin, ZMax);
|
||||||
glVertex3f( XMin, YMin, ZMax);
|
glVertex3f( XMin, YMin, ZMax);
|
||||||
// Front Face
|
// Front Face
|
||||||
|
#ifdef UseLighting
|
||||||
glNormal3f( 0.0f, 0.0f, 1.0f);
|
glNormal3f( 0.0f, 0.0f, 1.0f);
|
||||||
|
#endif
|
||||||
glVertex3f( XMin, YMin, ZMax);
|
glVertex3f( XMin, YMin, ZMax);
|
||||||
glVertex3f( XMax, YMin, ZMax);
|
glVertex3f( XMax, YMin, ZMax);
|
||||||
glVertex3f( XMax, YMax, ZMax);
|
glVertex3f( XMax, YMax, ZMax);
|
||||||
glVertex3f( XMin, YMax, ZMax);
|
glVertex3f( XMin, YMax, ZMax);
|
||||||
// Back Face
|
// Back Face
|
||||||
|
#ifdef UseLighting
|
||||||
glNormal3f( 0.0f, 0.0f,-1.0f);
|
glNormal3f( 0.0f, 0.0f,-1.0f);
|
||||||
|
#endif
|
||||||
glVertex3f( XMin, YMin, ZMin);
|
glVertex3f( XMin, YMin, ZMin);
|
||||||
glVertex3f( XMin, YMax, ZMin);
|
glVertex3f( XMin, YMax, ZMin);
|
||||||
glVertex3f( XMax, YMax, ZMin);
|
glVertex3f( XMax, YMax, ZMin);
|
||||||
glVertex3f( XMax, YMin, ZMin);
|
glVertex3f( XMax, YMin, ZMin);
|
||||||
// Right face
|
// Right face
|
||||||
|
#ifdef UseLighting
|
||||||
glNormal3f( 1.0f, 0.0f, 0.0f);
|
glNormal3f( 1.0f, 0.0f, 0.0f);
|
||||||
|
#endif
|
||||||
glVertex3f( XMax, YMin, ZMin);
|
glVertex3f( XMax, YMin, ZMin);
|
||||||
glVertex3f( XMax, YMax, ZMin);
|
glVertex3f( XMax, YMax, ZMin);
|
||||||
glVertex3f( XMax, YMax, ZMax);
|
glVertex3f( XMax, YMax, ZMax);
|
||||||
glVertex3f( XMax, YMin, ZMax);
|
glVertex3f( XMax, YMin, ZMax);
|
||||||
// Left Face
|
// Left Face
|
||||||
|
#ifdef UseLighting
|
||||||
glNormal3f(-1.0f, 0.0f, 0.0f);
|
glNormal3f(-1.0f, 0.0f, 0.0f);
|
||||||
|
#endif
|
||||||
glVertex3f( XMin, YMin, ZMin);
|
glVertex3f( XMin, YMin, ZMin);
|
||||||
glVertex3f( XMin, YMin, ZMax);
|
glVertex3f( XMin, YMin, ZMax);
|
||||||
glVertex3f( XMin, YMax, ZMax);
|
glVertex3f( XMin, YMax, ZMax);
|
||||||
glVertex3f( XMin, YMax, ZMin);
|
glVertex3f( XMin, YMax, ZMin);
|
||||||
// Top Face
|
// Top Face
|
||||||
|
#ifdef UseLighting
|
||||||
glNormal3f( 0.0f, 1.0f, 0.0f);
|
glNormal3f( 0.0f, 1.0f, 0.0f);
|
||||||
|
#endif
|
||||||
glVertex3f( XMin, YMax, ZMin);
|
glVertex3f( XMin, YMax, ZMin);
|
||||||
glVertex3f( XMin, YMax, ZMax);
|
glVertex3f( XMin, YMax, ZMax);
|
||||||
glVertex3f( XMax, YMax, ZMax);
|
glVertex3f( XMax, YMax, ZMax);
|
||||||
|
@ -109,7 +121,9 @@ void BuildGLBoxNoNormals(float XMin,float XMax,float YMin,float YMax,float ZMin,
|
||||||
void BuildGLQuad(float XMin,float XMax,float YMin,float YMax,float Z)
|
void BuildGLQuad(float XMin,float XMax,float YMin,float YMax,float Z)
|
||||||
{
|
{
|
||||||
// Front Face
|
// Front Face
|
||||||
|
#ifdef UseLighting
|
||||||
glNormal3f( 0.0f, 0.0f, 1.0f);
|
glNormal3f( 0.0f, 0.0f, 1.0f);
|
||||||
|
#endif
|
||||||
glVertex3f( XMin, YMin, Z);
|
glVertex3f( XMin, YMin, Z);
|
||||||
glVertex3f( XMax, YMin, Z);
|
glVertex3f( XMax, YMin, Z);
|
||||||
glVertex3f( XMax, YMax, Z);
|
glVertex3f( XMax, YMax, Z);
|
||||||
|
@ -176,67 +190,6 @@ int ID;
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
#if 0
|
|
||||||
AUX_RGBImageRec *LoadBMP(char *Filename)
|
|
||||||
{
|
|
||||||
FILE *File=NULL;
|
|
||||||
|
|
||||||
File=fopen(Filename,"r");
|
|
||||||
|
|
||||||
if (File)
|
|
||||||
{
|
|
||||||
fclose(File);
|
|
||||||
return auxDIBImageLoad(Filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
|
||||||
void FreeBMP(AUX_RGBImageRec *TextureImage)
|
|
||||||
{
|
|
||||||
if (TextureImage) // If Texture Exists
|
|
||||||
{
|
|
||||||
if (TextureImage->data) // If Texture Image Exists
|
|
||||||
{
|
|
||||||
free(TextureImage->data); // Free The Texture Image Memory
|
|
||||||
}
|
|
||||||
|
|
||||||
free(TextureImage); // Free The Image Structure
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
|
||||||
int LoadGLTexture(char *FileName, GLuint &Text,int &Width,int &Height)
|
|
||||||
{
|
|
||||||
AUX_RGBImageRec *TextureImage;
|
|
||||||
int Status=FALSE;
|
|
||||||
|
|
||||||
memset(&TextureImage,0,sizeof(void *)*1); // Init Buffer
|
|
||||||
|
|
||||||
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
|
|
||||||
if (TextureImage=LoadBMP(FileName))
|
|
||||||
{
|
|
||||||
Width=TextureImage->sizeX;
|
|
||||||
Height=TextureImage->sizeY;
|
|
||||||
Status=TRUE; // Set The Status To TRUE
|
|
||||||
|
|
||||||
glGenTextures(1, &Text); // Create The Texture
|
|
||||||
|
|
||||||
// Typical Texture Generation Using Data From The Bitmap
|
|
||||||
glBindTexture(GL_TEXTURE_2D, Text);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage->sizeX, TextureImage->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage->data);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
FreeBMP(TextureImage);
|
|
||||||
|
|
||||||
return Status; // Return The Status
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
struct sTgaHdr
|
struct sTgaHdr
|
||||||
|
@ -257,7 +210,7 @@ struct sTgaHdr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SaveTGA(char *Filename,int W,int H,char *Data)
|
void SaveTGA(char *Filename,int W,int H,u8 *Data)
|
||||||
{
|
{
|
||||||
FILE *File;
|
FILE *File;
|
||||||
sTgaHdr FileHdr;
|
sTgaHdr FileHdr;
|
||||||
|
@ -281,13 +234,13 @@ sTgaHdr FileHdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
void BGR2RGB(int W,int H,char *Data)
|
void BGR2RGB(int W,int H,u8 *Data)
|
||||||
{
|
{
|
||||||
for (int Y=0; Y<H; Y++)
|
for (int Y=0; Y<H; Y++)
|
||||||
{
|
{
|
||||||
for (int X=0; X<W; X++)
|
for (int X=0; X<W; X++)
|
||||||
{
|
{
|
||||||
unsigned char c0,c1;
|
u8 c0,c1;
|
||||||
c0=Data[0];
|
c0=Data[0];
|
||||||
c1=Data[2];
|
c1=Data[2];
|
||||||
Data[0]=c1;
|
Data[0]=c1;
|
||||||
|
@ -296,3 +249,67 @@ void BGR2RGB(int W,int H,char *Data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
void SaveBmp(char *Filename,int Width,int Height,RGBQUAD *Pal,u8 *Image)
|
||||||
|
{
|
||||||
|
FILE *File;
|
||||||
|
BITMAPFILEHEADER FileHdr;
|
||||||
|
BITMAPINFOHEADER ImageHdr;
|
||||||
|
int PaletteSize,ImageSize;
|
||||||
|
|
||||||
|
File=fopen(Filename,"wb");
|
||||||
|
|
||||||
|
if (!Pal)
|
||||||
|
{
|
||||||
|
PaletteSize=0;
|
||||||
|
ImageSize=Width*Height*3;
|
||||||
|
ImageHdr.biBitCount=24;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PaletteSize=256*sizeof(RGBQUAD);
|
||||||
|
ImageSize=Width*Height;
|
||||||
|
ImageHdr.biBitCount=8;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
FileHdr.bfType=19778;
|
||||||
|
FileHdr.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+PaletteSize+ImageSize;
|
||||||
|
FileHdr.bfReserved1=0;
|
||||||
|
FileHdr.bfReserved2=0;
|
||||||
|
FileHdr.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+PaletteSize;
|
||||||
|
|
||||||
|
ImageHdr.biSize=sizeof(BITMAPINFOHEADER);
|
||||||
|
ImageHdr.biWidth=Width;
|
||||||
|
ImageHdr.biHeight=Height;
|
||||||
|
ImageHdr.biPlanes=1;
|
||||||
|
// Set Above ImageHdr.biBitCount=8; // 24
|
||||||
|
ImageHdr.biCompression=BI_RGB;
|
||||||
|
ImageHdr.biSizeImage=0;
|
||||||
|
ImageHdr.biXPelsPerMeter=0;
|
||||||
|
ImageHdr.biYPelsPerMeter=0;
|
||||||
|
ImageHdr.biClrUsed=0;
|
||||||
|
ImageHdr.biClrImportant=0;
|
||||||
|
|
||||||
|
fwrite(&FileHdr,sizeof(BITMAPFILEHEADER),1,File);
|
||||||
|
fwrite(&ImageHdr,sizeof(BITMAPINFOHEADER),1,File);
|
||||||
|
|
||||||
|
if (Pal) fwrite(Pal,sizeof(RGBQUAD),256,File);
|
||||||
|
|
||||||
|
fwrite(Image,ImageSize,1,File);
|
||||||
|
/*
|
||||||
|
for (int Y=0;Y<Height;Y++)
|
||||||
|
{
|
||||||
|
for (int X=0;X<Width;X++)
|
||||||
|
{
|
||||||
|
TRACE1("%02d ",*Image++);
|
||||||
|
|
||||||
|
}
|
||||||
|
TRACE0("\n");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
fclose(File);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -6,11 +6,31 @@
|
||||||
#define __UTILS_HEADER__
|
#define __UTILS_HEADER__
|
||||||
|
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
//#include <gl\gl.h>
|
#include <gl\gl.h>
|
||||||
//#include <gl\glu.h>
|
#include <gl\glu.h>
|
||||||
//#include <gl\glut.h>
|
#include <gl\glut.h>
|
||||||
//#include <gl\glaux.h> // Header File For The Glaux Library
|
#include <gl\glaux.h> // Header File For The Glaux Library
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
typedef signed char s8;
|
||||||
|
typedef signed short s16;
|
||||||
|
typedef signed long s32;
|
||||||
|
//typedef long long s64;
|
||||||
|
|
||||||
|
typedef unsigned char u8;
|
||||||
|
typedef unsigned short u16;
|
||||||
|
typedef unsigned long u32;
|
||||||
|
//typedef unsigned long long u64;
|
||||||
|
|
||||||
|
typedef s8 S8;
|
||||||
|
typedef s16 S16;
|
||||||
|
typedef s32 S32;
|
||||||
|
//typedef s64 S64;
|
||||||
|
|
||||||
|
typedef u8 U8;
|
||||||
|
typedef u16 U16;
|
||||||
|
typedef u32 U32;
|
||||||
|
//typedef u64 U64;
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
void DbgMsg(const char * pszFmt,...);
|
void DbgMsg(const char * pszFmt,...);
|
||||||
|
@ -31,8 +51,10 @@ int PointToID(CPoint &Pnt,int Width);
|
||||||
|
|
||||||
|
|
||||||
//void SaveTGA(char *Filename,int SX,int SY,int SW,int SH);
|
//void SaveTGA(char *Filename,int SX,int SY,int SW,int SH);
|
||||||
void SaveTGA(char *Filename,int W,int H,char *Data);
|
void SaveTGA(char *Filename,int W,int H,u8 *Data);
|
||||||
void BGR2RGB(int W,int H,char *Data);
|
void SaveBmp(char *Filename,int Width,int Height,RGBQUAD *Pal,u8 *Image);
|
||||||
|
|
||||||
|
void BGR2RGB(int W,int H,u8 *Data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue