Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

OpenGL opengl newbie question

This topic is 4526 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#include <GL/glut.h> void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0f,1.0f,1.0f); glBegin(GL_LINE_STRIP); glVertex2i(380,240); glVertex2i(380,280); glVertex2i(300,320); glVertex2i(300,300); glVertex2i(320,280); glVertex2i(300,260); glVertex2i(300,240); glEnd(); glFlush(); } void main(void) { glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); glutInitWindowSize(1016,700); glutInitWindowPosition(0,0); glClearColor(0.0f,0.0f,0.0f,0.0f); glutCreateWindow("Panzer Blitz"); glutDisplayFunc(RenderScene); glutMainLoop(); } I am simply trying to draw an object on the screen but all I get is a black screen, please help

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by phil67rpg
how do I draw in pixels??


Make the viewport and the projection matrix match the windows size, then the coordinates given to glVertex-functions are in pixels.

Share this post


Link to post
Share on other sites
Never tried this but you could say since -1 is far left and 1 is far right then

2/width = 1pixel in x
2/height = 1pixel in y


//draw at 30,40
glVertex2f(30*(2/width), 40*(2/height));

could try that. should work not sure tho.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!