Jump to content
  • Advertisement

Bluseed

Member
  • Content Count

    86
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Bluseed

  • Rank
    Member
  1. Bluseed

    glGetString

    how do you go about creating a render context??
  2. Bluseed

    glGetString

    im trying to display wether or not im using software rendering or hardware rendering, i think im using software i updated my nvidia drivers and progz are still going slow.. Im trying to use the glGetstring to get my the vendor. char *Vendor = (char*)::glGetString(GL_VENDOR); glPrint("Vendor - %s ", Vendor); It just outputs (null) Where else within my code can i see if its in software mode??
  3. Bluseed

    text game

    Quote: (S)He only THINKS he has the necessary knowledge to make a simple text-based game and you want font-shaking?! Haha! Remind me never to work for you :p LOL yah its too much for a text based game but I was only givn an example(bad example, ok lol), yes that is far out there and overkill.
  4. I am Using VC++ Express 2005, and have a prog that i've just made that when i build and run within VC runs. But when i try to execute the exe it tells me "Initailization falied", Well, it runs when i Start without debugging, and comes up with no errors or warnings! What could i do to get my exe to initialize, im trying to send the prog in a zip file to a friend so we can work together on it, and he cant even run iot within VC......
  5. Bluseed

    text game

    Just like Vopisk said: Quote: Of course, you could always circumvent the string header/usage entirely and just use string literals, but I always like to think towards future expansion and storing things as string variables will allow greater flexibility in the long run. As ur going through your text based adventure game, think of, and create things that kinda go further then just a text based game, really challenge the language and use it to your advantage... i.e when you come to a scene in your gam, like when the army starts rushing into Narshe(Final Fantasy3/6 village), as the player is typing in the input have the text shake like an earthquake to give the player a feeling of being in Narshe. I know thats a challenge, lol, but your learning how to do things within the C++ enviroment. Do crazy things to advance your knowledge...
  6. Bluseed

    Sleep!!

    DArookie!! I think your on to something, what exactly would be a solution?? **edit*** It makes perfect sense Darookie, the Swapbuffers is in a loop thats outside of the rendering call right after the GLSceneDraw rendering call in the loop (make sense?) I've even tried putting the sleep(what have you) after the render call(GLScene Draw, and it still doesnt work!!!! **edit*** check this out, i dont know of any better way to show u fully but heres the source... #include <windows.h> // Header File For Windows #include <gl\gl.h> // Header File For The OpenGL32 Library #include <gl\glu.h> // Header File For The GLu32 Library #include <gl\glaux.h> // Header File For The Glaux Library #include <string> #include <time.h> #include <stdio.h> // Header File For Standard Input/Output #include <math.h> HDC hDC=NULL; // Private GDI Device Context HGLRC hRC=NULL; // Permanent Rendering Context HWND hWnd=NULL; // Holds Our Window Handle HINSTANCE hInstance; // Holds The Instance Of The Application bool keys[256]; // Array Used For The Keyboard Routine bool active=TRUE; // Window Active Flag Set To TRUE By Default bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default bool light; // Lighting ON/OFF bool lp = true; // L Pressed? bool fp; // F Pressed? bool blnBallX; bool blnBallY; bool blnPaddleUp; //Is Paddle moving up bool blnPaddleDown; //Is Paddle moving down bool blnPaddleUp2; //Is Paddle moving up bool blnPaddleDown2; //Is Paddle moving down bool blnRestart; bool blnMoveBall = true; float PI = 3.14159f; struct Sphere { float x; float y; float xv; float yv; }; Sphere Ball; float BallAngle; float Speed; float Distance; float Distance2; bool blnCollide; bool blnCollide2; //Text GLuint base; // Base Display List For The Font Set //Sphere GLUquadricObj *quadratic; // Storage For Our Quadratic Objects ( NEW ) // Absolute value function(comes in handy later). inline GLfloat ABS(GLfloat A) { if (A < 0) A = -A; return A; } float BallAng = 0.001f; float PaddleX = -6.2f; float PaddleY = 0.0f; float PaddleX2 = 7.9f; float PaddleY2 = 0.0f; float MinPaddleY; float MaxPaddleY; float MinPaddleY2; float MaxPaddleY2; float CollisionDist = 0.0f; float Dist; float Dist2; float Xrot = 1.0f; int Player1Score = 0; int Player2Score = 0; int Score = 1; int Score2 = 1; //Light GLfloat LightAmbient[]= { 2.0f, 2.0f, 2.0f, 1.0f }; GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat LightPosition[]= { 0.0f, 0.0f, 0.0f, 1.0f }; //Textures GLuint filter = 0; // Which Filter To Use GLuint texture[11]; // Storage For 3 Textures GLuint loop; // Generic Loop Variable LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc GLvoid BuildFont(GLvoid) // Build Our Bitmap Font { HFONT font; // Windows Font ID HFONT oldfont; // Used For Good House Keeping base = glGenLists(96); // Storage For 96 Characters font = CreateFont( -12, // Height Of Font 0, // Width Of Font 0, // Angle Of Escapement 0, // Orientation Angle 0, // Font Weight FALSE, // Italic FALSE, // Underline FALSE, // Strikeout ANSI_CHARSET, // Character Set Identifier OUT_TT_PRECIS, // Output Precision CLIP_DEFAULT_PRECIS, // Clipping Precision ANTIALIASED_QUALITY, // Output Quality FF_DONTCARE|DEFAULT_PITCH, // Family And Pitch "Arial"); // Font Name oldfont = (HFONT)SelectObject(hDC, font); // Selects The Font We Want wglUseFontBitmaps(hDC, 32, 96, base); // Builds 96 Characters Starting At Character 32 SelectObject(hDC, oldfont); // Selects The Font We Want DeleteObject(font); // Delete The Font } GLvoid KillFont(GLvoid) // Delete The Font List { glDeleteLists(base, 96); // Delete All 96 Characters } GLvoid glPrint(const char *fmt, ...) // Custom GL "Print" Routine { char text[256]; // Holds Our String va_list ap; // Pointer To List Of Arguments if (fmt == NULL) // If There's No Text return; // Do Nothing va_start(ap, fmt); // Parses The String For Variables vsprintf(text, fmt, ap); // And Converts Symbols To Actual Numbers va_end(ap); // Results Are Stored In Text glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits glListBase(base - 32); // Sets The Base Character to 32 glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text glPopAttrib(); // Pops The Display List Bits } AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image { FILE *File=NULL; // File Handle if (!Filename) // Make Sure A Filename Was Given { return NULL; // If Not Return NULL } File=fopen(Filename,"r"); // Check To See If The File Exists if (File) // Does The File Exist? { fclose(File); // Close The Handle return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer } return NULL; // If Load Failed Return NULL } int LoadGLTextures() // Load Bitmaps And Convert To Textures { int Status=FALSE; // Status Indicator AUX_RGBImageRec *TextureImage[11]; // Create Storage Space For The Textures memset(TextureImage,0,sizeof(void *)*11); // Set The Pointer To NULL if ((TextureImage[0]=LoadBMP("Data/Crate.bmp")) && // Logo Texture (TextureImage[1]=LoadBMP("Data/Number00.bmp")) && (TextureImage[2]=LoadBMP("Data/Number01.bmp")) && (TextureImage[3]=LoadBMP("Data/Number02.bmp")) && (TextureImage[4]=LoadBMP("Data/Number03.bmp")) && (TextureImage[5]=LoadBMP("Data/Number04.bmp")) && (TextureImage[6]=LoadBMP("Data/Number05.bmp")) && (TextureImage[7]=LoadBMP("Data/Number06.bmp")) && (TextureImage[8]=LoadBMP("Data/Number07.bmp")) && (TextureImage[9]=LoadBMP("Data/Number08.bmp")) && (TextureImage[10]=LoadBMP("Data/Number09.bmp"))) { Status=TRUE; // Set The Status To TRUE glGenTextures(11, &texture[0]); // Create 2 Textures for (loop=0; loop<11; loop++) // Loop Through All 5 Textures { glBindTexture(GL_TEXTURE_2D, texture[loop]); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[loop]->sizeX, TextureImage[loop]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[loop]->data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); } } for (loop=0; loop<11; loop++) // Loop Through All 5 Textures { if (TextureImage[loop]) // If Texture Exists { if (TextureImage[loop]->data) // If Texture Image Exists { free(TextureImage[loop]->data); // Free The Texture Image Memory } free(TextureImage[loop]); // Free The Image Structure } } return Status; // Return The Status } GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window { if (height==0) // Prevent A Divide By Zero By { height=1; // Making Height Equal One } glViewport(0,0,width,height); // Reset The Current Viewport glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix // Calculate The Aspect Ratio Of The Window gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix } int InitGL(GLvoid) // All Setup For OpenGL Goes Here { if (!LoadGLTextures()) // Jump To Texture Loading Routine { return FALSE; // If Texture Didn't Load Return FALSE } glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations //Lights glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light glEnable(GL_LIGHT1); // Enable Light One //Quadric Sphere quadratic=gluNewQuadric(); // Create A Pointer To The Quadric Object (Return 0 If No Memory) (NEW) gluQuadricNormals(quadratic, GLU_SMOOTH); // Create Smooth Normals (NEW) gluQuadricTexture(quadratic, GL_TRUE); // Create Texture Coords (NEW) BuildFont(); return TRUE; // Initialization Went OK } bool Collide(float Obj1X, float Obj1Y, float Obj2X, float Obj2Y) { Distance = pow(Obj2X - Obj1X,2) + pow(Obj2Y - Obj1Y,2); float sqrtf(Distance); if (Distance < 1.0f) { blnCollide = true; } else { blnCollide = false; } return blnCollide; } bool Collide2(float Obj1X, float Obj1Y, float Obj2X, float Obj2Y) { Distance2 = pow(Obj2X - Obj1X,2) + pow(Obj2Y - Obj1Y,2); float sqrtf(Distance2); if (Distance2 < 2.0f) { blnCollide2 = true; } else { blnCollide2 = false; } return blnCollide2; } void RestartGame() { { Ball.x = 0.0f; Ball.y = 0.0f; } Sleep(1000); //blnMoveBall = false; //blnRestart = true; //Random Ball Angle } int moveBall() { if (BallAngle > 360) { BallAngle = 0; } if (BallAngle < 0) { BallAngle = 360; } if (Ball.y < -5.8f) { blnBallY = true; } if (Ball.y > 5.8f) { blnBallY = false; } if (blnBallX == true) { ++Xrot; Ball.x += cosf(BallAngle * PI / 180) * Ball.xv / Speed; } if (blnBallX == false) { --Xrot; Ball.x -= cosf(BallAngle * PI / 180) * Ball.xv / Speed; } if (blnBallY == true) { Ball.y += sinf(BallAngle * PI / 180.0f) * Ball.yv / Speed; //Ball.y += Ball.yv; } if (blnBallY == false) { Ball.y -= sinf(BallAngle * PI / 180.0f) * Ball.yv / Speed; //Ball.y -= Ball.yv; } MinPaddleY = PaddleY - 1.5f; MaxPaddleY = PaddleY + 1.5f; MinPaddleY2 = PaddleY2 - 1.5f; MaxPaddleY2 = PaddleY2 + 1.5f; Dist = (Ball.x - PaddleX) - 1.0f; Dist2 = (Ball.x - PaddleX2); if (blnCollide == true) { //Paddle1 Physx(LOL) if (blnPaddleUp == true && blnBallY == true) { Ball.xv += 1.5f; Ball.yv = +10.0f; blnBallX = true; } else { blnBallX = true; } if (blnPaddleUp == true && blnBallY == false) { Ball.yv = +2.5f; blnBallX = true; } else { blnBallX = true; } if (blnPaddleDown == true && blnBallY == true) { Ball.yv = +2.5f; blnBallX = true; } else { blnBallX = true; } if (blnPaddleDown == true && blnBallY == false) { Ball.xv += 1.5f; Ball.yv = +10.0f; blnBallX = true; } else { blnBallX = true; } } if (blnCollide2 == true) { //Paddle2 Physx(LOL) if (blnPaddleUp2 == true && blnBallY == true) { Ball.xv += 1.5f; Ball.yv = +10.0f; blnBallX = false; } else { blnBallX = false; } if (blnPaddleUp2 == true && blnBallY == false) { Ball.yv = -0.5f; blnBallX = false; } else { blnBallX = false; } if (blnPaddleDown2 == true && blnBallY == true) { Ball.yv = -0.5f; blnBallX = false; } else { blnBallX = false; } if (blnPaddleDown2 == true && blnBallY == false) { Ball.xv += 1.5f; Ball.yv = +10.0f; blnBallX = false; } else { blnBallX = false; } } if (Ball.xv > 2.5f) { Ball.xv -= 0.001f; } if (Ball.xv < 1.0f) { Ball.xv += 0.001f; } if (Ball.xv > 6.5f) { Ball.xv = 6.5f; } if (Ball.yv > 2.5f) { Ball.yv -= 0.001f; } if (Ball.yv < 1.0f) { Ball.yv += 0.001f; } if (Ball.yv > 10.5f) { Ball.yv = 10.5f; } if (Ball.x < -9.0f) { Player2Score += 1; Score += 1; if (Score2 > 9) { Score2 = 1; } //Ball.x = 0.0f; //Ball.y = 0.0f; //blnMoveBall = false; //blnRestart = true; RestartGame(); blnBallX = true; } if (Ball.x > 9.0f) { Player1Score += 1; Score2 += 1; if (Score2 > 9) { Score2 = 1; } //RestartGame(); blnBallX = false; } return 0; } int EnemyAI() { if (Ball.x > 1.0) { if (PaddleY2 < Ball.y)// && PaddleY2 != BallY) { PaddleY2 += 0.009f ; } if (PaddleY2 > Ball.y)// && PaddleY2 != BallY) { PaddleY2 -= 0.009f ; } } return 0; } void NewGame() { //Reset Game-New Game Ball.x = 0.0f; Ball.y = 0.0f; PaddleY = 0.0f; PaddleY2 = 0.0f; Player1Score = 0; Player2Score = 0; } int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glLoadIdentity(); //Texture glBindTexture(GL_TEXTURE_2D, texture[filter]); //Sphere glTranslatef(Ball.x,Ball.y,-15.0f); glRotatef(Xrot,0.0f,0.0f,1.0f); gluSphere(quadratic,0.5,32,32); // Draw A Sphere With A Radius Of 1 And 16 Longitude And 16 Latitude Segments glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(PaddleX,PaddleY,-15.0f); glBegin(GL_QUADS); // Front Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.7f, -1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.7f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Right Face glNormal3f( 1.0f, 0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( -0.7f, -1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( -0.7f, 1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( -0.7f, 1.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( -0.7f, -1.0f, 1.0f); // Top Face glNormal3f( 0.0f, 1.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.9f, 1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.9f, 1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.7f, 1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.7f, 1.0f, -1.0f); // Bottom Face glNormal3f( 0.0f,-1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.7f, -1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.7f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glEnd(); glLoadIdentity(); glTranslatef(PaddleX2,PaddleY2,-15.0f); glBegin(GL_QUADS); // Front Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.7f, -1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.7f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Right Face glNormal3f( 1.0f, 0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( -1.0f, -1.0f, -1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( -1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( -1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( -1.0f, -1.0f, 1.0f); // Top Face glNormal3f( 0.0f, 1.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-0.7f, 1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-0.7f, 1.0f, -1.0f); // Bottom Face glNormal3f( 0.0f,-1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.7f, -1.0f, -1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.7f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glEnd(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //EndTexture glBindTexture(GL_TEXTURE_2D, 0); //Texture2 glBindTexture(GL_TEXTURE_2D, texture[Score]); glTranslatef(-4.0f,-2.5f,-10.0f); glBegin(GL_QUADS); // Front Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glEnd(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glBindTexture(GL_TEXTURE_2D, 0); //Texture3 glBindTexture(GL_TEXTURE_2D, texture[Score2]); glTranslatef(4.0f,-2.5f,-10.0f); glBegin(GL_QUADS); // Front Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glEnd(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glBindTexture(GL_TEXTURE_2D, 0); //Text glColor3f(1.0f,1.0f,1.0f); glTranslatef(-8.1f,5.6f,-15.0f); glRasterPos2f(0.0f, 0.0f); glPrint("SphereX - %f SphereY - %f ", Ball.x ,Ball.y); // Print GL Text To The Screen glLoadIdentity(); //Text glColor3f(1.0f,1.0f,1.0f); glTranslatef(-8.1f,5.3f,-15.0f); glRasterPos2f(0.0f, 0.0f); glPrint("Player1 - %d Player2 - %d ", Player1Score ,Player2Score); // Print GL Text To The Screen glLoadIdentity(); //Text glColor3f(1.0f,1.0f,0.0f); glTranslatef(-8.1f,5.0f,-15.0f); glRasterPos2f(0.0f, 0.0f); glPrint("Distance - %f Distance - %f blnCollide - %d", Distance, Distance2, blnBallY); glLoadIdentity(); //Text glColor3f(0.3f,0.3f,1.0f); glTranslatef(-8.1f,4.7f,-15.0f); glRasterPos2f(0.0f, 0.0f); glPrint("XVelocity - %f YVelocity - %f", Ball.xv, Ball.yv); glColor3f(1.0f,1.0f,1.0f); glLoadIdentity(); if (blnCollide == true || blnCollide2 == true) { glLoadIdentity(); //Text glColor3f(1.0f,1.0f,1.0f); glTranslatef(-8.1f,4.4f,-15.0f); glRasterPos2f(0.0f, 0.0f); glPrint("Collision Detected"); } EnemyAI(); if (blnMoveBall == true) { moveBall(); blnRestart = false; } if (blnRestart == true) { blnMoveBall = true; blnRestart = false; } Collide(PaddleX - 1.0f,PaddleY,Ball.x,Ball.y); Collide2(PaddleX2,PaddleY2,Ball.x,Ball.y); return TRUE; // Everything Went OK } GLvoid KillGLWindow(GLvoid) // Properly Kill The Window { gluDeleteQuadric(quadratic); if (fullscreen) // Are We In Fullscreen Mode? { ChangeDisplaySettings(NULL,0); // If So Switch Back To The Desktop ShowCursor(TRUE); // Show Mouse Pointer } if (hRC) // Do We Have A Rendering Context? { if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts? { MessageBox(NULL,"Release Of DC And RC Failed.","Exit",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 } if (!UnregisterClass("OpenGL",hInstance)) // Are We Able To Unregister Class { MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hInstance=NULL; // Set hInstance To NULL } } BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag) { GLuint PixelFormat; // Holds The Results After Searching For A Match WNDCLASS wc; // Windows Class Structure DWORD dwExStyle; // Window Extended Style DWORD dwStyle; // Window Style RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values WindowRect.left=(long)0; // Set Left Value To 0 WindowRect.right=(long)width; // Set Right Value To Requested Width WindowRect.top=(long)0; // Set Top Value To 0 WindowRect.bottom=(long)height; // Set Bottom Value To Requested Height fullscreen=fullscreenflag; // Set The Global Fullscreen Flag hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window. wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc Handles Messages wc.cbClsExtra = 0; // No Extra Window Data wc.cbWndExtra = 0; // No Extra Window Data wc.hInstance = hInstance; // Set The Instance wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer wc.hbrBackground = NULL; // No Background Required For GL wc.lpszMenuName = NULL; // We Don't Want A Menu wc.lpszClassName = "OpenGL"; // Set The Class Name if (!RegisterClass(&wc)) // Attempt To Register The Window Class { MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } 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\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",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 FALSE; // Return FALSE } } } 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 } AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size // Create The Window if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window "OpenGL", // Class Name title, // Window Title dwStyle | // Defined Window Style WS_CLIPSIBLINGS | // Required Window Style WS_CLIPCHILDREN, // Required Window Style 0, 0, // Window Position WindowRect.right-WindowRect.left, // Calculate Window Width WindowRect.bottom-WindowRect.top, // Calculate Window Height NULL, // No Parent Window NULL, // No Menu hInstance, // Instance NULL))) // Dont Pass Anything To WM_CREATE { KillGLWindow(); // Reset The Display MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format bits, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 16, // 16Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; if (!(hDC=GetDC(hWnd))) // Did We Get A Device Context? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if (!(hRC=wglCreateContext(hDC))) // Are We Able To Get A Rendering Context? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if(!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } ShowWindow(hWnd,SW_SHOW); // Show The Window SetForegroundWindow(hWnd); // Slightly Higher Priority SetFocus(hWnd); // Sets Keyboard Focus To The Window ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen if (!InitGL()) // Initialize Our Newly Created GL Window { KillGLWindow(); // Reset The Display MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } return TRUE; // Success } LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window UINT uMsg, // Message For This Window WPARAM wParam, // Additional Message Information LPARAM lParam) // Additional Message Information { switch (uMsg) // Check For Windows Messages { case WM_ACTIVATE: // Watch For Window Activate Message { if (!HIWORD(wParam)) // Check Minimization State { active=TRUE; // Program Is Active } else { active=FALSE; // Program Is No Longer Active } return 0; // Return To The Message Loop } case WM_SYSCOMMAND: // Intercept System Commands { switch (wParam) // Check System Calls { case SC_SCREENSAVE: // Screensaver Trying To Start? case SC_MONITORPOWER: // Monitor Trying To Enter Powersave? return 0; // Prevent From Happening } break; // Exit } case WM_CLOSE: // Did We Receive A Close Message? { PostQuitMessage(0); // Send A Quit Message return 0; // Jump Back } case WM_KEYDOWN: // Is A Key Being Held Down? { keys[wParam] = TRUE; // If So, Mark It As TRUE return 0; // Jump Back } case WM_KEYUP: // Has A Key Been Released? { keys[wParam] = FALSE; // If So, Mark It As FALSE return 0; // Jump Back } case WM_SIZE: // Resize The OpenGL Window { ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height return 0; // Jump Back } } // Pass All Unhandled Messages To DefWindowProc return DefWindowProc(hWnd,uMsg,wParam,lParam); } int WINAPI WinMain( HINSTANCE hInstance, // Instance HINSTANCE hPrevInstance, // Previous Instance LPSTR lpCmdLine, // Command Line Parameters int nCmdShow) // Window Show State { MSG msg; // Windows Message Structure BOOL done=FALSE; // Bool Variable To Exit Loop // Ask The User Which Screen Mode They Prefer /*if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO) { fullscreen=FALSE; // Windowed Mode }*/ fullscreen=FALSE; // Create Our OpenGL Window if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen)) { return 0; // Quit If Window Was Not Created } //initialize some variables Speed = 60.0f; Ball.xv = 2.5f; Ball.yv = 2.5f; BallAngle = 20.0f; while(!done) // Loop That Runs While done=FALSE { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting? { if (msg.message==WM_QUIT) // Have We Received A Quit Message? { done=TRUE; // If So done=TRUE } else // If Not, Deal With Window Messages { TranslateMessage(&msg); // Translate The Message DispatchMessage(&msg); // Dispatch The Message } } else // If There Are No Messages { // Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene() if (active) // Program Active? { if (keys[VK_ESCAPE]) // Was ESC Pressed? { done=TRUE; // ESC Signalled A Quit } else // Not Time To Quit, Update Screen { // Draw The Scene DrawGLScene(); SwapBuffers(hDC); // Swap Buffers (Double Buffering) } } if (keys['L'] && !lp) { lp=TRUE; light=!light; if (!light) { glDisable(GL_LIGHTING); } else { glEnable(GL_LIGHTING); } } if (!keys['L']) { lp=FALSE; } if (keys[VK_UP]) { blnPaddleUp = true; PaddleY += 0.2f; if (PaddleY > 5.2f) { PaddleY = 5.19f; } } if (!keys[VK_UP]) { blnPaddleUp = false; } if (keys[VK_DOWN]) { blnPaddleDown = true; PaddleY -= 0.2f; if (PaddleY < -5.2f) { PaddleY = -5.19f; } } if (!keys[VK_DOWN]) { blnPaddleDown = false; } if (keys[VK_LEFT]) { } if (keys[VK_RIGHT]) { } if (keys['F'] && !fp) { fp=TRUE; filter+=1; if (filter>11) { filter=0; } } if (!keys['F']) { fp=FALSE; } if (keys['A']) { //Ball.yv += 0.001f; BallAngle += 0.01f; } if (keys['D']) { //Ball.x += 0.03f; BallAngle -= 0.01f; } if (keys['W']) { blnPaddleUp2 = true; PaddleY2 += 0.1f; if (PaddleY2 > 5.2f) { PaddleY2 = 5.19f; } } if (!keys['W']) { blnPaddleUp2 = false; } if (keys['S']) { blnPaddleDown2 = true; PaddleY2 -= 0.1f; if (PaddleY2 < -5.2f) { PaddleY2 = -5.19f; } } if (!keys['S']) { blnPaddleDown2 = false; } if (keys[VK_F1]) // Is F1 Being Pressed? { keys[VK_F1]=FALSE; // If So Make Key FALSE KillGLWindow(); // Kill Our Current Window fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode // Recreate Our OpenGL Window if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen)) { return 0; // Quit If Window Was Not Created } } } } // Shutdown KillGLWindow(); // Kill The Window return (msg.wParam); // Exit The Program }
  7. Bluseed

    Slow Opengl

    No more warranty... :(
  8. Bluseed

    text game

    o ok correction!! lol even better...
  9. Bluseed

    text game

    Hey bro, Devcpp is cool but i just want to spread some luv, and give you a good link. VC8 Its only free for a limited time.... I guess i would suggest just doing a text game offline since you dont know where to start, i dont what to say besides thats the most easiest thing a coder can do(i think) Where you should start? Its a text based game, you can start anywhere really, start on the classes that hold your items, or weapons and armor, and character info. I dont know anybody who actually writes everything out on as a rough draft, unless they're doing a MUD(Something really big) A text based adventure doesnt sound too much fun to code, i ve done one myself, and the way i did it was: * 1.) Created my Classes , with just writing a few variables within them.. i.e. Items, Weapons Armor, Charcters, NPC's, Relics, Messages. * 2.) Started the story i.e Welcome to EpicDragons Enter your name blah blah blah You are in the middle of the Asrhobi Shrine, where you see 2 faires, a Scroll hanging on a fountain glittering of Gold and many colors, Pouring out water as clear as an opaque puke covered windshield!!(LOL) Input Selection Player 1 - Talk to faire 1 2- Talk to faire 2 3 - read scroll 4 - puke on faire 5 - Walk south 6 - Walk north 7 - Attack Fairie 8 - Open Treasure chest * 3.)Then i would goto my classes and add in an item to put in the treasure chest So you see just go along and fill in the blanks i hope thathelps..... I f ya need anyhelp just let me know im actually willing to revise what i know!!!
  10. Bluseed

    text game

    Hey bro, Devcpp is cool but i just want to spread some luv, and give you a good link.
  11. Bluseed

    OpenGL and 2D

    Okay so i just read a post and it said that if you turn the screen sorta say into an orthagraphic view, then openGL would be good to use for coding a 2D enviroment. Question: Are you suppose to put your images on a... //Texture2 glBindTexture(GL_TEXTURE_2D, texture[Score]); glTranslatef(-4.0f,-2.5f,-10.0f); glBegin(GL_QUADS); // Front Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, -1.0f, 1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glEnd(); coz thats the only way i know how to display an image on the screen.. Is there a Blit function or something i dont know about? Maybe i dont know what im talking about, but imagine doing a tile engine using that????
  12. Im telling you get rid of the old and install the new!!! Visual C++ 2005 Express Edition Hurry i think they only have 50 more copies available for download...!!! lol
  13. Bluseed

    Sprite Tutorial

    I agree with rob!!! Directx period is a pain in the ass. I can give you a DX9 project that opens a window and an OpenGL project that opens a window and i think i know what API you would choose. OpenGL is so much easier since your saying programming isnt coming to you too well. It takes a huge amount of code just to set up a window compared to OpenGL which is nmothing, and which should be. I love DX and OpenGL, I think it just takes a little more effort for DX, thats not bad, but I switched to OpenGL because i can find a lot of more resources fot it. I'll go back to it one day, until then imma figure out OpenGL. But before you trash your dx book make sure that its not a compiling or linking error. What language are you using besides DX i.e. C++, VB, C# etc...
  14. Bluseed

    I just can't understand C++

    I've self-taught myself by looking at MILLIONS of tutorials and Websites, some books but i need too. Even today its hard for me to figure something out, but i eventually do, and these forums are a huge help. Just stick in there and keep throwing the ball until you make a basket, keep doing it and you'll eventually get better. What i did, and still do is download somebody elses program and play with the variables and add things the way they did, you know, just play around with everything and see what happens, i actually think thats the best way to learn, coz you can always look at something they've coded and compare it to some other code and see what the difference is, and yet being able to understand how it works. It can get very frustrating at times, but i cant say that there was one time that i got stuck and never found it out. I always find crap out when i stick on it and look for answers. After looking at something for so long, you automatically memorize it, well i should say that for the most part you will. Repetition will help you so dont give up and keep looking and asking questions. I promise you'll get it....
  15. Bluseed

    Slow Opengl

    Well its a crappy MadFX5500 i think, and just all of a sudden the fan stopped!!!! I let it cool down for a couple of days and now it makes a nasty scraping clunking sound like the fans gettn ate up by the metal but everything looks fine, i dont know, but it doesnt function. Ummm and I just regularly installed opengl i guess i installed the software drivers, whatever it came with to install so.....probably. Is there anything i can do. Im hella far on my pong prog and i cant put any more images in the prog without the comp slowing down a great deal...
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!