Hi and thanks for the help in advance. I’m using SDL2.0 in Visual Studio on Windows 8. If you look at my Code to draw a quad it should draw a square but it draws a rectangle. The only thing I can think of is that I somehow must of messed up setting up my projection. 1280 by 720 is my window size. I also tried glOrtho and got the same results. I looked and I am calling all my functions.
Quad Draw Code
glBegin(GL_QUADS);
glTexCoord2i(0, 1); glVertex3f(0, 0, 0);
glTexCoord2i(0, 0); glVertex3f(0, 0.25f, 0);
glTexCoord2i(1, 0); glVertex3f(0.25f, 0.25f, 0);
glTexCoord2i(1, 1); glVertex3f(0.25f, 0, 0);
glEnd();
OVER ALL CODE FOR RENDERERING
#include "GraphicsDevice.h"
GraphicsDevice::GraphicsDevice()
{
}
GraphicsDevice::~GraphicsDevice()
{
}
void GraphicsDevice::Initalize(SDL_Window* win)
{
//Use OpenGL 2.1
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
//Create OpenGL Context
glContext = SDL_GL_CreateContext(win);
//Initalize OpenGl Clear Color
glClearColor(0,0,0,1);
}
void GraphicsDevice::UpdateProjection()
{
glViewport(0, 0, 1280, 720);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(0, 1, 1, 1, 0, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glFlush();
}
void GraphicsDevice::Clear(SDL_Window* win, Color* color)
{
SDL_GL_SwapWindow(win);
glClearColor(color->r, color->g, color->b, color->a);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glFlush();
}
void GraphicsDevice::BeginDraw()
{
glEnable(GL_TEXTURE_2D);
}
void GraphicsDevice::EndDraw()
{
glDisable(GL_TEXTURE_2D);
}
void GraphicsDevice::DrawQuad(Texture2D* texture, Vector3* position, Vector3* origin, Vector3* rotation, Vector3* scale)
{
glPushMatrix();
//Translate
//Sclae
//Rotate
glBindTexture(GL_TEXTURE_2D, texture->id);
glBegin(GL_QUADS);
glTexCoord2i(0, 1); glVertex3f(0, 0, 0);
glTexCoord2i(0, 0); glVertex3f(0, 0.25f, 0);
glTexCoord2i(1, 0); glVertex3f(0.25f, 0.25f, 0);
glTexCoord2i(1, 1); glVertex3f(0.25f, 0, 0);
glEnd();
glPopMatrix();
glFlush();
}
Thank you for your time and help.