From: Mikko Rasa Date: Sun, 21 Feb 2010 13:32:51 +0000 (+0000) Subject: Get rid of the typedefs for fundamental types X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=ceae2a27dfc58310c5bab7e3aa3fedf0fa9a1f49;p=libs%2Fgl.git Get rid of the typedefs for fundamental types --- diff --git a/source/batch.cpp b/source/batch.cpp index 33481a1c..9ed20a1f 100644 --- a/source/batch.cpp +++ b/source/batch.cpp @@ -20,7 +20,7 @@ Batch::Batch(PrimitiveType t): max_index(0) { } -Batch &Batch::append(uint i) +Batch &Batch::append(unsigned i) { if(indices.empty()) min_index=max_index=i; @@ -34,10 +34,10 @@ Batch &Batch::append(uint i) return *this; } -void Batch::append(const vector &ind) +void Batch::append(const vector &ind) { indices.reserve(indices.size()+ind.size()); - for(vector::const_iterator i=ind.begin(); i!=ind.end(); ++i) + for(vector::const_iterator i=ind.begin(); i!=ind.end(); ++i) append(*i); } @@ -58,7 +58,7 @@ Batch::Loader::Loader(Batch &b): add("indices", &Loader::indices); } -void Batch::Loader::indices(const vector &ind) +void Batch::Loader::indices(const vector &ind) { obj.append(ind); } diff --git a/source/batch.h b/source/batch.h index bca54139..2b907d48 100644 --- a/source/batch.h +++ b/source/batch.h @@ -11,7 +11,6 @@ Distributed under the LGPL #include #include #include "primitivetype.h" -#include "types.h" namespace Msp { namespace GL { @@ -24,22 +23,23 @@ public: public: Loader(Batch &); private: - void indices(const std::vector &); + void indices(const std::vector &); }; private: PrimitiveType type; - std::vector indices; - uint min_index; - uint max_index; + std::vector indices; + unsigned min_index; + unsigned max_index; public: Batch(PrimitiveType t); - Batch &append(uint); - void append(const std::vector &); + + Batch &append(unsigned); + void append(const std::vector &); PrimitiveType get_type() const { return type; } unsigned size() const { return indices.size(); } - const std::vector &get_indices() const { return indices; } + const std::vector &get_indices() const { return indices; } void draw() const; void draw_with_buffer(unsigned) const; }; diff --git a/source/buffer.h b/source/buffer.h index e9152486..7e57cf02 100644 --- a/source/buffer.h +++ b/source/buffer.h @@ -8,7 +8,7 @@ Distributed under the LGPL #ifndef MSP_GL_BUFFER_H_ #define MSP_GL_BUFFER_H_ -#include "types.h" +#include "gl.h" namespace Msp { namespace GL { diff --git a/source/datatype.h b/source/datatype.h new file mode 100644 index 00000000..b44644ac --- /dev/null +++ b/source/datatype.h @@ -0,0 +1,31 @@ +/* $Id$ + +This file is part of libmspgl +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + +#ifndef MSP_GL_TYPES_H_ +#define MSP_GL_TYPES_H_ + +#include "gl.h" + +namespace Msp { +namespace GL { + +enum DataType +{ + BYTE = GL_BYTE, + UNSIGNED_BYTE = GL_UNSIGNED_BYTE, + SHORT = GL_SHORT, + UNSIGNED_SHORT = GL_UNSIGNED_SHORT, + INT = GL_INT, + UNSIGNED_INT = GL_UNSIGNED_INT, + FLOAT = GL_FLOAT, + DOUBLE = GL_DOUBLE +}; + +} // namespace GL +} // namespace Msp + +#endif diff --git a/source/extension.cpp b/source/extension.cpp index cd8c6297..6b00ceb6 100644 --- a/source/extension.cpp +++ b/source/extension.cpp @@ -100,7 +100,7 @@ void require_version(unsigned a, unsigned b) ExtFunc *get_proc_address(const string &name) { #ifndef WIN32 - return glXGetProcAddressARB(reinterpret_cast(name.c_str())); + return glXGetProcAddressARB(reinterpret_cast(name.c_str())); #else return reinterpret_cast(wglGetProcAddress(name.c_str())); #endif diff --git a/source/framebuffer.h b/source/framebuffer.h index 9fe4cd8b..7c88b4cd 100644 --- a/source/framebuffer.h +++ b/source/framebuffer.h @@ -10,7 +10,6 @@ Distributed under the LGPL #include #include "gl.h" -#include "types.h" namespace Msp { namespace GL { @@ -92,7 +91,7 @@ private: Attachment &operator=(Texture &); }; - uint id; + unsigned id; std::vector attachments; unsigned width; unsigned height; diff --git a/source/program.cpp b/source/program.cpp index 01644c02..b3773a63 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -76,7 +76,7 @@ void Program::set_del_shaders(bool ds) del_shaders=ds; } -void Program::bind_attribute(uint index, const string &name) +void Program::bind_attribute(unsigned index, const string &name) { static RequireExtension _ext("GL_ARB_vertex_shader"); glBindAttribLocationARB(id, index, name.c_str()); @@ -102,9 +102,9 @@ int Program::get_param(GLenum param) const string Program::get_info_log() const { - sizei len=get_param(GL_INFO_LOG_LENGTH); + GLsizei len=get_param(GL_INFO_LOG_LENGTH); char log[len+1]; - glGetInfoLogARB(id, len+1, reinterpret_cast(&len), log); + glGetInfoLogARB(id, len+1, &len, log); return string(log, len); } @@ -160,7 +160,7 @@ void Program::Loader::fragment_shader(const string &src) obj.attach_shader(*new Shader(FRAGMENT_SHADER, src)); } -void Program::Loader::attribute(uint i, const string &n) +void Program::Loader::attribute(unsigned i, const string &n) { obj.bind_attribute(i, n); } diff --git a/source/program.h b/source/program.h index 818e72be..af506fe8 100644 --- a/source/program.h +++ b/source/program.h @@ -12,7 +12,6 @@ Distributed under the LGPL #include #include #include "gl.h" -#include "types.h" namespace Msp { namespace GL { @@ -22,7 +21,7 @@ class Shader; class Program { private: - uint id; + unsigned id; std::list shaders; bool del_shaders; bool linked; @@ -38,7 +37,7 @@ public: private: void vertex_shader(const std::string &); void fragment_shader(const std::string &); - void attribute(uint, const std::string &); + void attribute(unsigned, const std::string &); virtual void finish(); }; @@ -53,7 +52,7 @@ public: void detach_shader(Shader &shader); const std::list &get_shaders() const { return shaders; } void set_del_shaders(bool); - void bind_attribute(uint, const std::string &); + void bind_attribute(unsigned, const std::string &); void link(); int get_param(GLenum param) const; bool get_linked() const { return linked; } diff --git a/source/renderbuffer.cpp b/source/renderbuffer.cpp index ac0a34cd..40d58cef 100644 --- a/source/renderbuffer.cpp +++ b/source/renderbuffer.cpp @@ -30,7 +30,7 @@ void Renderbuffer::bind() const glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, id); } -void Renderbuffer::storage(PixelFormat fmt, sizei w, sizei h) +void Renderbuffer::storage(PixelFormat fmt, unsigned w, unsigned h) { bind(); width=w; diff --git a/source/renderbuffer.h b/source/renderbuffer.h index 040dad44..b7320929 100644 --- a/source/renderbuffer.h +++ b/source/renderbuffer.h @@ -9,7 +9,6 @@ Distributed under the LGPL #define MSP_GL_RENDERBUFFER_H_ #include "pixelformat.h" -#include "types.h" namespace Msp { namespace GL { @@ -24,21 +23,21 @@ Requires the GL_EXT_framebuffer_object extension. class Renderbuffer { private: - uint id; - sizei width; - sizei height; + unsigned id; + unsigned width; + unsigned height; public: Renderbuffer(); ~Renderbuffer(); - uint get_id() const { return id; } - sizei get_width() const { return width; } - sizei get_height() const { return height; } + unsigned get_id() const { return id; } + unsigned get_width() const { return width; } + unsigned get_height() const { return height; } void bind() const; - void storage(PixelFormat fmt, sizei width, sizei height); + void storage(PixelFormat fmt, unsigned width, unsigned height); }; } // namespace GL diff --git a/source/select.cpp b/source/select.cpp index 51fe0b60..e905729d 100644 --- a/source/select.cpp +++ b/source/select.cpp @@ -14,7 +14,7 @@ using namespace std; namespace { vector *select_buf=0; -vector select_buf_int; +vector select_buf_int; } @@ -33,7 +33,7 @@ void init_names() glInitNames(); } -void push_name(uint n) +void push_name(unsigned n) { glPushName(n); } @@ -43,19 +43,19 @@ void pop_name() glPopName(); } -void load_name(uint n) +void load_name(unsigned n) { glLoadName(n); } -void parse_select_records(const uint *buf, uint count, vector &tbuf) +void parse_select_records(const unsigned *buf, unsigned count, vector &tbuf) { - uint i=0; + unsigned i=0; while(count--) { SelectRecord record; - uint n_names=buf[i++]; + unsigned n_names=buf[i++]; record.min_depth=buf[i++]; record.max_depth=buf[i++]; @@ -67,7 +67,7 @@ void parse_select_records(const uint *buf, uint count, vector &tbu } } -void _parse_internal_select_records(uint count) +void _parse_internal_select_records(unsigned count) { if(!select_buf) throw InvalidState("No select buffer specified"); diff --git a/source/select.h b/source/select.h index 680334f4..16d0e47a 100644 --- a/source/select.h +++ b/source/select.h @@ -9,27 +9,26 @@ Distributed under the LGPL #define MSP_GL_SELECT_H_ #include -#include "types.h" namespace Msp { namespace GL { struct SelectRecord { - uint min_depth; - uint max_depth; - std::vector names; + unsigned min_depth; + unsigned max_depth; + std::vector names; }; void select_buffer(std::vector &); void init_names(); -void push_name(uint); +void push_name(unsigned); void pop_name(); -void load_name(uint); +void load_name(unsigned); -void parse_select_records(const uint *buf, uint, std::vector &); +void parse_select_records(const unsigned *buf, unsigned, std::vector &); -void _parse_internal_select_records(uint); +void _parse_internal_select_records(unsigned); } // namespace GL } // namespace Msp diff --git a/source/shader.cpp b/source/shader.cpp index 85451527..e32919bc 100644 --- a/source/shader.cpp +++ b/source/shader.cpp @@ -45,7 +45,7 @@ Shader::~Shader() glDeleteObjectARB(id); } -void Shader::source(sizei count, const char **str, const int *len) +void Shader::source(unsigned count, const char **str, const int *len) { glShaderSourceARB(id, count, str, len); } @@ -76,9 +76,9 @@ int Shader::get_param(GLenum param) const string Shader::get_info_log() const { - sizei len=get_param(GL_INFO_LOG_LENGTH); + GLsizei len=get_param(GL_INFO_LOG_LENGTH); char log[len+1]; - glGetInfoLogARB(id, len+1, reinterpret_cast(&len), log); + glGetInfoLogARB(id, len+1, &len, log); return string(log, len); } diff --git a/source/shader.h b/source/shader.h index 06f769cc..86a70be0 100644 --- a/source/shader.h +++ b/source/shader.h @@ -10,7 +10,6 @@ Distributed under the LGPL #include #include "gl.h" -#include "types.h" namespace Msp { namespace GL { @@ -31,16 +30,16 @@ private: public: ~Shader(); - void source(sizei count, const char **str, const int *len); + void source(unsigned count, const char **str, const int *len); void source(const std::string &str); void source(const char *str, int len); void compile(); - uint get_id() const { return id; } + unsigned get_id() const { return id; } bool get_compiled() const { return compiled; } int get_param(GLenum param) const; std::string get_info_log() const; private: - uint id; + unsigned id; bool compiled; }; diff --git a/source/stencil.cpp b/source/stencil.cpp index a0506310..dfeb3fb7 100644 --- a/source/stencil.cpp +++ b/source/stencil.cpp @@ -10,7 +10,7 @@ Distributed under the LGPL namespace Msp { namespace GL { -void stencil_func(Predicate func, int ref, uint mask) +void stencil_func(Predicate func, int ref, unsigned mask) { glStencilFunc(func, ref, mask); } diff --git a/source/stencil.h b/source/stencil.h index 4d4ee6d3..30ad2570 100644 --- a/source/stencil.h +++ b/source/stencil.h @@ -10,7 +10,6 @@ Distributed under the LGPL #include "gl.h" #include "predicate.h" -#include "types.h" namespace Msp { namespace GL { @@ -32,7 +31,7 @@ enum StencilOp DECR_WRAP = GL_DECR_WRAP }; -void stencil_func(Predicate func, int ref, uint mask); +void stencil_func(Predicate func, int ref, unsigned mask); void stencil_op(StencilOp sfail, StencilOp dfail, StencilOp dpass); } // namespace GL diff --git a/source/tests.cpp b/source/tests.cpp index a7440063..5b34bf69 100644 --- a/source/tests.cpp +++ b/source/tests.cpp @@ -10,7 +10,7 @@ Distributed under the LGPL namespace Msp { namespace GL { -void scissor(int left, int bottom, sizei width, sizei height) +void scissor(int left, int bottom, unsigned width, unsigned height) { glScissor(left, bottom, width, height); } diff --git a/source/tests.h b/source/tests.h index 223396fe..b906c0ce 100644 --- a/source/tests.h +++ b/source/tests.h @@ -10,7 +10,6 @@ Distributed under the LGPL #include "gl.h" #include "predicate.h" -#include "types.h" namespace Msp { namespace GL { @@ -22,7 +21,7 @@ enum DEPTH_TEST = GL_DEPTH_TEST }; -void scissor(int left, int bottom, sizei width, sizei height); +void scissor(int left, int bottom, unsigned width, unsigned height); void alpha_func(Predicate func, float ref); diff --git a/source/texture.h b/source/texture.h index 21edb81a..848517eb 100644 --- a/source/texture.h +++ b/source/texture.h @@ -11,7 +11,6 @@ Distributed under the LGPL #include #include #include "gl.h" -#include "types.h" namespace Msp { namespace GL { @@ -56,12 +55,12 @@ public: void set_min_filter(TextureFilter f) { parameter(GL_TEXTURE_MIN_FILTER, f); } void set_mag_filter(TextureFilter f) { parameter(GL_TEXTURE_MAG_FILTER, f); } GLenum get_target() const { return target; } - uint get_id() const { return id; } + unsigned get_id() const { return id; } static void unbind(); static void unbind_from(unsigned); protected: - uint id; + unsigned id; GLenum target; Texture(); diff --git a/source/texture2d.cpp b/source/texture2d.cpp index c1f6e0e9..1c5a9d63 100644 --- a/source/texture2d.cpp +++ b/source/texture2d.cpp @@ -21,7 +21,7 @@ Texture2D::Texture2D(): bind(); } -void Texture2D::storage(PixelFormat fmt, sizei wd, sizei ht, int brd) +void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht, int brd) { if(width>0) throw InvalidState("Texture storage may only be specified once"); @@ -44,7 +44,7 @@ void Texture2D::image(int level, PixelFormat fmt, DataType type, const void *dat glTexImage2D(target, level, ifmt, width, height, border, fmt, type, data); } -void Texture2D::sub_image(int level, int x, int y, sizei wd, sizei ht, PixelFormat fmt, DataType type, const void *data) +void Texture2D::sub_image(int level, int x, int y, unsigned wd, unsigned ht, PixelFormat fmt, DataType type, const void *data) { if(width==0) throw InvalidState("Texture storage has not been specified"); diff --git a/source/texture2d.h b/source/texture2d.h index 5784645b..01271852 100644 --- a/source/texture2d.h +++ b/source/texture2d.h @@ -10,6 +10,7 @@ Distributed under the LGPL #include #include +#include "datatype.h" #include "pixelformat.h" #include "texture.h" @@ -34,8 +35,8 @@ public: private: PixelFormat ifmt; - sizei width; - sizei height; + unsigned width; + unsigned height; int border; public: @@ -45,7 +46,7 @@ public: Defines the texture storage. This function may only be successfully called once. */ - void storage(PixelFormat fmt, sizei wd, sizei ht, int brd); + void storage(PixelFormat fmt, unsigned wd, unsigned ht, int brd); /** Uploads an image to the texture. storage() must have been called prior to @@ -58,7 +59,7 @@ public: Uploads a sub-image into the texture. Unlike full image upload, there are no constraints on the size of the sub-image. */ - void sub_image(int level, int x, int y, sizei wd, sizei ht, PixelFormat fmt, DataType type, const void *data); + void sub_image(int level, int x, int y, unsigned wd, unsigned ht, PixelFormat fmt, DataType type, const void *data); /** Loads an image from a file and uploads it to the texture. If storage() has @@ -66,8 +67,8 @@ public: */ void load_image(const std::string &fn); - sizei get_width() const { return width; } - sizei get_height() const { return height; } + unsigned get_width() const { return width; } + unsigned get_height() const { return height; } private: void image(const Graphics::Image &); diff --git a/source/texture3d.cpp b/source/texture3d.cpp index 5f864968..b34e20cd 100644 --- a/source/texture3d.cpp +++ b/source/texture3d.cpp @@ -28,7 +28,7 @@ Texture3D::Texture3D(): bind(); } -void Texture3D::storage(PixelFormat f, sizei w, sizei h, sizei d, int b) +void Texture3D::storage(PixelFormat f, unsigned w, unsigned h, unsigned d, int b) { if(width>0) throw InvalidState("Textures may only be created once"); diff --git a/source/texture3d.h b/source/texture3d.h index ec3b57ba..8d9566d8 100644 --- a/source/texture3d.h +++ b/source/texture3d.h @@ -9,6 +9,7 @@ Distributed under the LGPL #define MSP_GL_TEXTURE3D_H_ #include +#include "datatype.h" #include "pixelformat.h" #include "texture.h" @@ -19,20 +20,20 @@ class Texture3D: public Texture { private: PixelFormat ifmt; - sizei width; - sizei height; - sizei depth; + unsigned width; + unsigned height; + unsigned depth; int border; public: Texture3D(); - void storage(PixelFormat, sizei, sizei, sizei, int); + void storage(PixelFormat, unsigned, unsigned, unsigned, int); void image(int, PixelFormat, DataType, const void *); - void sub_image(int, int, int, sizei, sizei, sizei, PixelFormat, DataType, const void *); + void sub_image(int, int, int, unsigned, unsigned, unsigned, PixelFormat, DataType, const void *); void load_image(const std::string &fn, int dp=-1); - sizei get_width() const { return width; } - sizei get_height() const { return height; } - sizei get_depth() const { return depth; } + unsigned get_width() const { return width; } + unsigned get_height() const { return height; } + unsigned get_depth() const { return depth; } }; } // namespace GL diff --git a/source/types.h b/source/types.h deleted file mode 100644 index eb07c726..00000000 --- a/source/types.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#ifndef MSP_GL_TYPES_H_ -#define MSP_GL_TYPES_H_ - -#include "gl.h" - -namespace Msp { -namespace GL { - -enum DataType -{ - BYTE = GL_BYTE, - UNSIGNED_BYTE = GL_UNSIGNED_BYTE, - SHORT = GL_SHORT, - UNSIGNED_SHORT = GL_UNSIGNED_SHORT, - INT = GL_INT, - UNSIGNED_INT = GL_UNSIGNED_INT, - FLOAT = GL_FLOAT, - DOUBLE = GL_DOUBLE -}; - -typedef signed char byte; -typedef unsigned char ubyte; -typedef unsigned sizei; -typedef unsigned uint; - -} // namespace GL -} // namespace Msp - -#endif diff --git a/source/vertexarray.cpp b/source/vertexarray.cpp index a2b65daa..c6724e13 100644 --- a/source/vertexarray.cpp +++ b/source/vertexarray.cpp @@ -83,13 +83,13 @@ void VertexArray::apply() const vbuf->bind(); const float *base=vbuf?0:&data[0]; - uint offset=0; - uint found=0; - uint bpv=stride*sizeof(float); + unsigned offset=0; + unsigned found=0; + unsigned bpv=stride*sizeof(float); for(const unsigned char *c=format.begin(); c!=format.end(); ++c) { - uint sz=(*c&3)+1; - uint t=*c>>2; + unsigned sz=(*c&3)+1; + unsigned t=*c>>2; switch(t) { case 0: @@ -192,17 +192,17 @@ void array_element(int i) glArrayElement(i); } -void draw_arrays(PrimitiveType mode, int first, sizei count) +void draw_arrays(PrimitiveType mode, int first, unsigned count) { glDrawArrays(mode, first, count); } -void draw_elements(PrimitiveType mode, sizei count, DataType type, const void *indices) +void draw_elements(PrimitiveType mode, unsigned count, DataType type, const void *indices) { glDrawElements(mode, count, type, indices); } -void draw_range_elements(PrimitiveType mode, uint low, uint high, sizei count, DataType type, const void *indices) +void draw_range_elements(PrimitiveType mode, unsigned low, unsigned high, unsigned count, DataType type, const void *indices) { static RequireVersion _ver(1, 2); glDrawRangeElements(mode, low, high, count, type, indices); diff --git a/source/vertexarray.h b/source/vertexarray.h index 281996d4..7fcbb8bd 100644 --- a/source/vertexarray.h +++ b/source/vertexarray.h @@ -11,8 +11,8 @@ Distributed under the LGPL #include #include #include +#include "datatype.h" #include "primitivetype.h" -#include "types.h" #include "vertexarraybuilder.h" #include "vertexformat.h" @@ -33,9 +33,9 @@ public: private: VertexFormat format; std::vector data; - uint stride; - Buffer *vbuf; - bool own_vbuf; + unsigned stride; + Buffer *vbuf; + bool own_vbuf; VertexArray(const VertexArray &); VertexArray &operator=(const VertexArray &); @@ -63,20 +63,20 @@ private: }; void array_element(int); -void draw_arrays(PrimitiveType, int, sizei); -void draw_elements(PrimitiveType, sizei, DataType, const void *); -void draw_range_elements(PrimitiveType, uint, uint, sizei, DataType, const void *); +void draw_arrays(PrimitiveType, int, unsigned); +void draw_elements(PrimitiveType, unsigned, DataType, const void *); +void draw_range_elements(PrimitiveType, unsigned, unsigned, unsigned, DataType, const void *); -inline void draw_elements(PrimitiveType mode, sizei count, const unsigned *indices) +inline void draw_elements(PrimitiveType mode, unsigned count, const unsigned *indices) { draw_elements(mode, count, UNSIGNED_INT, indices); } -inline void draw_elements(PrimitiveType mode, sizei count, const unsigned short *indices) +inline void draw_elements(PrimitiveType mode, unsigned count, const unsigned short *indices) { draw_elements(mode, count, UNSIGNED_SHORT, indices); } -inline void draw_range_elements(PrimitiveType mode, uint low, uint high, sizei count, const unsigned short *indices) +inline void draw_range_elements(PrimitiveType mode, unsigned low, unsigned high, unsigned count, const unsigned short *indices) { draw_range_elements(mode, low, high, count, UNSIGNED_SHORT, indices); } -inline void draw_range_elements(PrimitiveType mode, uint low, uint high, sizei count, const unsigned *indices) +inline void draw_range_elements(PrimitiveType mode, unsigned low, unsigned high, unsigned count, const unsigned *indices) { draw_range_elements(mode, low, high, count, UNSIGNED_INT, indices); } } // namespace GL diff --git a/source/vertexarraybuilder.cpp b/source/vertexarraybuilder.cpp index 09b0a1f2..f9adcf58 100644 --- a/source/vertexarraybuilder.cpp +++ b/source/vertexarraybuilder.cpp @@ -25,8 +25,8 @@ void VertexArrayBuilder::vertex_(float x, float y, float z, float w) float *ptr=array.append(); for(const unsigned char *c=array.get_format().begin(); c!=array.get_format().end(); ++c) { - uint size=(*c&3)+1; - uint type=*c>>2; + unsigned size=(*c&3)+1; + unsigned type=*c>>2; switch(type) { case 0: @@ -49,11 +49,11 @@ void VertexArrayBuilder::vertex_(float x, float y, float z, float w) case 3: if(size==1) { - union { ubyte c[4]; float f; } u; - u.c[0]=static_cast(cr*255); - u.c[1]=static_cast(cg*255); - u.c[2]=static_cast(cb*255); - u.c[3]=static_cast(ca*255); + union { unsigned char c[4]; float f; } u; + u.c[0]=static_cast(cr*255); + u.c[1]=static_cast(cg*255); + u.c[2]=static_cast(cb*255); + u.c[3]=static_cast(ca*255); *ptr++=u.f; } else diff --git a/source/vertexbuilder.h b/source/vertexbuilder.h index 3e02e1d4..c92a2760 100644 --- a/source/vertexbuilder.h +++ b/source/vertexbuilder.h @@ -9,7 +9,6 @@ Distributed under the LGPL #define MSP_GL_VERTEXBUILDER_H_ #include -#include "types.h" namespace Msp { namespace GL { @@ -43,8 +42,8 @@ public: void texcoord(float s, float t) { texcoord(s, t, 0, 1); } void texcoord(float s, float t, float r) { texcoord(s, t, r, 1); } void texcoord(float s, float t, float r, float q) { ts=s; tt=t; tr=r; tq=q; } - void color(ubyte r, ubyte g, ubyte b) { color(r, g, b, 255); } - void color(ubyte r, ubyte g, ubyte b, ubyte a) { color(r/255.f, g/255.f, b/255.f, a/255.f); } + void color(unsigned char r, unsigned char g, unsigned char b) { color(r, g, b, 255); } + void color(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { color(r/255.f, g/255.f, b/255.f, a/255.f); } void color(float r, float g, float b) { color(r, g, b, 1); } void color(float r, float g, float b, float a) { cr=r; cg=g; cb=b; ca=a; } void attrib(unsigned i, float x) { attrib(i, x, 0, 0, 1); } diff --git a/source/vertexformat.cpp b/source/vertexformat.cpp index 457cffad..c26c5c3e 100644 --- a/source/vertexformat.cpp +++ b/source/vertexformat.cpp @@ -57,7 +57,7 @@ VertexFormat::~VertexFormat() unsigned VertexFormat::stride() const { - uint s=0; + unsigned s=0; for(const unsigned char *i=begin(); i!=end(); ++i) s+=(*i&3)+1; return s; diff --git a/source/vertexformat.h b/source/vertexformat.h index 75e33473..2164a8fb 100644 --- a/source/vertexformat.h +++ b/source/vertexformat.h @@ -9,7 +9,6 @@ Distributed under the LGPL #define MSP_GL_VERTEXFORMAT_H_ #include -#include "types.h" namespace Msp { namespace GL { @@ -57,7 +56,7 @@ VertexFormat operator,(const VertexFormat &f, unsigned i); inline VertexFormat operator,(VertexComponent c, unsigned i) { return (VertexFormat(c), i); } -inline uint get_stride(const VertexFormat &f) +inline unsigned get_stride(const VertexFormat &f) { return f.stride(); } std::istream &operator>>(std::istream &, VertexFormat &);