Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


chilun

Member Since 10 Oct 2013
Offline Last Active Nov 29 2013 12:09 PM

Topics I've Started

C++ OPENGL help wanted to port glbegin and end

01 November 2013 - 07:50 AM

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();
}

 


opengl glutstrokecharacter - write text to screen

29 October 2013 - 07:46 AM

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();
}

 


opengl help wanted to set background picture

28 October 2013 - 05:53 PM

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


glortho function - assistance required...

25 October 2013 - 03:50 AM

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);
...
}

How to use Textout to output variable value in C++

14 October 2013 - 03:54 AM

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 

 

 

 


PARTNERS