Разработка информационной системы для деканата высшего учебного заведения
Дипломная работа - Компьютеры, программирование
Другие дипломы по предмету Компьютеры, программирование
формате TGARGBApixel
{
GLubyte r,g,b,a;(GLubyte, GLubyte, GLubyte, GLubyte);();GetPixel(GLubyte &, GLubyte &, GLubyte &, GLubyte &);ToBGRA();
};RGBpixel
{r,g,b;(GLubyte, GLubyte, GLubyte);();GetPixel(GLubyte &, GLubyte &, GLubyte &);ToBGR();ToBGRA();
};
//Основной класс текстуры
class texture
{:exsist; //суествует
bool binded; //уже применяется
int width; //ширина
int height; //высотаRealWidth; //ширина, приближённая к степени двойкиRealHeight; //высота, приближённая к степени двойкиPixelsQnt; //количество точекID; //идентификационный номер текстуры в OpelGL
float hcoeff; //отношение height к RealHeightwcoeff; //отношение width к RealWidth:
//поля
dinmas imageData; //массив точек
//методы
//исправление целочисленного цвета,
//если он выходит из диапазона 0-255
GLubyte correct(float);
//копировать текстуру
void operator=(texture &);
//задать одну точку целыми числами
void SetPixel(int, int, GLubyte, GLubyte, GLubyte, GLubyte);
//задать одну точку числами с плавающей точкой
void SetPixelf(int, int, float, float, float, float);
//получить одну точку
void GetPixel(int, int, GLubyte &, GLubyte &, GLubyte &, GLubyte &);
texture(); //конструктор
//выделение памяти c проверкой на степень двойкиMakeArray(int, int);
//выделение памяти в обход проверки на степень двойки
bool MakeArraySimple(unsigned int, unsigned int);
//применение текстуры
bool BindTexture(unsigned int, bool, bool);
//сохранение в TGASaveToTGA(AnsiString);
//чтение из TGALoadFromTGA(AnsiString, unsigned int, bool, bool);
~texture(); //деструкторDeleteArray(); //очистить массив
void UnBind(); //отменить текстуру
//Методы получения величин
unsigned int GetWidth();int GetHeight();int GetRealWidth();int GetRealHeight();int GetPixelsQnt();int GetID();GetExsist();GetBinded();GetWCoeff();GetHCoeff();GetWCoeffF();GetHCoeffF();
//Методы установки величин
void PutWidth(unsigned int);PutHeight(unsigned int);PutRealWidth(unsigned int);PutRealHeight(unsigned int);PutPixelsQnt(unsigned int);PutID(unsigned int);PutExsist(bool);PutBinded(bool);PutWCoeff(float);PutHCoeff(float);
};
#endif
3.3.2 Реализация lotexture.cpp
#ifndef LOTEXTURE_CPP
#define LOTEXTURE_CPP
#include "lotexture.h"namespace std;::RGBApixel(GLubyte R, GLubyte G, GLubyte B, GLubyte A)
{
r=R; g=G; b=B; a=A;
}::RGBApixel()
{=0; g=0; b=0; a=255;
}RGBApixel::GetPixel(GLubyte &R, GLubyte &G, GLubyte &B, GLubyte &A)
{=r; G=g; B=b; A=a;
}RGBApixel::ToBGRA()
{RGBApixel(b,g,r,a);
}::RGBpixel(GLubyte R, GLubyte G, GLubyte B)
{=R; g=G; b=B;
}::RGBpixel()
{=0; g=0; b=0;
}RGBpixel::GetPixel(GLubyte &R, GLubyte &G, GLubyte &B)
{=r; G=g; B=b;
}RGBpixel::ToBGR()
{RGBpixel(b,g,r);
}RGBpixel::ToBGRA()
{RGBApixel(b,g,r,255);
}texture::correct(float x)
{(x=1) return 255;floor(255*x);
}texture::operator=(texture &object)
{=object.exsist;
}texture::SetPixel(int Col, int Row, GLubyte r, GLubyte g, GLubyte b, GLubyte a)
{i=Row*RealWidth+Col;(i<PixelsQnt) imageData[i]=RGBApixel(r,g,b,a);
}texture::SetPixelf(int Col, int Row, float r, float g, float b, float a)
{i=Row*RealWidth+Col;(i<PixelsQnt) imageData[i]=RGBApixel(correct(r),correct(g),correct(b),correct(a));
}texture::GetPixel(int Col, int Row, GLubyte &r, GLubyte &g, GLubyte &b, GLubyte &a)
{i=Row*RealWidth+Col;(i<PixelsQnt)
{[i].GetPixel(r,g,b,a);
}
}::texture()
{=0; binded=0;
}texture::MakeArray(int w, int h)
{(w==0 || h==0) return 0;=w; height=h;
#ifdef LT_IGNORE_ERROR
{=NearestPow2(w);=NearestPow2(h);=1-1.*(RealWidth -width )/RealWidth ;=1-1.*(RealHeight-height)/RealHeight;
}
#else
{=width;=height;=wcoeff=1;
}
#endif=RealWidth*RealHeight;(imageData.make(PixelsQnt))
{=1;1;
}
{("Ошибка");0;
}
}texture::MakeArraySimple(unsigned int w, unsigned int h)
{(w==0 || h==0) return 0;=w; height=h;=width;=height;=wcoeff=1;=RealWidth*RealHeight;(imageData.make(PixelsQnt))
{=1;1;
}
{("Ошибка");0;
}
}texture::BindTexture(unsigned int TexID, bool Interpolation, bool Multiply)
{(!exsist) return 0;=TexID;(GL_TEXTURE_2D, TexID);(Interpolation)
{(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
{(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}(Multiply)
{(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_REPEAT);(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_REPEAT);
}
{(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_CLAMP);(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_CLAMP);
}D(GL_TEXTURE_2D, 0, GL_RGBA, RealWidth, RealHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData.data);=1;1;
}texture::SaveToTGA(AnsiString fileName)
{(!exsist) return 0;hdr;( &hdr, \0, sizeof ( hdr ) );.imageType = 2; // unencoded image.width = width;.height = height;.pixelSize = 32;*pFile;=fopen(fileName.c_str(), "wb");(&hdr, sizeof(hdr),1,pFile);WritedPxlQnt=width*height;*temp = new RGBApixel[WritedPxlQnt];i=0;(int row=0;row<height;row++)
{(int col=0;col<width;col++)
{[i]=imageData[row*RealWidth+col].ToBGRA();++;
}
}(temp, WritedPxlQnt*4, 1, pFile);(pFile);( temp );1;
}texture::LoadFromTGA(AnsiString fileName, unsigned int TexID, bool Interpolation, bool Multiply)
{hdr;*pFile;=fopen(fileName.c_str(), "rb");(pFile==NULL) return 0;(&hdr, sizeof(hdr),1,pFile);(!(hdr.pixelSize==32 || hdr.pixelSize==24) || hdr.imageType!=2) return 0;(hdr.width,hdr.height);ReadPxlQnt=hdr.width*hdr.height;(hdr.pixelSize==32)
{*temp = new RGBApixel[ReadPxlQnt];(temp, ReadPxlQnt*4, 1, pFile);i=0;(int row=0;row<height;row++)
{(int col=0;col<width;col++)
{[row*RealWidth+col]=temp[i].ToBGRA();++;
}
}(temp);
}(hdr.pixelSize==24)
{*temp = new RGBpixel[ReadPxlQnt];(temp, ReadPxlQnt*3, 1, pFile);i=0;(int row=0;row<height;row++)
{(int col=0;col<width;col++)
{[row*RealWidth+col]=temp[i].ToBGRA();++;
}
}(temp);
}(pFile);(TexID,Interpolation,Multiply);1;
}::~texture()
{();
}texture::DeleteArray()
{(!exsist) return;.clear();=0;
}texture::UnBind()
{(!binded) return;(GL_TEXTURE_2D, ID);data[4]="1111";D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);=0;
}int texture::GetWidth()
{width;
}int texture::GetHeight()
{height;
}int texture::GetRealWidth()
{RealWidth;
}int texture::GetRealHeight()
{RealHeight;
}int texture::GetPixelsQnt()
{PixelsQnt;
}int texture::GetID()
{ID;
}texture::GetExsist()
{exsist;
}texture::GetBinded()
{binded;
}texture::GetWCoeff()
{
return wcoeff;
}texture::GetHCoeff()
{hcoeff;
}texture::GetWCoeffF()
{1-1.*(RealWidth-width-2)/RealWidth;
}texture::GetHCoeffF()
{1-1.*(RealHeight-height-2)/RealHeight;
}texture::PutWidth(unsigned int w)
{=w;
}texture::PutHeight(unsigned int h)
{=h;
}texture::PutRealWidth(unsigned int rw)
{=rw;
}texture::PutRealHeight(unsigned int rh)
{=rh;
}texture::PutPixelsQnt(unsigned int pq)
{=pq;
}texture::PutID(unsigned int id)
{=id;
}texture::PutExsist(bool ex)
{=ex;
}texture::PutBinded(bool bd)
{=bd;
}texture::PutWCoeff(float wc)
{=wc;
}texture::PutHCoeff(float hc)
{=hc;
}
#endif
3.4 Модуль chizu
/******************************************************
Автор: Плеханов Ф.А.
Назначение: Класс батиметрии. Производит всю обработку батиметрических данных
и построение батиметрической сетки.
Входные данные: исходные треки, множество настроек, таких как частота изолиний
Выходные данные: трёхмерная батиметрическая карта с изолиниями и подписями
*******************************************************/
3.4.1 Заголовочный файл chizu.h
#ifndef C