Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Learning opengl from mu online.

Joined
Mar 13, 2008
Messages
758
Reaction score
1,002
Well i was decompiling some function where draw effects or image via opengl functions is very old,but well is for learn..
at this moment i just have 2 functions

DrawImage and DrawEffect?

well here have the source code to know how draw image or some effects in muonline

Code:
void CINTERFACE::DrawImage(int InterFaceId,float PosX,float PosY,float Width,float Height,float StartX,float StartY,float ScaleTextureX,float ScaleTextureY)
{
 
glPushMatrix(); //push a matrix para que no gire toda la pantalla solo el objeto


float x = float(*(WORD*)0x6105F8)*PosX*0.001562500f; //0x6105F8  = Screen width
float y = float(*(WORD*)0x6105FC)*PosY*0.002083333;//0x6105FC  = Screen height
float widthy = float(*(WORD*)0x6105FC)-y;
pSetTexture(InterFaceId); //set texture image



CVector2 cVec[4];
cVec[0].X = x;
cVec[0].Y = widthy;


cVec[1].X = x;
cVec[1].Y = widthy-Height;


cVec[2].X = x+Width;
cVec[2].Y = widthy-Height;


cVec[3].X = x+Width;
cVec[3].Y = widthy;


CVector2 cVecTexture[4];
cVecTexture[0].X = StartX;
cVecTexture[0].Y = StartY;


cVecTexture[1].X = StartX;
cVecTexture[1].Y = ScaleTextureY+StartY;


cVecTexture[2].X = ScaleTextureX+StartX;
cVecTexture[2].Y = ScaleTextureY+StartY;


cVecTexture[3].X = ScaleTextureX+StartX;
cVecTexture[3].Y = StartY;


glBegin(GL_TRIANGLE_FAN);


for(int i = 0; i<4;i++)
{
glTexCoord2f(cVecTexture[i].X,cVecTexture[i].Y);
glVertex2f(cVec[i].X,cVec[i].Y);
}


glEnd();
glPopMatrix();
}

Code:
void SetTextureCoord(CVector2* TextureCoor,float CoorX,float CoorY)
{
TextureCoor->X = CoorX;
TextureCoor->Y = CoorY;
}


void SetVertex(CVector3 *lpVertex, CVector3 *a2)
{
   float PosX = lpVertex->X * 0.017453292;
   float PosY = lpVertex->Y * 0.017453292;
  float PosZ = lpVertex->Z * 0.017453292;


  a2->X = cos(PosY) * cos(PosZ);
  a2->Y = cos(PosY) * sin(PosZ);
  a2->Z = -sin(PosY);


  a2[1].X = 0;
  a2[1].Y = (sin(PosX) * sin(PosY) ) * cos(PosZ) - cos(PosX) * sin(PosZ);
  a2[1].Z =  (sin(PosX) * sin(PosY) ) * sin(PosZ) + cos(PosX) * cos(PosZ);
  
  a2[2].X = sin(PosX) * cos(PosY);
  a2[2].Y = 0;
  a2[2].Z = (cos(PosX) * sin(PosY)) * cos(PosZ) + sin(PosX) * sin(PosZ);
 
  a2[3].X = (cos(PosX) * sin(PosY)) *  sin(PosZ) - sin(PosX) * cos(PosZ);
  a2[3].Y =  cos(PosX) * cos(PosY);
  a2[3].Z = 0;
}


void SetVertextCoor(CVector3 *Size, CVector3 *a2, CVector3 *lpVertex)
{


  lpVertex->X = a2->Y * Size->Y + a2->Z * Size->Z + Size->X * a2->X;
  lpVertex->Y = a2[1].Y * Size->X + a2[1].Z * Size->Y + a2[2].X * Size->Z;
  lpVertex->Z = a2[2].Z * Size->X + a2[3].X * Size->Y + a2[3].Y * Size->Z;
  return;
}

