Well i have no ftp or anything so hopefull the following isnt against the rules
i tried to leave releavent info but it is late so hopefully my locker combination or show size number isnt included in the code
CODE Begining:
all u have to do is copy this and paste it into wordpad i think it will re-align:
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glaux.h>
//Booleans
int fullscreen; //fullscreen?
int fullscreenflag = 0;
int active = 0; //active??
//Globals
HWND hWnd; //handle for program window
HGLRC hRC; //opengl rendering context
HDC hDC; //window device context
void DrawScene() // This function draws our 3D scene.
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//glRotatef(45.0f, 1.0f, 0.0f, 0.0f);
glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 0.0f); //top right
glVertex3f(0.8f, 1.0f, 0.0f); //top left
glVertex3f(0.8f, 0.8f, 0.0f); //bottom left
glVertex3f(1.0f, 0.8f, 0.0f); //bottom right
glEnd();
}
int InitGL(int Width, int Height, unsigned char bits)
{
PIXELFORMATDESCRIPTOR pfd; //pixel structure
GLuint PixelFormat; //index for pixel structure
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //screen clearing color
glClearDepth(1.0); // Enable clearing of the depth buffer
glDepthFunc(GL_LEQUAL); // The kind of depth testing to do.
glEnable(GL_DEPTH_TEST); // Enable it
// Set the matrix mode, so the next commands are on the Projection Matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat) Width / (GLfloat) Height,
0.1f, 100.0f);
// Now switch to the Model View Matrix.
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 16;
pfd.cDepthBits = 16;
pfd.dwLayerMask = PFD_MAIN_PLANE;
PixelFormat = ChoosePixelFormat(hDC, &pfd);
if(!PixelFormat) {
MessageBox(NULL, "Could not find suitable pixel format",
"Pixel Format Error", MB_OK);
return 0;
}
if(!SetPixelFormat(hDC, PixelFormat, &pfd)) {
MessageBox(NULL, "Can't set the pixel format",
"Pixel Format Error", MB_OK);
return 0;
}
hRC = wglCreateContext(hDC); // Get a render context from our DC
if(!hRC) {
MessageBox(NULL, "Can't create render context.", "Render Context Error",
MB_OK);
return 0;
}
if(!wglMakeCurrent(hDC, hRC)) { // Make this render context the current one.
MessageBox(NULL, "Can't set active render context.",
"Render Context Error", MB_OK);
return 0;
}
//Change video mode display settings
if (fullscreen) // Attempt Fullscreen Mode?
{
DEVMODE dmScreenSettings; // Device Mode
memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory’s Cleared
dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure
dmScreenSettings.dmPelsWidth = Width; // Selected Screen Width
dmScreenSettings.dmPelsHeight = Height; // Selected Screen Height
dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
{
// If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode.
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By
Your Video Card. Use Windowed Mode Instead?",“Error”,MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
{
fullscreen=FALSE; // Windowed Mode Selected. Fullscreen = FALSE
}
else
{
// Pop Up A Message Box Letting User Know The Program Is Closing.
MessageBox(NULL,“Program Will Now Close.”,“ERROR”,MB_OK|MB_ICONSTOP);
return 0;
}
}
fullscreenflag = 1;
}
active = 1;
return 1;
}
void ShutDown()
{
if (fullscreenflag) { // Are We In Fullscreen Mode?
ChangeDisplaySettings(NULL,0); // If So Switch Back To The Desktop
ShowCursor(TRUE); // Show Mouse Pointer
fullscreenflag = 0; //no longer physically fullscreen
}
if (hRC) {
if (!wglMakeCurrent(NULL,NULL)) { // Are We Able To Release The DC And RC Contexts?
MessageBox(NULL,“Release Of DC And RC Failed.”,“SHUTDOWN ERROR”,MB_OK | MB_ICONINFORMATION);
}
if (!wglDeleteContext(hRC)) { // Are We Able To Delete The RC?
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
hRC=NULL; // Set RC To NULL
}
if (hDC && !ReleaseDC(hWnd,hDC)) { // Are We Able To Release The DC
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hDC=NULL; // Set DC To NULL
}
if (hWnd && !DestroyWindow(hWnd)) { // Are We Able To Destroy The Window?
MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hWnd=NULL; // Set hWnd To NULL
}
}
void ResizeGLWindow(int Width, int Height)
{
if(!Height) return;
glViewport(0, 0, Width, Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, Width / (GLfloat) Height, 0.1f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
return;
}
LRESULT CALLBACK WinProc(HWND hWnd, UINT uintMessage,
WPARAM par1, LPARAM par2)
{
switch (uintMessage) {
case WM_CLOSE:
PostQuitMessage(0);
break;
case WM_ACTIVATE: // Watch For Window Activate Message
if (!HIWORD(par1)) { // Check Minimization State
active=1;
}
else {
active=0;
}
break;
case WM_KEYDOWN:
if (par1 == VK_ESCAPE)
PostQuitMessage(0);
break;
case WM_SIZE: // Resize The OpenGL Window
ResizeGLWindow(LOWORD(par2),HIWORD(par2)); // LoWord=Width, HiWord=Height
break;
default:
return DefWindowProc(hWnd, uintMessage, par1, par2);
}
return 0;
}
int Win32Ini(HINSTANCE hInstance, int iCmdShow, int Width, int Height)
{
WNDCLASSEX wcx;
DWORD dwExStyle; // Window Extended Style
DWORD dwStyle; // Window Style
//next define windws attributes
wcx.cbSize = sizeof(wcx);
wcx.style = CS_HREDRAW | CS_VREDRAW;
wcx.lpfnWndProc = WinProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = hInstance;
wcx.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
wcx.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wcx.hCursor = LoadCursor(NULL,IDC_ARROW);
wcx.hbrBackground = NULL;
wcx.lpszMenuName = NULL;
wcx.lpszClassName = "class name";
if(!RegisterClassEx(&wcx))
return 0;
if (fullscreen) // Are We Still In Fullscreen Mode?
{
dwExStyle=WS_EX_APPWINDOW; // Window Extended Style
dwStyle=WS_POPUP; // Windows Style
ShowCursor(FALSE); // Hide Mouse Pointer
}
else
{
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
dwStyle=WS_OVERLAPPEDWINDOW; // Windows Style
}
// Create The Window
if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window
"class name", // Class Name
"Yair's Opengl Stuff |-)-<=<", // Window Title
dwStyle | // Defined Window Style
WS_CLIPSIBLINGS | // Required Window Style
WS_CLIPCHILDREN, // Required Window Style
0, 0, // Window Position
Width, Height, // Selected Width And Height
NULL, // No Parent Window
NULL, // No Menu
hInstance, // Instance
NULL))) // Dont Pass Anything To WM_CREATE
{
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return 0;
}
ShowWindow(hWnd,iCmdShow); //default window display method(mini,max,hidden)
ResizeGLWindow(Width, Height);
// UpdateWindow(hWnd); //send a WM_PAINT
hDC = GetDC(hWnd);
if (!hDC) {
MessageBox(NULL, “Unable to allocate a DC”,“error”, MB_OK);
return 0;
}
return 1; //All is well
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR sCmdLine, int iCmdShow)
{
MSG msg;
if (MessageBox(NULL, "Would you like to view the program in full screen(recomended)?", "Query", MB_YESNO) ==IDYES)
fullscreen = true;
else
fullscreen = false;
if (Win32Ini(hInstance, iCmdShow, 640, 480) == 0) {
ShutDown();
return 0;
}
if (!InitGL(640, 480, 16)) {
ShutDown();
return 0;
}
while(1) {
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { // Is There A Message Waiting?
if (msg.message==WM_QUIT) { // Have We Received A Quit Message?
goto ShutDown; // If So done=TRUE
}
else { // If Not, Deal With Window Messages
TranslateMessage(&msg); // Translate The Message
DispatchMessage(&msg); // Dispatch The Message
}
}
else if (active) {
DrawScene();
SwapBuffers(hDC);
}
}
ShutDown:;
ShutDown();
return msg.wParam; //return windows termination code
}
The end hopefully somone is patient enough to help me cause i am going insane with my unsuccesful coding