This commit is contained in:
parent
90d4097793
commit
7123b53ece
17 changed files with 294 additions and 177 deletions
|
@ -510,3 +510,10 @@ int ListSize=Layer.size();
|
||||||
|
|
||||||
UpdateView(View);
|
UpdateView(View);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CCore::Toggle2d3d(CMapEditView *View)
|
||||||
|
{
|
||||||
|
Is3dFlag=!Is3dFlag;
|
||||||
|
UpdateView(View);
|
||||||
|
}
|
||||||
|
|
|
@ -87,6 +87,9 @@ public:
|
||||||
int GetMapWidth() {return(Layer[LAYER_ACTION]->GetWidth());}
|
int GetMapWidth() {return(Layer[LAYER_ACTION]->GetWidth());}
|
||||||
int GetMapHeight() {return(Layer[LAYER_ACTION]->GetHeight());}
|
int GetMapHeight() {return(Layer[LAYER_ACTION]->GetHeight());}
|
||||||
|
|
||||||
|
void Toggle2d3d(CMapEditView *View);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CPoint CurrentMousePos,LastMousePos;
|
CPoint CurrentMousePos,LastMousePos;
|
||||||
CPoint CursorPos,LastCursorPos;
|
CPoint CursorPos,LastCursorPos;
|
||||||
|
|
|
@ -98,12 +98,12 @@ Vec ThisCam=CamPos/XYDiv;
|
||||||
if (Is3d && Render3dFlag)
|
if (Is3d && Render3dFlag)
|
||||||
{
|
{
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
Render3d(Core,ThisCam,Map);
|
Render(Core,ThisCam,Map,TRUE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Render2d(Core,ThisCam,Map);
|
Render(Core,ThisCam,Map,FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,57 +124,17 @@ CMap &Brush=TileBank.GetActiveBrush();
|
||||||
if (Is3d && Render3dFlag)
|
if (Is3d && Render3dFlag)
|
||||||
{
|
{
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
Render3d(Core,ThisCam,Brush,0.5);
|
Render(Core,ThisCam,Brush,TRUE,0.5);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Render2d(Core,ThisCam,Brush,0.5);
|
Render(Core,ThisCam,Brush,FALSE,0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CLayerTile::Render2d(CCore *Core,Vec &CamPos,CMap &ThisMap,float Alpha)
|
void CLayerTile::Render(CCore *Core,Vec &CamPos,CMap &ThisMap,BOOL Render3d,float Alpha)
|
||||||
{
|
|
||||||
return;
|
|
||||||
int Width=ThisMap.GetWidth();
|
|
||||||
int Height=ThisMap.GetHeight();
|
|
||||||
|
|
||||||
if (Alpha<1)
|
|
||||||
{
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Alpha Blend Style
|
|
||||||
glColor4f(0.5,0.5,0.5,Alpha);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
glColor3f(0.5,0.5,0.5);
|
|
||||||
}
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
|
|
||||||
for (int YLoop=0; YLoop<Height; YLoop++)
|
|
||||||
{
|
|
||||||
for (int XLoop=0; XLoop<Width; XLoop++)
|
|
||||||
{
|
|
||||||
sMapElem &ThisElem=ThisMap.Get(XLoop,YLoop);
|
|
||||||
CTile &ThisTile=Core->GetTile(ThisElem.Set,ThisElem.Tile);
|
|
||||||
|
|
||||||
glLoadIdentity(); // Slow way, but good to go for the mo
|
|
||||||
glTranslatef(CamPos.x+XLoop,CamPos.y-YLoop,CamPos.z);
|
|
||||||
// ThisTile.Render();
|
|
||||||
int c=(XLoop+YLoop)&1;
|
|
||||||
glColor3f(c,1,1);
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
BuildGLQuad(0,1,0,1,0);
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CLayerTile::Render3d(CCore *Core,Vec &CamPos,CMap &ThisMap,float Alpha)
|
|
||||||
{
|
{
|
||||||
int Width=ThisMap.GetWidth();
|
int Width=ThisMap.GetWidth();
|
||||||
int Height=ThisMap.GetHeight();
|
int Height=ThisMap.GetHeight();
|
||||||
|
@ -203,7 +163,7 @@ int Height=ThisMap.GetHeight();
|
||||||
|
|
||||||
glLoadIdentity(); // Slow way, but good to go for the mo
|
glLoadIdentity(); // Slow way, but good to go for the mo
|
||||||
glTranslatef(CamPos.x+XLoop,CamPos.y-YLoop,CamPos.z);
|
glTranslatef(CamPos.x+XLoop,CamPos.y-YLoop,CamPos.z);
|
||||||
ThisTile.Render(ThisElem.Flags);
|
ThisTile.Render(ThisElem.Flags,Render3d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,7 @@ public:
|
||||||
BOOL MirrorY(CCore *Core);
|
BOOL MirrorY(CCore *Core);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Render2d(CCore *Core,Vec &CamPos,CMap &ThisMap,float Alpha=1.0f);
|
void Render(CCore *Core,Vec &CamPos,CMap &ThisMap,BOOL Render3d,float Alpha=1.0f);
|
||||||
void Render3d(CCore *Core,Vec &CamPos,CMap &ThisMap,float Alpha=1.0f);
|
|
||||||
void RenderCursorPaint(CCore *Core,Vec &CamPos,BOOL Is3d);
|
void RenderCursorPaint(CCore *Core,Vec &CamPos,BOOL Is3d);
|
||||||
|
|
||||||
BOOL Paint(CMap &Blk,CPoint &CursorPos);
|
BOOL Paint(CMap &Blk,CPoint &CursorPos);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[General Info]
|
[General Info]
|
||||||
Version=1
|
Version=1
|
||||||
LastClass=CLayerList
|
LastClass=CMapEditView
|
||||||
LastTemplate=CDialog
|
LastTemplate=CDialog
|
||||||
NewFileInclude1=#include "stdafx.h"
|
NewFileInclude1=#include "stdafx.h"
|
||||||
NewFileInclude2=#include "mapedit.h"
|
NewFileInclude2=#include "mapedit.h"
|
||||||
|
@ -18,19 +18,19 @@ Class6=CMapEditDoc
|
||||||
Class7=CMapEditView
|
Class7=CMapEditView
|
||||||
|
|
||||||
ResourceCount=10
|
ResourceCount=10
|
||||||
Resource1=IDD_MULTIBAR (English (U.S.))
|
Resource1=IDD_ABOUTBOX (English (U.S.))
|
||||||
Resource2=IDD_LAYER_LIST_DIALOG
|
Resource2=IDD_MULTIBAR (English (U.S.))
|
||||||
Resource3=IDD_GFXTOOLBAR
|
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_MAINFRAME (English (U.S.))
|
Resource6=IDR_TOOLBAR (English (U.S.))
|
||||||
Resource7=IDR_TOOLBAR (English (U.S.))
|
Resource7=IDD_TILESET_DIALOG
|
||||||
Class9=CLayerList
|
Class9=CLayerList
|
||||||
Class10=CTileSetDlg
|
Class10=CTileSetDlg
|
||||||
Resource8=IDD_ABOUTBOX (English (U.S.))
|
Resource8=IDR_MAINFRAME (English (U.S.))
|
||||||
Class11=CGfxToolBar
|
Class11=CGfxToolBar
|
||||||
Resource9=IDD_TILESET_DIALOG
|
Resource9=IDD_LAYER_LIST_DIALOG
|
||||||
Class12=CMapSizeDlg
|
Class12=CMapSizeDlg
|
||||||
Resource10=IDD_MAPSIZE
|
Resource10=IDD_MAPSIZE
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ Type=0
|
||||||
BaseClass=CGLEnabledView
|
BaseClass=CGLEnabledView
|
||||||
HeaderFile=MapEditView.h
|
HeaderFile=MapEditView.h
|
||||||
ImplementationFile=MapEditView.cpp
|
ImplementationFile=MapEditView.cpp
|
||||||
LastObject=CMapEditView
|
LastObject=ID_2D_3D_TOGGLE
|
||||||
Filter=C
|
Filter=C
|
||||||
VirtualFilter=VWC
|
VirtualFilter=VWC
|
||||||
|
|
||||||
|
@ -135,36 +135,38 @@ Command17=ID_MIRRORY
|
||||||
Command18=ID_ACTIVEBRUSH_LEFT
|
Command18=ID_ACTIVEBRUSH_LEFT
|
||||||
Command19=ID_ACTIVEBRUSH_RIGHT
|
Command19=ID_ACTIVEBRUSH_RIGHT
|
||||||
Command20=ID_TOGGLE_TILEVIEW
|
Command20=ID_TOGGLE_TILEVIEW
|
||||||
Command21=ID_WINDOW_NEW
|
Command21=ID_2D_3D_TOGGLE
|
||||||
Command22=ID_WINDOW_CASCADE
|
Command22=ID_WINDOW_NEW
|
||||||
Command23=ID_WINDOW_TILE_HORZ
|
Command23=ID_WINDOW_CASCADE
|
||||||
Command24=ID_WINDOW_ARRANGE
|
Command24=ID_WINDOW_TILE_HORZ
|
||||||
Command25=ID_APP_ABOUT
|
Command25=ID_WINDOW_ARRANGE
|
||||||
CommandCount=25
|
Command26=ID_APP_ABOUT
|
||||||
|
CommandCount=26
|
||||||
|
|
||||||
[ACL:IDR_MAINFRAME (English (U.S.))]
|
[ACL:IDR_MAINFRAME (English (U.S.))]
|
||||||
Type=1
|
Type=1
|
||||||
Class=?
|
Class=?
|
||||||
Command1=ID_ACTIVEBRUSH_LEFT
|
Command1=ID_ACTIVEBRUSH_LEFT
|
||||||
Command2=ID_ACTIVEBRUSH_RIGHT
|
Command2=ID_ACTIVEBRUSH_RIGHT
|
||||||
Command3=ID_EDIT_COPY
|
Command3=ID_2D_3D_TOGGLE
|
||||||
Command4=ID_TOGGLE_GRID
|
Command4=ID_EDIT_COPY
|
||||||
Command5=ID_FILE_NEW
|
Command5=ID_TOGGLE_GRID
|
||||||
Command6=ID_FILE_OPEN
|
Command6=ID_FILE_NEW
|
||||||
Command7=ID_FILE_SAVE
|
Command7=ID_FILE_OPEN
|
||||||
Command8=ID_EDIT_PASTE
|
Command8=ID_FILE_SAVE
|
||||||
Command9=ID_EDIT_UNDO
|
Command9=ID_EDIT_PASTE
|
||||||
Command10=ID_EDIT_CUT
|
Command10=ID_EDIT_UNDO
|
||||||
Command11=ID_EDIT_COPY
|
Command11=ID_EDIT_CUT
|
||||||
Command12=ID_EDIT_PASTE
|
Command12=ID_EDIT_COPY
|
||||||
Command13=ID_TOGGLE_TILEVIEW
|
Command13=ID_EDIT_PASTE
|
||||||
Command14=ID_NEXT_PANE
|
Command14=ID_TOGGLE_TILEVIEW
|
||||||
Command15=ID_PREV_PANE
|
Command15=ID_NEXT_PANE
|
||||||
Command16=ID_MIRRORX
|
Command16=ID_PREV_PANE
|
||||||
Command17=ID_EDIT_CUT
|
Command17=ID_MIRRORX
|
||||||
Command18=ID_MIRRORY
|
Command18=ID_EDIT_CUT
|
||||||
Command19=ID_EDIT_UNDO
|
Command19=ID_MIRRORY
|
||||||
CommandCount=19
|
Command20=ID_EDIT_UNDO
|
||||||
|
CommandCount=20
|
||||||
|
|
||||||
[DLG:IDD_ABOUTBOX (English (U.S.))]
|
[DLG:IDD_ABOUTBOX (English (U.S.))]
|
||||||
Type=1
|
Type=1
|
||||||
|
@ -209,7 +211,7 @@ ImplementationFile=LayerList.cpp
|
||||||
BaseClass=CDialog
|
BaseClass=CDialog
|
||||||
Filter=D
|
Filter=D
|
||||||
VirtualFilter=dWC
|
VirtualFilter=dWC
|
||||||
LastObject=IDC_LAYER_LIST
|
LastObject=CLayerList
|
||||||
|
|
||||||
[DLG:IDD_TILESET_DIALOG]
|
[DLG:IDD_TILESET_DIALOG]
|
||||||
Type=1
|
Type=1
|
||||||
|
|
|
@ -129,6 +129,10 @@ BEGIN
|
||||||
MENUITEM SEPARATOR
|
MENUITEM SEPARATOR
|
||||||
MENUITEM "&Toggle TileView", ID_TOGGLE_TILEVIEW
|
MENUITEM "&Toggle TileView", ID_TOGGLE_TILEVIEW
|
||||||
END
|
END
|
||||||
|
POPUP "Misc"
|
||||||
|
BEGIN
|
||||||
|
MENUITEM "2d/3d Toggle", ID_2D_3D_TOGGLE
|
||||||
|
END
|
||||||
POPUP "&Window"
|
POPUP "&Window"
|
||||||
BEGIN
|
BEGIN
|
||||||
MENUITEM "&New Window", ID_WINDOW_NEW
|
MENUITEM "&New Window", ID_WINDOW_NEW
|
||||||
|
@ -152,6 +156,7 @@ IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
|
||||||
BEGIN
|
BEGIN
|
||||||
219, ID_ACTIVEBRUSH_LEFT, VIRTKEY, NOINVERT
|
219, ID_ACTIVEBRUSH_LEFT, VIRTKEY, NOINVERT
|
||||||
221, ID_ACTIVEBRUSH_RIGHT, VIRTKEY, NOINVERT
|
221, ID_ACTIVEBRUSH_RIGHT, VIRTKEY, NOINVERT
|
||||||
|
222, ID_2D_3D_TOGGLE, VIRTKEY, NOINVERT
|
||||||
"C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
|
"C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
|
||||||
"G", ID_TOGGLE_GRID, VIRTKEY, NOINVERT
|
"G", ID_TOGGLE_GRID, VIRTKEY, NOINVERT
|
||||||
"N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
|
"N", ID_FILE_NEW, VIRTKEY, CONTROL, NOINVERT
|
||||||
|
|
|
@ -191,7 +191,7 @@ void CMapEditDoc::SetMode(int NewMode)
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
void CMapEditDoc::TileBankLoad()
|
void CMapEditDoc::TileBankLoad()
|
||||||
{
|
{
|
||||||
char BASED_CODE GinFilter[]= "Gin Files (*.Gin)|*.gin|All Files (*.*)|*.*||";
|
char BASED_CODE GinFilter[]= "All Tile Files (*.Gin; *.Bmp)|*.gin;*.Bmp|3d Tile Files (*.Gin)|*.Gin|2d Tile Files (*.Bmp)|*.Bmp|All Files (*.*)|*.*||";
|
||||||
CFileDialog Dlg(TRUE,"Gin",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,GinFilter);
|
CFileDialog Dlg(TRUE,"Gin",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,GinFilter);
|
||||||
|
|
||||||
if (Dlg.DoModal()!=IDOK) return;
|
if (Dlg.DoModal()!=IDOK) return;
|
||||||
|
@ -243,3 +243,9 @@ CMapSizeDlg Dlg;
|
||||||
|
|
||||||
Core.SetMapSize(View,Dlg.m_Width,Dlg.m_Height);
|
Core.SetMapSize(View,Dlg.m_Width,Dlg.m_Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************************************************************************/
|
||||||
|
void CMapEditDoc::Toggle2d3d(CMapEditView *View)
|
||||||
|
{
|
||||||
|
Core.Toggle2d3d(View);
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
void ActiveBrushLeft(CMapEditView *View);
|
void ActiveBrushLeft(CMapEditView *View);
|
||||||
void ActiveBrushRight(CMapEditView *View);
|
void ActiveBrushRight(CMapEditView *View);
|
||||||
void MapSetSize(CMapEditView *View);
|
void MapSetSize(CMapEditView *View);
|
||||||
|
void Toggle2d3d(CMapEditView *View);
|
||||||
|
|
||||||
void TileBankLoad();
|
void TileBankLoad();
|
||||||
void TileBankReload();
|
void TileBankReload();
|
||||||
|
|
|
@ -41,9 +41,10 @@ BEGIN_MESSAGE_MAP(CMapEditView, CGLEnabledView)
|
||||||
ON_COMMAND(ID_MIRRORY, OnMirrory)
|
ON_COMMAND(ID_MIRRORY, OnMirrory)
|
||||||
ON_COMMAND(ID_ACTIVEBRUSH_LEFT, OnActivebrushLeft)
|
ON_COMMAND(ID_ACTIVEBRUSH_LEFT, OnActivebrushLeft)
|
||||||
ON_COMMAND(ID_ACTIVEBRUSH_RIGHT, OnActivebrushRight)
|
ON_COMMAND(ID_ACTIVEBRUSH_RIGHT, OnActivebrushRight)
|
||||||
|
ON_COMMAND(ID_MAP_SETSIZE, OnMapSetSize)
|
||||||
ON_COMMAND(ID_TOOLBAR_TILEPALETTE, OnToggleTileview)
|
ON_COMMAND(ID_TOOLBAR_TILEPALETTE, OnToggleTileview)
|
||||||
ON_COMMAND(ID_TOGGLE_GRID, OnToggleGrid)
|
ON_COMMAND(ID_TOGGLE_GRID, OnToggleGrid)
|
||||||
ON_COMMAND(ID_MAP_SETSIZE, OnMapSetSize)
|
ON_COMMAND(ID_2D_3D_TOGGLE, On2d3dToggle)
|
||||||
//}}AFX_MSG_MAP
|
//}}AFX_MSG_MAP
|
||||||
END_MESSAGE_MAP()
|
END_MESSAGE_MAP()
|
||||||
|
|
||||||
|
@ -167,3 +168,5 @@ void CMapEditView::OnActivebrushLeft() {GetDocument()->ActiveBrushLeft(t
|
||||||
void CMapEditView::OnActivebrushRight() {GetDocument()->ActiveBrushRight(this);}
|
void CMapEditView::OnActivebrushRight() {GetDocument()->ActiveBrushRight(this);}
|
||||||
|
|
||||||
void CMapEditView::OnMapSetSize() {GetDocument()->MapSetSize(this);}
|
void CMapEditView::OnMapSetSize() {GetDocument()->MapSetSize(this);}
|
||||||
|
|
||||||
|
void CMapEditView::On2d3dToggle() {GetDocument()->Toggle2d3d(this);}
|
||||||
|
|
|
@ -62,6 +62,7 @@ protected:
|
||||||
afx_msg void OnActivebrushLeft();
|
afx_msg void OnActivebrushLeft();
|
||||||
afx_msg void OnActivebrushRight();
|
afx_msg void OnActivebrushRight();
|
||||||
afx_msg void OnMapSetSize();
|
afx_msg void OnMapSetSize();
|
||||||
|
afx_msg void On2d3dToggle();
|
||||||
//}}AFX_MSG
|
//}}AFX_MSG
|
||||||
DECLARE_MESSAGE_MAP()
|
DECLARE_MESSAGE_MAP()
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#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 <Vector>
|
#include <Vector>
|
||||||
|
|
||||||
#include "TexCache.h"
|
#include "TexCache.h"
|
||||||
|
@ -15,32 +16,113 @@
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int CTexCache::ProcessTexture(char *TexName,char *Path,int Flags)
|
int CTexCache::GetTexIdx(char *Name,int Flags)
|
||||||
{
|
{
|
||||||
int ListSize=TexList.size();
|
int ListSize=TexList.size();
|
||||||
|
|
||||||
// Check if Tex exists
|
|
||||||
for (int Count=0;Count<ListSize;Count++)
|
for (int Count=0;Count<ListSize;Count++)
|
||||||
{
|
{
|
||||||
if (strcmp(TexName,TexList[Count].Name)==0 && TexList[Count].Flags==Flags)
|
if (strcmp(Name,TexList[Count].Name)==0 && TexList[Count].Flags==Flags)
|
||||||
{
|
{
|
||||||
return(Count);
|
return(Count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sTex NewTex;
|
|
||||||
char Filename[256];
|
|
||||||
strcpy(NewTex.Name,TexName);
|
|
||||||
strcpy(NewTex.Path,Path);
|
|
||||||
sprintf(Filename,"%s%s",Path,TexName);
|
|
||||||
TRACE1("Loading Texture %s\n",Filename);
|
|
||||||
LoadGLTexture(Filename,NewTex.TexID);
|
|
||||||
NewTex.Flags=Flags;
|
|
||||||
TexList.push_back(NewTex);
|
|
||||||
|
|
||||||
return(Count);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
int CTexCache::ProcessTexture(char *TexName,char *Path,int Flags,sRGBData *RGBData)
|
||||||
|
{
|
||||||
|
int ListSize=TexList.size();
|
||||||
|
int Idx;
|
||||||
|
char Name[_MAX_FNAME];
|
||||||
|
|
||||||
|
_splitpath(TexName,0,0,Name,0);
|
||||||
|
|
||||||
|
// Check if Tex exists
|
||||||
|
/* for (int Count=0;Count<ListSize;Count++)
|
||||||
|
{
|
||||||
|
if (strcmp(Name,TexList[Count].Name)==0 && TexList[Count].Flags==Flags)
|
||||||
|
{
|
||||||
|
return(Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
Idx=GetTexIdx(Name,Flags);
|
||||||
|
if (Idx!=-1) return(Idx);
|
||||||
|
|
||||||
|
sTex NewTex;
|
||||||
|
sRGBData ThisRGB;
|
||||||
|
|
||||||
|
strcpy(NewTex.Name,Name);
|
||||||
|
strcpy(NewTex.Path,Path);
|
||||||
|
NewTex.Flags=Flags;
|
||||||
|
|
||||||
|
if (!RGBData) // Need to load file
|
||||||
|
{
|
||||||
|
char Filename[_MAX_PATH];
|
||||||
|
|
||||||
|
sprintf(Filename,"%s%s.Bmp",Path,Name);
|
||||||
|
TRACE1("Loading Texture %s\n",Filename);
|
||||||
|
LoadBMP(Filename,ThisRGB);
|
||||||
|
RGBData=&ThisRGB;
|
||||||
|
LoadTex(NewTex,RGBData);
|
||||||
|
FreeBMP(ThisRGB);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LoadTex(NewTex,RGBData);
|
||||||
|
}
|
||||||
|
|
||||||
|
TexList.push_back(NewTex);
|
||||||
|
|
||||||
|
return(ListSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
/**************************************************************************************/
|
||||||
|
/**************************************************************************************/
|
||||||
|
void CTexCache::LoadBMP(char *Filename,sRGBData &RGBData)
|
||||||
|
{
|
||||||
|
FILE *File=NULL;
|
||||||
|
AUX_RGBImageRec *Aux;
|
||||||
|
|
||||||
|
Aux=auxDIBImageLoad(Filename);
|
||||||
|
RGBData.Width=Aux->sizeX;
|
||||||
|
RGBData.Height=Aux->sizeY;
|
||||||
|
RGBData.RGB=(char*)Aux->data;
|
||||||
|
free(Aux); // Safe to free aux now, contents copied (I HATE AUX)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
void CTexCache::FreeBMP(sRGBData &RGBData)
|
||||||
|
{
|
||||||
|
if (RGBData.RGB)
|
||||||
|
{
|
||||||
|
free((unsigned char*)RGBData.RGB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
void CTexCache::LoadTex(sTex &ThisTex,sRGBData *TexData)
|
||||||
|
{
|
||||||
|
ThisTex.Width=TexData->Width;
|
||||||
|
ThisTex.Height=TexData->Height;
|
||||||
|
|
||||||
|
glGenTextures(1, &ThisTex.TexID);
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_2D, ThisTex.TexID);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, 3, TexData->Width, TexData->Height, 0, GL_RGB, GL_UNSIGNED_BYTE, TexData->RGB);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
/**************************************************************************************/
|
||||||
|
/**************************************************************************************/
|
||||||
|
|
||||||
void CTexCache::Purge()
|
void CTexCache::Purge()
|
||||||
{
|
{
|
||||||
int ListSize=TexList.size();
|
int ListSize=TexList.size();
|
||||||
|
|
|
@ -12,12 +12,20 @@
|
||||||
#include <gl\glut.h>
|
#include <gl\glut.h>
|
||||||
#include <Vector>
|
#include <Vector>
|
||||||
|
|
||||||
|
struct sRGBData
|
||||||
|
{
|
||||||
|
int Width;
|
||||||
|
int Height;
|
||||||
|
char *RGB;
|
||||||
|
};
|
||||||
|
|
||||||
struct sTex
|
struct sTex
|
||||||
{
|
{
|
||||||
char Name[256];
|
char Name[256];
|
||||||
char Path[256];
|
char Path[256];
|
||||||
GLuint TexID;
|
GLuint TexID;
|
||||||
int Flags;
|
int Flags;
|
||||||
|
int Width,Height;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -27,10 +35,18 @@ class CTexCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
int ProcessTexture(char *TexName,char *Path,int Flags);
|
int GetTexIdx(char *Name,int Flags);
|
||||||
|
|
||||||
|
int ProcessTexture(char *TexName,char *Path,int Flags,sRGBData *RGBData=0);
|
||||||
|
void Purge();
|
||||||
|
|
||||||
|
void LoadBMP(char *Filename,sRGBData &RGBData);
|
||||||
|
void FreeBMP(sRGBData &RGBData);
|
||||||
|
|
||||||
|
void LoadTex(sTex &ThisTex,sRGBData *TexData);
|
||||||
|
|
||||||
sTex &GetTex(int Id) {return(TexList[Id]);}
|
sTex &GetTex(int Id) {return(TexList[Id]);}
|
||||||
GLuint GetTexGLId(int Id) {return(TexList[Id].TexID);}
|
GLuint GetTexGLId(int Id) {return(TexList[Id].TexID);}
|
||||||
void Purge();
|
|
||||||
|
|
||||||
std::vector<sTex> TexList;
|
std::vector<sTex> TexList;
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,8 @@ CTileBank::CTileBank()
|
||||||
SelEnd=1;
|
SelEnd=1;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// AddTileSet("c:/temp/rockp/rockp.gin");
|
AddTileSet("c:/temp/rockp/rockp.gin");
|
||||||
AddTileSet("c:/temp/3/test.gin");
|
// AddTileSet("c:/temp/3/test.gin");
|
||||||
|
|
||||||
int W=3;
|
int W=3;
|
||||||
int H=3;
|
int H=3;
|
||||||
|
@ -167,12 +167,12 @@ void CTileBank::RenderSet(CCore *Core,Vec &CamPos,BOOL Is3d)
|
||||||
if (Is3d)
|
if (Is3d)
|
||||||
{
|
{
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
TileSet[CurrentSet].Render3d(CamPos,GetLBrush(),GetRBrush());
|
TileSet[CurrentSet].Render(CamPos,GetLBrush(),GetRBrush(),TRUE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TileSet[CurrentSet].Render2d(CamPos,GetLBrush(),GetRBrush());
|
TileSet[CurrentSet].Render(CamPos,GetLBrush(),GetRBrush(),FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TileSet[CurrentSet].RenderCursor(CamPos,CursorPos,SelStart,SelEnd);
|
TileSet[CurrentSet].RenderCursor(CamPos,CursorPos,SelStart,SelEnd);
|
||||||
|
@ -288,14 +288,8 @@ BOOL CTileBank::SelectCancel()
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
CTileSet::CTileSet(char *_Filename,int Idx)
|
CTileSet::CTileSet(char *_Filename,int Idx)
|
||||||
{
|
{
|
||||||
char Drive[_MAX_DRIVE];
|
_splitpath(_Filename,Drive,Path,Name,Ext);
|
||||||
char Dir[_MAX_DIR];
|
|
||||||
char Fname[_MAX_FNAME];
|
|
||||||
char Ext[_MAX_EXT];
|
|
||||||
|
|
||||||
_splitpath(_Filename,Drive,Dir,Fname,Ext);
|
|
||||||
sprintf(Path,"%s%s",Drive,Dir);
|
|
||||||
sprintf(Name,"%s",Fname);
|
|
||||||
Loaded=FALSE;
|
Loaded=FALSE;
|
||||||
SetNumber=Idx;
|
SetNumber=Idx;
|
||||||
}
|
}
|
||||||
|
@ -312,10 +306,37 @@ CTileSet::~CTileSet()
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CTileSet::Load(CCore *Core)
|
void CTileSet::Load(CCore *Core)
|
||||||
{
|
{
|
||||||
CScene Scene;
|
|
||||||
char Filename[256+64];
|
|
||||||
|
|
||||||
sprintf(Filename,"%s%s.%s",Path,Name,"Gin");
|
if (IsStrSame(Ext,".Gin"))
|
||||||
|
{
|
||||||
|
Load3d(Core);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Load2d(Core);
|
||||||
|
}
|
||||||
|
|
||||||
|
Loaded=TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CTileSet::Load2d(CCore *Core)
|
||||||
|
{
|
||||||
|
|
||||||
|
// _makepath( Filename, Drive, Path, Name, Ext);
|
||||||
|
|
||||||
|
Tile.push_back(CTile()); // Insert Blank
|
||||||
|
|
||||||
|
Tile.push_back(CTile(Core,this,0,0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
void CTileSet::Load3d(CCore *Core)
|
||||||
|
{
|
||||||
|
char Filename[_MAX_PATH];
|
||||||
|
CScene Scene;
|
||||||
|
|
||||||
|
_makepath( Filename, Drive, Path, Name, Ext);
|
||||||
Scene.Load(Filename);
|
Scene.Load(Filename);
|
||||||
|
|
||||||
CNode &ThisNode=Scene.GetSceneNode(0);
|
CNode &ThisNode=Scene.GetSceneNode(0);
|
||||||
|
@ -327,8 +348,6 @@ int ChildCount=ThisNode.GetPruneChildCount();
|
||||||
Tile.push_back(CTile(Core,this,Scene,ThisNode.PruneChildList[Child]));
|
Tile.push_back(CTile(Core,this,Scene,ThisNode.PruneChildList[Child]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Loaded=TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -346,12 +365,7 @@ int ListSize=Tile.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void CTileSet::Render2d(Vec &CamPos,CMap &LBrush,CMap &RBrush)
|
void CTileSet::Render(Vec &CamPos,CMap &LBrush,CMap &RBrush,BOOL Render3d)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
void CTileSet::Render3d(Vec &CamPos,CMap &LBrush,CMap &RBrush)
|
|
||||||
{
|
{
|
||||||
int ListSize=Tile.size();
|
int ListSize=Tile.size();
|
||||||
int TileID=0;
|
int TileID=0;
|
||||||
|
@ -371,7 +385,7 @@ int SelFlag;
|
||||||
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);
|
||||||
|
|
||||||
glColor3f(0.5,0.5,0.5);
|
glColor3f(0.5,0.5,0.5);
|
||||||
if (TileID) Tile[TileID].Render(0);
|
if (TileID) Tile[TileID].Render(0,Render3d);
|
||||||
ThisElem.Tile=TileID;
|
ThisElem.Tile=TileID;
|
||||||
SelFlag=0;
|
SelFlag=0;
|
||||||
|
|
||||||
|
@ -445,7 +459,6 @@ int MaxTile=Tile.size();
|
||||||
{
|
{
|
||||||
for (int X=Start.x; X<=End.x; X++)
|
for (int X=Start.x; X<=End.x; X++)
|
||||||
{
|
{
|
||||||
// RenderCursorBlock(CamPos,X,Y);
|
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -93,21 +93,26 @@ public:
|
||||||
|
|
||||||
int IsLoaded() {return(Loaded);}
|
int IsLoaded() {return(Loaded);}
|
||||||
int GetTileCount() {return(Tile.size());}
|
int GetTileCount() {return(Tile.size());}
|
||||||
|
|
||||||
void Load(CCore *Core);
|
void Load(CCore *Core);
|
||||||
|
void Load2d(CCore *Core);
|
||||||
|
void Load3d(CCore *Core);
|
||||||
|
|
||||||
char *GetPath() {return(Path);}
|
char *GetPath() {return(Path);}
|
||||||
char *GetName() {return(Name);}
|
char *GetName() {return(Name);}
|
||||||
|
char *GetExt() {return(Ext);}
|
||||||
|
|
||||||
CTile &GetTile(int No) {return(Tile[No]);}
|
CTile &GetTile(int No) {return(Tile[No]);}
|
||||||
void Purge();
|
void Purge();
|
||||||
int FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos);
|
int FindCursorPos(CCore *Core,CMapEditView *View,Vec &CamPos,CPoint &MousePos);
|
||||||
void Render2d(Vec &CamPos,CMap &LBrush,CMap &RBrush);
|
void Render(Vec &CamPos,CMap &LBrush,CMap &RBrush,BOOL Render3d);
|
||||||
void Render3d(Vec &CamPos,CMap &LBrush,CMap &RBrush);
|
|
||||||
void RenderCursor(Vec &CamPos,int Pos,int Width, int Height);
|
void RenderCursor(Vec &CamPos,int Pos,int Width, int Height);
|
||||||
void RenderBrush(Vec &CamPos,CMap &LBrush,CMap &RBrush);
|
void RenderBrush(Vec &CamPos,CMap &LBrush,CMap &RBrush);
|
||||||
void RenderGrid(Vec &CamPos);
|
void RenderGrid(Vec &CamPos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
char Path[256],Name[256];
|
char Drive[_MAX_DRIVE],Path[_MAX_DIR],Name[_MAX_FNAME],Ext[_MAX_EXT];
|
||||||
int SetNumber;
|
int SetNumber;
|
||||||
std::vector<CTile> Tile;
|
std::vector<CTile> Tile;
|
||||||
BOOL Loaded;
|
BOOL Loaded;
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#define ID_ACTIVEBRUSH_LEFT 32790
|
#define ID_ACTIVEBRUSH_LEFT 32790
|
||||||
#define ID_ACTIVEBRUSH_RIGHT 32791
|
#define ID_ACTIVEBRUSH_RIGHT 32791
|
||||||
#define ID_MAP_SETSIZE 32792
|
#define ID_MAP_SETSIZE 32792
|
||||||
|
#define ID_2D_3D_TOGGLE 32794
|
||||||
#define ID_INDICATOR_CURSORXY 59142
|
#define ID_INDICATOR_CURSORXY 59142
|
||||||
|
|
||||||
// Next default values for new objects
|
// Next default values for new objects
|
||||||
|
@ -51,7 +52,7 @@
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_3D_CONTROLS 1
|
#define _APS_3D_CONTROLS 1
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 168
|
#define _APS_NEXT_RESOURCE_VALUE 168
|
||||||
#define _APS_NEXT_COMMAND_VALUE 32794
|
#define _APS_NEXT_COMMAND_VALUE 32795
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1042
|
#define _APS_NEXT_CONTROL_VALUE 1042
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
#define _APS_NEXT_SYMED_VALUE 101
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -176,6 +176,7 @@ int ID;
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
#if 0
|
||||||
AUX_RGBImageRec *LoadBMP(char *Filename)
|
AUX_RGBImageRec *LoadBMP(char *Filename)
|
||||||
{
|
{
|
||||||
FILE *File=NULL;
|
FILE *File=NULL;
|
||||||
|
@ -192,40 +193,50 @@ FILE *File=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
int LoadGLTexture(char *FileName, GLuint &Text)
|
void FreeBMP(AUX_RGBImageRec *TextureImage)
|
||||||
{
|
{
|
||||||
AUX_RGBImageRec *TextureImage[1];
|
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;
|
int Status=FALSE;
|
||||||
|
|
||||||
memset(TextureImage,0,sizeof(void *)*1); // Init Buffer
|
memset(&TextureImage,0,sizeof(void *)*1); // Init Buffer
|
||||||
|
|
||||||
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
|
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
|
||||||
if (TextureImage[0]=LoadBMP(FileName))
|
if (TextureImage=LoadBMP(FileName))
|
||||||
{
|
{
|
||||||
|
Width=TextureImage->sizeX;
|
||||||
|
Height=TextureImage->sizeY;
|
||||||
Status=TRUE; // Set The Status To TRUE
|
Status=TRUE; // Set The Status To TRUE
|
||||||
|
|
||||||
glGenTextures(1, &Text); // Create The Texture
|
glGenTextures(1, &Text); // Create The Texture
|
||||||
|
|
||||||
// Typical Texture Generation Using Data From The Bitmap
|
// Typical Texture Generation Using Data From The Bitmap
|
||||||
glBindTexture(GL_TEXTURE_2D, Text);
|
glBindTexture(GL_TEXTURE_2D, Text);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
|
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_MIN_FILTER,GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TextureImage[0]) // If Texture Exists
|
FreeBMP(TextureImage);
|
||||||
{
|
|
||||||
if (TextureImage[0]->data) // If Texture Image Exists
|
|
||||||
{
|
|
||||||
free(TextureImage[0]->data); // Free The Texture Image Memory
|
|
||||||
}
|
|
||||||
|
|
||||||
free(TextureImage[0]); // Free The Image Structure
|
|
||||||
}
|
|
||||||
|
|
||||||
return Status; // Return The Status
|
return Status; // Return The Status
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
struct sTgaHdr
|
struct sTgaHdr
|
||||||
|
@ -246,52 +257,42 @@ struct sTgaHdr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SaveTGA(char *Filename,int SX,int SY,int SW,int SH)
|
void SaveTGA(char *Filename,int W,int H,char *Data)
|
||||||
{
|
{
|
||||||
FILE *File;
|
FILE *File;
|
||||||
sTgaHdr FileHdr;
|
sTgaHdr FileHdr;
|
||||||
|
|
||||||
File=fopen(Filename,"wb");
|
File=fopen(Filename,"wb");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
// Header
|
|
||||||
memset(&FileHdr,0 ,sizeof(sTgaHdr));
|
memset(&FileHdr,0 ,sizeof(sTgaHdr));
|
||||||
|
|
||||||
FileHdr.imagetype= 2; //imagetype
|
FileHdr.imagetype= 2; //imagetype
|
||||||
FileHdr.width = SW;
|
FileHdr.width = W;
|
||||||
FileHdr.height= SH;
|
FileHdr.height= H;
|
||||||
FileHdr.depth=24;
|
FileHdr.depth=24;
|
||||||
// FileHdr.imagedesc=24;
|
|
||||||
|
|
||||||
fwrite(&FileHdr,sizeof(sTgaHdr),1,File);
|
fwrite(&FileHdr,sizeof(sTgaHdr),1,File);
|
||||||
|
|
||||||
|
fwrite(Data,W*H*3,1,File);
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
// Data
|
|
||||||
for (int Y=0; Y<SH; Y++)
|
|
||||||
{
|
|
||||||
for (int X=0; X<SW; X++)
|
|
||||||
{
|
|
||||||
float Col[3];
|
|
||||||
unsigned char R,G,B;
|
|
||||||
|
|
||||||
glReadPixels(X,Y,1,1,GL_RED, GL_FLOAT,&Col[0]);
|
|
||||||
glReadPixels(X,Y,1,1,GL_GREEN, GL_FLOAT,&Col[1]);
|
|
||||||
glReadPixels(X,Y,1,1,GL_BLUE, GL_FLOAT,&Col[2]);
|
|
||||||
|
|
||||||
R=Col[0]*255;
|
|
||||||
G=Col[1]*255;
|
|
||||||
B=Col[2]*255;
|
|
||||||
|
|
||||||
fwrite(&B,1,1,File);
|
|
||||||
fwrite(&G,1,1,File);
|
|
||||||
fwrite(&R,1,1,File);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
fclose(File);
|
fclose(File);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**************************************************************************************/
|
||||||
|
void BGR2RGB(int W,int H,char *Data)
|
||||||
|
{
|
||||||
|
for (int Y=0; Y<H; Y++)
|
||||||
|
{
|
||||||
|
for (int X=0; X<W; X++)
|
||||||
|
{
|
||||||
|
unsigned char c0,c1;
|
||||||
|
c0=Data[0];
|
||||||
|
c1=Data[2];
|
||||||
|
Data[0]=c1;
|
||||||
|
Data[2]=c0;
|
||||||
|
Data+=3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,10 @@
|
||||||
#define __UTILS_HEADER__
|
#define __UTILS_HEADER__
|
||||||
|
|
||||||
#include "maths.h"
|
#include "maths.h"
|
||||||
|
//#include <gl\gl.h>
|
||||||
|
//#include <gl\glu.h>
|
||||||
|
//#include <gl\glut.h>
|
||||||
|
//#include <gl\glaux.h> // Header File For The Glaux Library
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
@ -14,7 +18,7 @@ void DbgMsg(const char * pszFmt,...);
|
||||||
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);
|
||||||
void BuildGLBoxNoNormals(float XMin,float XMax,float YMin,float YMax,float ZMin,float ZMax);
|
void BuildGLBoxNoNormals(float XMin,float XMax,float YMin,float YMax,float ZMin,float ZMax);
|
||||||
void BuildGLQuad(float XMin,float XMax,float YMin,float YMax,float Z);
|
void BuildGLQuad(float XMin,float XMax,float YMin,float YMax,float Z);
|
||||||
int LoadGLTexture(char *FileName, GLuint &Text);
|
int LoadGLTexture(char *FileName, GLuint &Text,int &Width,int &Height);
|
||||||
|
|
||||||
void TNormalise(TVECTOR &V);
|
void TNormalise(TVECTOR &V);
|
||||||
TVECTOR TCrossProduct(TVECTOR const &V0,TVECTOR const &V1,const TVECTOR &V2 );
|
TVECTOR TCrossProduct(TVECTOR const &V0,TVECTOR const &V1,const TVECTOR &V2 );
|
||||||
|
@ -22,7 +26,15 @@ TVECTOR TCrossProduct(TVECTOR const &V0,TVECTOR const &V1,const TVECTOR &V2 );
|
||||||
CPoint IDToPoint(int ID,int Width);
|
CPoint IDToPoint(int ID,int Width);
|
||||||
int PointToID(CPoint &Pnt,int Width);
|
int PointToID(CPoint &Pnt,int Width);
|
||||||
|
|
||||||
void SaveTGA(char *Filename,int SX,int SY,int SW,int SH);
|
//AUX_RGBImageRec *LoadBMP(char *Filename);
|
||||||
|
//void FreeBMP(AUX_RGBImageRec *TextureImage);
|
||||||
|
|
||||||
|
|
||||||
|
//void SaveTGA(char *Filename,int SX,int SY,int SW,int SH);
|
||||||
|
void SaveTGA(char *Filename,int W,int H,char *Data);
|
||||||
|
void BGR2RGB(int W,int H,char *Data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue