Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About chilun

  • Rank
  1. thanks very much. I'll look into this
  2. Hi;   I have this code in openGL, which works, but I would like to eliminate the glbegin and glend to meet OpenGL ES standards. Can anyone out there assist me on figuring out how to do this? Thanks   #include "painter.hpp" #include "GL/glut.h" void Painter::bar(int x1, int y1, int x2, int y2) {   glColor3f(0, 1, 0);   glBegin(GL_QUADS);   glVertex2f(x1, y1);   glVertex2f(x2, y1);   glVertex2f(x2, y2);   glVertex2f(x1, y2);   glEnd(); } void Painter::circle(int x, int y, int radius) {   glColor3f(1, 0, 0);   glBegin(GL_POLYGON);   glVertex2f(x + radius, y);   glVertex2f(x, y + radius);   glVertex2f(x - radius, y);    glVertex2f(x, y - radius);   glEnd(); }  
  3. Thank you very much. There is an alternative using the GlutBitmapCharacter function so I will test to see if this works with my existing code instead.
  4. Hi;   I'm trying to write some code into my existing game project to write some text to the window. I've modified the sample code to plug into project. The output function assigns element in the text string to an individual char in order to pass to the display function (subsequently output to the screen). It compiles, but I don't see any text written to the window. Does anyone know how I can fix this?   void output(GLfloat x, GLfloat y, char* text) {     glPushMatrix();     glTranslatef(x, y, 0);     glScalef(1/152.38, 1/152.38, 1/152.38);     for( char* p = text; *p; p++)     {         glutStrokeCharacter(GLUT_STROKE_ROMAN, *p);     }     glPopMatrix(); } void display() {   glClear(GL_COLOR_BUFFER_BIT);   Painter p;   game.draw(p);      //write text to screen   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);   glEnable(GL_BLEND);   glEnable(GL_LINE_SMOOTH);   glLineWidth(2.0);   output(400,200,"hello");      glutSwapBuffers(); }  
  5. Thank you very much for the links. I'll take a closer look at these
  6. Hi;   I'm looking to have a background picture set on my opengl window, but I don't know where to begin. Is there a specific picture format I should use and most importantly, are there any examples I can take a look at?   Thank you
  7. Hi Goran;   I'll definitely try what you suggested and will come back to you with a response.   Thank you very much indeed :)
  8. Hi all;   I have some trouble with trying to use the glOrtho function to scale some graphics to a window (height - 500, width - 500). I've created a function called reshape to do this, but for some reason I think my numbers are off as the graphics are scaling to the size I would like, but for some reason it is only scaling into the top-left hand corner of the window - I want to make sure that the scaling fills the entire size of the window. Can anyone provide any tips on what I can do?   Thank you ...void reshape(int w, int h) { glViewport(0,0, w, h); GLfloat aspect = (GLfloat)w / (GLfloat) h; glMatrixMode (GL_PROJECTION); glLoadIdentity(); glOrtho(0.0f, w, h, 0.0f, 0.0f, 1.0f); } ... int main (int argc, char **argv) { ... glutInitWindowSize(500, 500); glutReshapeFunc(reshape); ... }
  9. Hi all;   I'm looking for help on how to output some text to my window using the built-in 'TextOut' function in VS2010. I've read a few examples on how to feed hdc and hwnd into another variable before then feeding that variable to TextOut - write to screen. I've tried to test this in a test cpp file, but I'm unable to get this working. Can someone help me out with a basic example on how to do this using TextOut as opposed to using functions from an imported library such as GLUT? I'm new to C++ graphics programming so please bear with me.   Thank you and I look forward to any responses. Chilun       
  10. I've figured this out... Split the conditional statement into 2 in order to handle with the paddle - wall contact (prevent the paddle flying off) and also modified the maxVelocity value to 500.0f.  This now works for me    Thanks everyone for your help. Chilun   ...   sf::Vector2f pos = this->GetPosition();   // MAKE SURE PADDLE DOESN'T DISAPPEAR OFF INTO SPACE WHEN IT REACHES THE WINDOW BOUNDARY (LEFT AND RIGHT SIDE) if(pos.x  < GetSprite().GetSize().x/2) { this->SetPosition(GetSprite().GetSize().x/2, this->GetPosition().y); } if(pos.x > (Game::SCREEN_WIDTH - GetSprite().GetSize().x/2)){ this->SetPosition(Game::SCREEN_WIDTH - GetSprite().GetSize().x/2, this->GetPosition().y); }
  11. Hi Serapth;   Thank you for your response. I think once the game initially loads, its loads up fine, but after a few seconds - either the AI or the player paddle seems to fly off into eternity. Would you know why this is the case? I've change the speed of the player paddle to 500.0f so that the movement of the paddle from left to right (vice versa) is smoother, upon releasing the key, the velocity resets back to 0 - otherwise the paddle becomes uncontrollable. Essentially, if I continue to hold the left or right key continuously, the paddle with just disappear out of the window and there is currently no checking to see if this is the case, reset the paddle back at the bottom of the screen.   Thanks very much. Chilun
  12. Hi Paradigm Shifter;   Its quite a strange one - most of the logic is either in the Ball or PlayerPaddle cpp files. The tutorial I followed (http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition-Part-7.aspx) goes into depth regarding the speed of the ball and the origin of where the ball came from would determine the angle of how the ball will deflect off either the AIPaddle or the left/right wall. Sadly the person who wrote the tutorial didn't finish off what he started so I'm scratching my head as to how I could finish this off. I will try to bash out some code that would do the boundary checking. Thanks for your help   
  13. Hi all;   I'm looking to implement some basic collision detection for my pong game. I followed a few basic tutorials on how to create all the classes to write a pong game - I now have a somewhat playable version of the game, which I've flipped the view so instead of the traditional horizontal position, you play in a vertical position so the player paddle is at the bottom of the window and the AI paddle is at the top. I've attached all the files necessary for everything to work. I'm thinking about adding some sort of check in the 'PlayerPaddle' to detect whether the paddle has touched the window boundary on either side and if this has been detected, don't allow the paddle to continue to move out of the window into oblivion.   I'm sure there are experts who know exactly what the problem is and how to remedy this problem. I'm pulling my hair out as this is my last major problem to sort out. I'd like to thank anyone in advance for providing on help on this conundrum. For some reason I can't attach cpp and header files so I've included the following link to all the files:   https://www.dropbox.com/sh/cr04j36vleat56y/sCTKdg0XVH   Any help or advice will be greatly appreciated.   Chilun    
  • 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!