//Draw effect in select character when a character is selected.
void COPENGL::DrawEffect(int EffectId,CVector3 * lpPosition,float Size,float Width, float Height,float a6,float a7,float a8)
{
  pSetTexture(EffectId); //set texture


  CVector3 Color3f[4];


  Color3f[0].X = 1.0f;
  Color3f[0].Y = 1.0f;
  Color3f[0].Z = 1.0f;


  Color3f[1].X = 1.0f;
  Color3f[1].Y = 1.0f;
  Color3f[1].Z = 1.0f;


  Color3f[2].X = a7;
  Color3f[2].Y = a7;
  Color3f[2].Z = a7;


  Color3f[3].X = a7;
  Color3f[3].Y = a7;
  Color3f[3].Z = a7;


  CVector2 TextureCoor[4];


 for(float x = 0; x<12;x++)
 {
 
    float CoorX = x * 0.083333336;
    SetTextureCoord(&TextureCoor[0], CoorX, 1.0f);
   CoorX = (x+1.0f) * 0.083333336;
    SetTextureCoord(&TextureCoor[1], CoorX, 1.0f);
    SetTextureCoord(&TextureCoor[2], CoorX, 0);
CoorX = x * 0.083333336;
    SetTextureCoord(&TextureCoor[3], CoorX, 0);
CVector3 cVector;
CVector3 Vertex3f[4];
cVector.X = 0;
cVector.Y = 0;
cVector.Z = x*30.0f+a6;
    SetVertex(&cVector, &Vertex3f[0]);
    cVector.Z = (x+1.0f) * 30.0 + a6;
CVector3 Vertex3f2[4];
    SetVertex(&cVector, &Vertex3f2[0]);


CVector3 vsize;
vsize.X = 0;
vsize.Y = Size;
vsize.Z = 0;
   
CVector3 cVertextCoor[4];


    SetVertextCoor(&vsize, &Vertex3f[0], &cVertextCoor[0]);
    cVertextCoor[0].X = cVertextCoor[0].X + lpPosition->X;
cVertextCoor[0].Y = cVertextCoor[0].Y + lpPosition->Y;
cVertextCoor[0].Z = cVertextCoor[0].Z + lpPosition->Z;
vsize.X = 0;
    vsize.Y = Size;
vsize.Z = 0.0;
    SetVertextCoor(&vsize, &Vertex3f2[0], &cVertextCoor[1]);
cVertextCoor[1].X = cVertextCoor[1].X + lpPosition->X;
cVertextCoor[1].Y = cVertextCoor[1].Y + lpPosition->Y;
cVertextCoor[1].Z = cVertextCoor[1].Z + lpPosition->Z;
    
vsize.X = 0;
    vsize.Y = Width;
vsize.Z = Height;
    SetVertextCoor(&vsize, &Vertex3f2[0], &cVertextCoor[2]);


cVertextCoor[2].X = cVertextCoor[2].X + lpPosition->X;
cVertextCoor[2].Y = cVertextCoor[2].Y + lpPosition->Y;
cVertextCoor[2].Z = cVertextCoor[2].Z + lpPosition->Z;
 
    vsize.X = 0;
    vsize.Y = Width;
vsize.Z = Height;


    SetVertextCoor(&vsize, &Vertex3f[0], &cVertextCoor[3]);
    cVertextCoor[3].X = cVertextCoor[3].X + lpPosition->X;
cVertextCoor[3].Y = cVertextCoor[3].Y + lpPosition->Y;
cVertextCoor[3].Z = cVertextCoor[2].Z + lpPosition->Z;
  glBegin(GL_QUADS);
   for(int i = 0;i<4;i++)
   {
   glBegin(GL_QUADS);
      glTexCoord2f(TextureCoor[i].X, TextureCoor[i].Y+a8);
      glColor3fv((GLfloat*)&Color3f[i]);
      glVertex3fv((GLfloat *)&cVertextCoor[i]);
     
    }
    glEnd();
  }


}

Code:
//used to draw hp bar or line simples

void CINTERFACE::DrawVector(float PosX,float PosY,float Width,float Height)
{

float NewPosX = float(*(WORD*)0x6105F8)*PosX*0.001562500f;
float NewPosY = float(*(WORD*)0x6105FC)*PosY*0.0020833334f;
float widthy = float(*(WORD*)0x6105FC)-NewPosY;

sub_5B12D0(0);


CVector2 cVec[4];
cVec[0].X = NewPosX;
cVec[0].Y = widthy;


cVec[1].X = NewPosX;
cVec[1].Y = widthy-Height;


cVec[2].X = NewPosX+Width;
cVec[2].Y = widthy-Height;


cVec[3].X = NewPosX+Width;
cVec[3].Y = widthy;


glBegin(GL_TRIANGLE_FAN);


for(int i = 0; i<4;i++)
{
glVertex2f(cVec[i].X,cVec[i].Y);
}
glEnd();

}
 
Last edited:
Skilled Illusionist
Joined
Jun 22, 2017
Messages
363
Reaction score
557
and you can check IGC source for code draw text.
 
Initiate Mage
Joined
Nov 6, 2016
Messages
42
Reaction score
14
and you can check IGC source for code draw text.

How ? Because when i execute :
g_Font[ARIAL_14]->DrawColor(300, 400, RGBA(255, 255, 255, 255), "test" );
I m not seeing the test at 300x400.
 
Back
Top