Move the texture object to the screen directory for the sake of library dependencies
This commit is contained in:
@@ -15,7 +15,6 @@ include_HEADERS = \
|
|||||||
stopwatch.hxx \
|
stopwatch.hxx \
|
||||||
strutils.hxx \
|
strutils.hxx \
|
||||||
tabbed_values.hxx \
|
tabbed_values.hxx \
|
||||||
texture.hxx \
|
|
||||||
texcoord.hxx \
|
texcoord.hxx \
|
||||||
zfstream.hxx
|
zfstream.hxx
|
||||||
|
|
||||||
@@ -28,7 +27,6 @@ libsgmisc_a_SOURCES = \
|
|||||||
sgstream.cxx \
|
sgstream.cxx \
|
||||||
strutils.cxx \
|
strutils.cxx \
|
||||||
tabbed_values.cxx \
|
tabbed_values.cxx \
|
||||||
texture.cxx \
|
|
||||||
texcoord.cxx \
|
texcoord.cxx \
|
||||||
zfstream.cxx
|
zfstream.cxx
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,14 @@ IMAGE_SERVER_INCL =
|
|||||||
IMAGE_SERVER_SRCS =
|
IMAGE_SERVER_SRCS =
|
||||||
endif
|
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 = \
|
libsgscreen_a_SOURCES = \
|
||||||
|
texture.cxx \
|
||||||
GLBitmaps.cxx GLBitmaps.h \
|
GLBitmaps.cxx GLBitmaps.h \
|
||||||
$(IMAGE_SERVER_SRCS) \
|
$(IMAGE_SERVER_SRCS) \
|
||||||
screen-dump.cxx \
|
screen-dump.cxx \
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ SGTexture::SGTexture()
|
|||||||
|
|
||||||
SGTexture::SGTexture(unsigned int width, unsigned int height)
|
SGTexture::SGTexture(unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
texture_data = new GLubyte[ width*height*3 ];
|
texture_data = new GLubyte[ width * height * 3 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
SGTexture::~SGTexture()
|
SGTexture::~SGTexture()
|
||||||
@@ -275,8 +275,8 @@ SGTexture::read_raw_texture(const char *name)
|
|||||||
|
|
||||||
ptr = texture_data;
|
ptr = texture_data;
|
||||||
for(y=0; y<256; y++) {
|
for(y=0; y<256; y++) {
|
||||||
gzread(image->file, ptr, 256*3);
|
gzread(image->file, ptr, 256*3);
|
||||||
ptr+=256*3;
|
ptr+=256*3;
|
||||||
}
|
}
|
||||||
ImageClose(image);
|
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::ImageRec *
|
||||||
SGTexture::ImageOpen(const char *fileName)
|
SGTexture::ImageOpen(const char *fileName)
|
||||||
{
|
{
|
||||||
@@ -493,6 +515,7 @@ SGTexture::ConvertShort(unsigned short *array, unsigned int length) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SGTexture::ConvertUint(unsigned *array, unsigned int length) {
|
SGTexture::ConvertUint(unsigned *array, unsigned int length) {
|
||||||
unsigned int b1, b2, b3, b4;
|
unsigned int b1, b2, b3, b4;
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
|
#include <plib/sg.h>
|
||||||
|
|
||||||
class SGTexture {
|
class SGTexture {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -64,9 +66,17 @@ public:
|
|||||||
inline int width() { return texture_width; }
|
inline int width() { return texture_width; }
|
||||||
inline int height() { return texture_height; }
|
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 prepare(unsigned int width = 256, unsigned int height = 256);
|
||||||
void finish(unsigned int width, unsigned int height);
|
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();
|
void bind();
|
||||||
inline void select() {
|
inline void select() {
|
||||||
// if (texture_data)
|
// if (texture_data)
|
||||||
Reference in New Issue
Block a user