Move the texture object to the screen directory for the sake of library dependencies

This commit is contained in:
ehofman
2003-04-12 09:29:18 +00:00
parent ce4f0c4fee
commit 95c6c16851
4 changed files with 42 additions and 6 deletions

View File

@@ -15,7 +15,6 @@ include_HEADERS = \
stopwatch.hxx \
strutils.hxx \
tabbed_values.hxx \
texture.hxx \
texcoord.hxx \
zfstream.hxx
@@ -28,7 +27,6 @@ libsgmisc_a_SOURCES = \
sgstream.cxx \
strutils.cxx \
tabbed_values.cxx \
texture.cxx \
texcoord.cxx \
zfstream.cxx

View File

@@ -12,9 +12,14 @@ IMAGE_SERVER_INCL =
IMAGE_SERVER_SRCS =
endif
include_HEADERS = $(IMAGE_SERVER_INCL) screen-dump.hxx tr.h
include_HEADERS = \
texture.hxx \
$(IMAGE_SERVER_INCL) \
screen-dump.hxx \
tr.h
libsgscreen_a_SOURCES = \
texture.cxx \
GLBitmaps.cxx GLBitmaps.h \
$(IMAGE_SERVER_SRCS) \
screen-dump.cxx \

View File

@@ -25,7 +25,7 @@ SGTexture::SGTexture()
SGTexture::SGTexture(unsigned int width, unsigned int height)
{
texture_data = new GLubyte[ width*height*3 ];
texture_data = new GLubyte[ width * height * 3 ];
}
SGTexture::~SGTexture()
@@ -275,8 +275,8 @@ SGTexture::read_raw_texture(const char *name)
ptr = texture_data;
for(y=0; y<256; y++) {
gzread(image->file, ptr, 256*3);
ptr+=256*3;
gzread(image->file, ptr, 256*3);
ptr+=256*3;
}
ImageClose(image);
}
@@ -320,6 +320,28 @@ SGTexture::read_r8_texture(const char *name)
}
void
SGTexture::set_pixel(GLuint x, GLuint y, sgVec3 &c)
{
unsigned int pos = (x + y*texture_width)*3;
texture_data[pos] = c[0];
texture_data[pos+1] = c[1];
texture_data[pos+2] = c[2];
}
sgVec3 *
SGTexture::get_pixel(GLuint x, GLuint y)
{
static sgVec3 c;
unsigned int pos = (x + y*texture_width)*3;
sgSetVec3(c, texture_data[pos], texture_data[pos+1], texture_data[pos+2]);
return &c;
}
SGTexture::ImageRec *
SGTexture::ImageOpen(const char *fileName)
{
@@ -493,6 +515,7 @@ SGTexture::ConvertShort(unsigned short *array, unsigned int length) {
}
}
void
SGTexture::ConvertUint(unsigned *array, unsigned int length) {
unsigned int b1, b2, b3, b4;

View File

@@ -5,6 +5,8 @@
#include <GL/gl.h>
#include <zlib.h>
#include <plib/sg.h>
class SGTexture {
private:
@@ -64,9 +66,17 @@ public:
inline int width() { return texture_width; }
inline int height() { return texture_height; }
// dynamic texture functions.
// everything drawn to the OpenGL screen after prepare is
// called and before finish is called will be included
// in the new texture.
void prepare(unsigned int width = 256, unsigned int height = 256);
void finish(unsigned int width, unsigned int height);
// texture pixel manipulation functions.
void set_pixel(GLuint x, GLuint y, sgVec3 &c);
sgVec3 *get_pixel(GLuint x, GLuint y);
void bind();
inline void select() {
// if (texture_data)