4 Replies - 740 Views - Last Post: 01 July 2015 - 11:51 PM Rate Topic: -----

#1 mateo226   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 19-June 15

glOrtho not working properly?

Posted 27 June 2015 - 01:37 PM

Hello everyone!
I am using GLUT and for some reason my glOrtho isnt working properly...
This is my code:
#include"Dependencies\glew\glew.h"
#include"Dependencies\freeglut\freeglut.h"
#include<iostream>
void render(void)
{
	glEnable(GL_DEPTH_TEST);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glClearColor(1, 1, 1, 1.0);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, 1280, 720, 0, 0, 1);
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);

	float x = 0;
	float y = 0;

	glBegin(GL_QUADS);
		glColor3f(1, 0, 0);
		glVertex2f(x, y);
		glVertex2f(x + .1, y);
		glVertex2f(x + .1, y + .1);
		glVertex2f(x, y + .1);
	glEnd();
	std::cout << "Hey" << std::endl;
	glutSwapBuffers();
}
void closeCallback()
{

	std::cout << "GLUT:\t Finished" << std::endl;
	glutLeaveMainLoop();
}

int main(int argc, char **argv)
{

	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
	glutInitWindowPosition(32, 32);
	glutInitWindowSize(1280, 720);
	glutCreateWindow("MahGame");
	glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);

	glewInit();

	glutDisplayFunc(render);
	glutCloseFunc(closeCallback);

	glutMainLoop();

	return 0;
}

SO basically, even though I set my x and y floats to 0 i renders it in the middle, and when I try something like x + 50, it is SUPER huge, I have to make it x + 0.5f so that my triangle is small...
Any help is appreciated!
Thanks!
Have a great day!

Is This A Good Question/Topic? 0
  • +

Replies To: glOrtho not working properly?

#2 mateo226   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 19-June 15

Re: glOrtho not working properly?

Posted 27 June 2015 - 02:25 PM

Bump
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14929
  • View blog
  • Posts: 59,607
  • Joined: 12-June 08

Re: glOrtho not working properly?

Posted 27 June 2015 - 02:27 PM

Remember this is a volunteer forum and people work on their own schedule. Please do not excessively bump your thread - especially with in less than an hour of posting it and still at the top of the sub-forum.
Was This Post Helpful? 0
  • +
  • -

#4 mateo226   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 19-June 15

Re: glOrtho not working properly?

Posted 28 June 2015 - 02:53 AM

Okay sorry.
Was This Post Helpful? 0
  • +
  • -

#5 ben255   User is offline

  • D.I.C Addict

Reputation: 39
  • View blog
  • Posts: 510
  • Joined: 09-September 13

Re: glOrtho not working properly?

Posted 01 July 2015 - 11:51 PM

The opengl view looks different then the normal for pixels. 0 is middle if you start going negative it goes left or up. And posetive values are right or down depending on the axis youre changeinc
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1