diff --git a/GL/framebuffer.c b/GL/framebuffer.c index 8983a62..9faac02 100644 --- a/GL/framebuffer.c +++ b/GL/framebuffer.c @@ -1,6 +1,7 @@ #include #include "private.h" #include "../include/glkos.h" +#include "../include/glext.h" typedef struct { GLuint index; diff --git a/GL/private.h b/GL/private.h index 1bb7a7d..ffc378d 100644 --- a/GL/private.h +++ b/GL/private.h @@ -9,6 +9,7 @@ #define TRACE_ENABLED 0 #define TRACE() if(TRACE_ENABLED) {fprintf(stderr, "%s\n", __func__);} +#define MAX_TEXTURE_SIZE 1024 typedef struct { unsigned int cmd[8]; diff --git a/GL/state.c b/GL/state.c index e57e1e0..7946a49 100644 --- a/GL/state.c +++ b/GL/state.c @@ -434,6 +434,9 @@ void APIENTRY glGetIntegerv(GLenum pname, GLint *params) { case GL_BLEND_DST: *params = BLEND_DFACTOR; break; + case GL_MAX_TEXTURE_SIZE: + *params = MAX_TEXTURE_SIZE; + break; default: _glKosThrowError(GL_INVALID_ENUM, "glGetIntegerv"); _glKosPrintError(); diff --git a/GL/texture.c b/GL/texture.c index d2845fa..016e2fb 100644 --- a/GL/texture.c +++ b/GL/texture.c @@ -1,7 +1,10 @@ #include "private.h" -#include "../include/glext.h" + #include +#include "../include/glext.h" +#include "../include/glkos.h" + #define CLAMP_U (1<<1) #define CLAMP_V (1<<0) @@ -167,7 +170,7 @@ void APIENTRY glTexEnvf(GLenum target, GLenum pname, GLfloat param) { void APIENTRY glCompressedTexImage2D(GLenum target, GLint level, - GLenum internalformat, + GLenum internalFormat, GLsizei width, GLsizei height, GLint border, @@ -178,22 +181,24 @@ void APIENTRY glCompressedTexImage2D(GLenum target, if(target != GL_TEXTURE_2D) _glKosThrowError(GL_INVALID_ENUM, "glCompressedTexImage2D"); - if(level < 0) + if(level < 0 || border) _glKosThrowError(GL_INVALID_VALUE, "glCompressedTexImage2D"); - if(border) - _glKosThrowError(GL_INVALID_VALUE, "glCompressedTexImage2D"); - - if(internalformat != GL_UNSIGNED_SHORT_5_6_5_VQ_KOS) - if(internalformat != GL_UNSIGNED_SHORT_5_6_5_VQ_TWID_KOS) - if(internalformat != GL_UNSIGNED_SHORT_4_4_4_4_VQ_KOS) - if(internalformat != GL_UNSIGNED_SHORT_4_4_4_4_REV_VQ_TWID_KOS) - if(internalformat != GL_UNSIGNED_SHORT_1_5_5_5_REV_VQ_KOS) - if(internalformat != GL_UNSIGNED_SHORT_1_5_5_5_REV_VQ_TWID_KOS) - _glKosThrowError(GL_INVALID_OPERATION, "glCompressedTexImage2D"); - - if(TEXTURE_UNITS[ACTIVE_TEXTURE] == NULL) + switch(internalFormat) { + case GL_COMPRESSED_ARGB_1555_VQ_KOS: + case GL_COMPRESSED_ARGB_1555_VQ_TWID_KOS: + case GL_COMPRESSED_ARGB_4444_VQ_KOS: + case GL_COMPRESSED_ARGB_4444_VQ_TWID_KOS: + case GL_COMPRESSED_RGB_565_VQ_KOS: + case GL_COMPRESSED_RGB_565_VQ_TWID_KOS: + break; + default: _glKosThrowError(GL_INVALID_OPERATION, "glCompressedTexImage2D"); + } + + if(TEXTURE_UNITS[ACTIVE_TEXTURE] == NULL) { + _glKosThrowError(GL_INVALID_OPERATION, "glCompressedTexImage2D"); + } if(_glKosHasError()) { _glKosPrintError(); @@ -206,8 +211,8 @@ void APIENTRY glCompressedTexImage2D(GLenum target, active->height = height; active->mip_map = level; active->color = _determinePVRFormat( - internalformat, - internalformat /* Doesn't matter (see determinePVRFormat) */ + internalFormat, + internalFormat /* Doesn't matter (see determinePVRFormat) */ ); /* Odds are slim new data is same size as old, so free always */ @@ -312,21 +317,21 @@ static GLuint _determinePVRFormat(GLint internalFormat, GLenum type) { /* Compressed and twiddled versions */ case GL_UNSIGNED_SHORT_5_6_5_TWID_KOS: return PVR_TXRFMT_RGB565 | PVR_TXRFMT_TWIDDLED; - case GL_UNSIGNED_SHORT_5_6_5_VQ_KOS: + case GL_COMPRESSED_RGB_565_VQ_KOS: return PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED | PVR_TXRFMT_VQ_ENABLE; - case GL_UNSIGNED_SHORT_5_6_5_VQ_TWID_KOS: + case GL_COMPRESSED_RGB_565_VQ_TWID_KOS: return PVR_TXRFMT_RGB565 | PVR_TXRFMT_TWIDDLED | PVR_TXRFMT_VQ_ENABLE; case GL_UNSIGNED_SHORT_4_4_4_4_REV_TWID_KOS: return PVR_TXRFMT_ARGB4444 | PVR_TXRFMT_TWIDDLED; - case GL_UNSIGNED_SHORT_4_4_4_4_REV_VQ_TWID_KOS: + case GL_COMPRESSED_ARGB_4444_VQ_TWID_KOS: return PVR_TXRFMT_ARGB4444 | PVR_TXRFMT_TWIDDLED | PVR_TXRFMT_VQ_ENABLE; - case GL_UNSIGNED_SHORT_4_4_4_4_VQ_KOS: + case GL_COMPRESSED_ARGB_4444_VQ_KOS: return PVR_TXRFMT_ARGB4444 | PVR_TXRFMT_NONTWIDDLED | PVR_TXRFMT_VQ_ENABLE; case GL_UNSIGNED_SHORT_1_5_5_5_REV_TWID_KOS: return PVR_TXRFMT_ARGB1555 | PVR_TXRFMT_TWIDDLED; - case GL_UNSIGNED_SHORT_1_5_5_5_REV_VQ_KOS: + case GL_COMPRESSED_ARGB_1555_VQ_KOS: return PVR_TXRFMT_ARGB1555 | PVR_TXRFMT_NONTWIDDLED | PVR_TXRFMT_VQ_ENABLE; - case GL_UNSIGNED_SHORT_1_5_5_5_REV_VQ_TWID_KOS: + case GL_COMPRESSED_ARGB_1555_VQ_TWID_KOS: return PVR_TXRFMT_ARGB1555 | PVR_TXRFMT_TWIDDLED | PVR_TXRFMT_VQ_ENABLE; default: return 0; @@ -494,7 +499,7 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat, pvr_mem_free(active->data); active->data = NULL; } - } + } GLuint bytes = (width * height * sizeof(GLushort)); diff --git a/include/gl.h b/include/gl.h index af93d82..9b8a828 100644 --- a/include/gl.h +++ b/include/gl.h @@ -339,24 +339,6 @@ __BEGIN_DECLS #define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -/* - * Dreamcast specific compressed + twiddled formats. - * We use constants from the range 0xEEE0 onwards - * to avoid trampling any real GL constants (this is in the middle of the - * any_vendor_future_use range defined in the GL enum.spec file. -*/ -#define GL_UNSIGNED_SHORT_5_6_5_TWID_KOS 0xEEE0 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV_TWID_KOS 0xEEE2 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_TWID_KOS 0xEEE3 - -#define GL_UNSIGNED_SHORT_5_6_5_VQ_KOS 0xEEE4 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV_VQ_KOS 0xEEE6 -#define GL_UNSIGNED_SHORT_4_4_4_4_VQ_KOS 0xEEE7 - -#define GL_UNSIGNED_SHORT_5_6_5_VQ_TWID_KOS 0xEEE8 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV_VQ_TWID_KOS 0xEEEA -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_VQ_TWID_KOS 0xEEEB - #define GL_RED 0x1903 #define GL_GREEN 0x1904 #define GL_BLUE 0x1905 diff --git a/include/glext.h b/include/glext.h index 2d52273..fc4a762 100644 --- a/include/glext.h +++ b/include/glext.h @@ -87,6 +87,45 @@ __BEGIN_DECLS #define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 + +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD + +GLAPI void APIENTRY glGenFramebuffersEXT(GLsizei n, GLuint* framebuffers); +GLAPI void APIENTRY glDeleteFramebuffersEXT(GLsizei n, const GLuint* framebuffers); +GLAPI void APIENTRY glBindFramebufferEXT(GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glGenerateMipmapEXT(GLenum target); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT(GLenum target); +GLAPI GLboolean APIENTRY glIsFramebufferEXT(GLuint framebuffer); + __END_DECLS #endif /* !__GL_GLEXT_H */ diff --git a/include/glkos.h b/include/glkos.h index 4e83a24..07e8478 100644 --- a/include/glkos.h +++ b/include/glkos.h @@ -5,49 +5,30 @@ __BEGIN_DECLS +/* + * Dreamcast specific compressed + twiddled formats. + * We use constants from the range 0xEEE0 onwards + * to avoid trampling any real GL constants (this is in the middle of the + * any_vendor_future_use range defined in the GL enum.spec file. +*/ +#define GL_UNSIGNED_SHORT_5_6_5_TWID_KOS 0xEEE0 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV_TWID_KOS 0xEEE2 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_TWID_KOS 0xEEE3 -#define GL_NEARZ_CLIPPING_KOS 0xEEFA +#define GL_COMPRESSED_RGB_565_VQ_KOS 0xEEE4 +#define GL_COMPRESSED_ARGB_1555_VQ_KOS 0xEEE6 +#define GL_COMPRESSED_ARGB_4444_VQ_KOS 0xEEE7 -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_COMPRESSED_RGB_565_VQ_TWID_KOS 0xEEE8 +#define GL_COMPRESSED_ARGB_1555_VQ_TWID_KOS 0xEEEA +#define GL_COMPRESSED_ARGB_4444_VQ_TWID_KOS 0xEEEB + +#define GL_NEARZ_CLIPPING_KOS 0xEEFA -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD GLAPI void APIENTRY glKosSwapBuffers(); -GLAPI void APIENTRY glGenFramebuffersEXT(GLsizei n, GLuint* framebuffers); -GLAPI void APIENTRY glDeleteFramebuffersEXT(GLsizei n, const GLuint* framebuffers); -GLAPI void APIENTRY glBindFramebufferEXT(GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glGenerateMipmapEXT(GLenum target); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT(GLenum target); -GLAPI GLboolean APIENTRY glIsFramebufferEXT(GLuint framebuffer); + __END_DECLS diff --git a/samples/Makefile b/samples/Makefile index 4e98a82..8854101 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -11,6 +11,7 @@ all: $(KOS_MAKE) -C nehe02va all $(KOS_MAKE) -C nehe03 all $(KOS_MAKE) -C nehe06 all + $(KOS_MAKE) -C nehe06_vq all $(KOS_MAKE) -C ortho2d all $(KOS_MAKE) -C lerabot01 all $(KOS_MAKE) -C zclip all diff --git a/samples/nehe06_vq/Makefile b/samples/nehe06_vq/Makefile new file mode 100644 index 0000000..8daa976 --- /dev/null +++ b/samples/nehe06_vq/Makefile @@ -0,0 +1,29 @@ +TARGET = nehe06_vq.elf +OBJS = main.o + +all: rm-elf $(TARGET) + +include $(KOS_BASE)/Makefile.rules + +clean: + -rm -f $(TARGET) $(OBJS) romdisk.* + +rm-elf: + -rm -f $(TARGET) romdisk.* + +$(TARGET): $(OBJS) romdisk.o + $(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \ + $(OBJS) romdisk.o $(OBJEXTRA) -lm -lkosutils $(KOS_LIBS) + +romdisk.img: + $(KOS_GENROMFS) -f romdisk.img -d romdisk -v + +romdisk.o: romdisk.img + $(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o + +run: $(TARGET) + $(KOS_LOADER) $(TARGET) + +dist: + rm -f $(OBJS) romdisk.o romdisk.img + $(KOS_STRIP) $(TARGET) diff --git a/samples/nehe06_vq/main.c b/samples/nehe06_vq/main.c new file mode 100644 index 0000000..408d8e0 --- /dev/null +++ b/samples/nehe06_vq/main.c @@ -0,0 +1,243 @@ +#include + +#include "gl.h" +#include "glu.h" +#include "glkos.h" + +extern uint8 romdisk[]; +KOS_INIT_ROMDISK(romdisk); + +/* floats for x rotation, y rotation, z rotation */ +float xrot, yrot, zrot; + +/* storage for one texture */ +int texture[1]; + +/* Image type - contains height, width, and data */ +struct Image { + unsigned long sizeX; + unsigned long sizeY; + char *data; + GLenum internalFormat; + GLboolean mipmapped; + unsigned int dataSize; +}; + +typedef struct Image Image; + +int ImageLoad(char *filename, Image *image) { + FILE* file = NULL; + + // make sure the file is there. + if ((file = fopen(filename, "rb")) == NULL) + { + printf("File Not Found : %s\n",filename); + return 0; + } + + struct { + char id[4]; // 'DTEX' + short width; + short height; + int type; + int size; + } header; + + fread(&header, sizeof(header), 1, file); + + GLboolean twiddled = (header.type & (1 << 26)) < 1; + GLboolean compressed = (header.type & (1 << 30)) > 0; + GLboolean mipmapped = (header.type & (1 << 31)) > 0; + GLboolean strided = (header.type & (1 << 25)) > 0; + GLuint format = (header.type >> 27) & 0b111; + + image->data = (char *) malloc (header.size); + image->sizeX = header.width; + image->sizeY = header.height; + image->dataSize = header.size; + + fread(image->data, image->dataSize, 1, file); + fclose(file); + + if(compressed) { + if(twiddled) { + switch(format) { + case 0: + image->internalFormat = GL_COMPRESSED_ARGB_1555_VQ_TWID_KOS; + break; + case 1: + image->internalFormat = GL_COMPRESSED_RGB_565_VQ_TWID_KOS; + break; + case 2: + image->internalFormat = GL_COMPRESSED_ARGB_4444_VQ_TWID_KOS; + break; + default: + fprintf(stderr, "Invalid texture format"); + return 0; + } + } else { + switch(format) { + case 0: + image->internalFormat = GL_COMPRESSED_ARGB_1555_VQ_KOS; + break; + case 1: + image->internalFormat = GL_COMPRESSED_RGB_565_VQ_KOS; + break; + case 2: + image->internalFormat = GL_COMPRESSED_ARGB_4444_VQ_KOS; + break; + default: + fprintf(stderr, "Invalid texture format"); + return 0; + } + } + } else { + printf("Not a compressed texture"); + return 0; + } + + // we're done. + return 1; +} + +// Load Bitmaps And Convert To Textures +void LoadGLTextures() { + // Load Texture + Image *image1; + + // allocate space for texture + image1 = (Image *) malloc(sizeof(Image)); + if (image1 == NULL) { + printf("Error allocating space for image"); + exit(0); + } + + if (!ImageLoad("/rd/NeHe.tex", image1)) { + exit(1); + } + + // Create Texture + glGenTextures(1, &texture[0]); + glBindTexture(GL_TEXTURE_2D, texture[0]); // 2d texture (x and y size) + + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // scale linearly when image bigger than texture + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // scale linearly when image smalled than texture + + // 2d texture, level of detail 0 (normal), 3 components (red, green, blue), x size from image, y size from image, + // border 0 (normal), rgb color data, unsigned byte data, and finally the data itself. + glCompressedTexImage2D( + GL_TEXTURE_2D, 0, image1->internalFormat, image1->sizeX, image1->sizeY, 0, + image1->dataSize, image1->data + ); +}; + +/* A general OpenGL initialization function. Sets all of the initial parameters. */ +void InitGL(int Width, int Height) // We call this right after our OpenGL window is created. +{ + LoadGLTextures(); + glEnable(GL_TEXTURE_2D); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black + glClearDepth(1.0); // Enables Clearing Of The Depth Buffer + glDepthFunc(GL_LESS); // The Type Of Depth Test To Do + glEnable(GL_DEPTH_TEST); // Enables Depth Testing + glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); // Reset The Projection Matrix + + gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f); // Calculate The Aspect Ratio Of The Window + + glMatrixMode(GL_MODELVIEW); +} + +/* The function called when our window is resized (which shouldn't happen, because we're fullscreen) */ +void ReSizeGLScene(int Width, int Height) +{ + if (Height == 0) // Prevent A Divide By Zero If The Window Is Too Small + Height = 1; + + glViewport(0, 0, Width, Height); // Reset The Current Viewport And Perspective Transformation + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f); + glMatrixMode(GL_MODELVIEW); +} + + +/* The main drawing function. */ +void DrawGLScene() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer + glLoadIdentity(); // Reset The View + + glTranslatef(0.0f,0.0f,-5.0f); // move 5 units into the screen. + + glRotatef(xrot,1.0f,0.0f,0.0f); // Rotate On The X Axis + glRotatef(yrot,0.0f,1.0f,0.0f); // Rotate On The Y Axis + glRotatef(zrot,0.0f,0.0f,1.0f); // Rotate On The Z Axis + + glBindTexture(GL_TEXTURE_2D, texture[0]); // choose the texture to use. + + glBegin(GL_QUADS); // begin drawing a cube + + // Front Face (note that the texture's corners have to match the quad's corners) + glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad + + // Back Face + glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad + + // Top Face + glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad + + // Bottom Face + glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Top Left Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad + + // Right face + glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad + glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad + + // Left Face + glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Bottom Left Of The Texture and Quad + glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad + glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Right Of The Texture and Quad + glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); // Top Left Of The Texture and Quad + + glEnd(); // done with the polygon. + + xrot+=1.5f; // X Axis Rotation + yrot+=1.5f; // Y Axis Rotation + zrot+=1.5f; // Z Axis Rotation + // + // swap buffers to display, since we're double buffered. + glKosSwapBuffers(); +} + +int main(int argc, char **argv) +{ + glKosInit(); + + InitGL(640, 480); + ReSizeGLScene(640, 480); + + while(1) { + DrawGLScene(); + } + + return 0; +} diff --git a/samples/nehe06_vq/romdisk/NeHe.bmp b/samples/nehe06_vq/romdisk/NeHe.bmp new file mode 100644 index 0000000..6b3db10 Binary files /dev/null and b/samples/nehe06_vq/romdisk/NeHe.bmp differ diff --git a/samples/nehe06_vq/romdisk/NeHe.png b/samples/nehe06_vq/romdisk/NeHe.png new file mode 100644 index 0000000..49aba8e Binary files /dev/null and b/samples/nehe06_vq/romdisk/NeHe.png differ diff --git a/samples/nehe06_vq/romdisk/NeHe.tex b/samples/nehe06_vq/romdisk/NeHe.tex new file mode 100644 index 0000000..265b491 Binary files /dev/null and b/samples/nehe06_vq/romdisk/NeHe.tex differ diff --git a/samples/nehe06_vq/romdisk/PLACEHOLDER b/samples/nehe06_vq/romdisk/PLACEHOLDER new file mode 100644 index 0000000..e69de29