rborgaonkar
04-30-2012, 10:44 AM
Hello All,
I am new to OPENGL and Im trying to run a sample code in Visual Studio C++.The code compiles. When I run the code , I see a black screen for a second , and disappears. I am just trying to draw a simple line.Please Help !!!
Here is the code.
#include "StdAfx.h"
#include <windows.h>
#include <gl/gl.h>
void DrawLine( int ax, int ay, int bx, int by, int width, int r, int g, int b, int a )
{
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4ub( r, g, b, a);
glLineWidth(width);
glBegin(GL_LINES);
glVertex2i( ax, ay);
glVertex2i( bx, by);
glEnd();
glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
}
void main()
{
DrawLine( 492, 384, 532, 384, 3, 0, 255, 100, 255);
}
I am new to OPENGL and Im trying to run a sample code in Visual Studio C++.The code compiles. When I run the code , I see a black screen for a second , and disappears. I am just trying to draw a simple line.Please Help !!!
Here is the code.
#include "StdAfx.h"
#include <windows.h>
#include <gl/gl.h>
void DrawLine( int ax, int ay, int bx, int by, int width, int r, int g, int b, int a )
{
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4ub( r, g, b, a);
glLineWidth(width);
glBegin(GL_LINES);
glVertex2i( ax, ay);
glVertex2i( bx, by);
glEnd();
glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
}
void main()
{
DrawLine( 492, 384, 532, 384, 3, 0, 255, 100, 255);
}