⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 opengl.cpp

📁 我对他如何控制准星、显示敌友很好奇
💻 CPP
字号:
// 
// Online Game Cheats Client.dll hook
// Copyright (c) system   2001-2002
// Copyright (c) bunny771 2001-2002
// 
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// 
// NOTE:
// GNU license doesn't cover Engine directory.
// Content of Engine directory is copyrighted (c) 1999, 2000, by Valve LLC
// and it is licensed under Valve's proprietary license (see original HL SDK).
// 

#define  WIN32_LEAN_AND_MEAN
#include <windows.h>

#include "cvar.h"
#include "client.h"
#include <gl/gl.h>

#include <map>
#include <string>
using namespace std;
#include "hookqueue.h"

// color stuff
#include <vector>
#include "stringfinder.h"
#include "color.h"

// logging
#include <fstream>


typedef void (APIENTRY *Tgl1ui) (unsigned int);
typedef void (APIENTRY *Tgl3f)( float , float , float );
typedef void (APIENTRY *Tgl4f)( float , float , float , float );
typedef void (APIENTRY *Tgl2ui) (unsigned int, unsigned int);
typedef void (APIENTRY *TglTexEnvi) (unsigned int, unsigned int, int);
typedef void (APIENTRY *Tglvui) (unsigned int,float*);
typedef void (APIENTRY *xglViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
typedef BOOL (APIENTRY *xwglSwapBuffers) (HDC);
typedef void (APIENTRY *xglBlendFunc) (GLenum sfactor, GLenum dfactor);
typedef void (APIENTRY *xglColor4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
typedef void (APIENTRY *xglLineWidth) (GLfloat width);
typedef void (APIENTRY *TglRectiFunc) (GLint x, GLint y, GLint x2, GLint y2);

extern hookinfo glBlendFuncInfo   ;
extern hookinfo glBeginInfo       ;
extern hookinfo glVertex3fInfo    ;
extern hookinfo glDisableInfo     ;
extern hookinfo glEnableInfo      ;
extern hookinfo glColor3fInfo     ;
extern hookinfo glTexEnviInfo     ;
extern hookinfo glPolygonModeInfo ;
extern hookinfo glClearColorInfo  ;
extern hookinfo glClearInfo       ;
extern hookinfo glGetFloatvInfo   ;
extern hookinfo glViewportInfo    ;
extern hookinfo glColor4fInfo     ;
extern hookinfo glLineWidthInfo   ;
extern hookinfo glRectiInfo       ;


//========================================================================================
void opengl_ClearBackground()
{
	if(glClearColorInfo.oldfunc && glClearInfo.oldfunc)
	{
		ColorEntry* color = colorList.get(10);
		float r = float(color->r)/255.0f;
		float g = float(color->g)/255.0f;
		float b = float(color->b)/255.0f;
		float a = float(color->a)/255.0f;
		(*(Tgl4f )(glClearColorInfo.oldfunc))(r,g,b,a);
		(*(Tgl1ui)(glClearInfo     .oldfunc))(GL_COLOR_BUFFER_BIT);
	}
}



//========================================================================================
bool oglSubtractive = false;
extern hookinfo glBlendFuncInfo;
void APIENTRY pglBlendFunc(GLenum sfactor, GLenum dfactor)
{
	if(oglSubtractive)  (*(xglBlendFunc)(glBlendFuncInfo.oldfunc))(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	else                (*(xglBlendFunc)(glBlendFuncInfo.oldfunc))(sfactor, dfactor);
}

extern bool bIsHooked;

//========================================================================================
void APIENTRY pglBegin(unsigned int mode)
{
	if(!bIsHooked) { (*(Tgl1ui)(glBeginInfo.oldfunc))(mode); return; }

	switch (cvar.wall) 
	{ 
	case 1: 	
		if (mode == GL_TRIANGLE_STRIP || mode == GL_TRIANGLE_FAN) 
		{
			(*(Tgl1ui)(glDisableInfo.oldfunc))(GL_DEPTH_TEST);
		}
		break;
	case 2:
		if (mode != GL_TRIANGLE_STRIP && mode != GL_TRIANGLE_FAN)
		{
			float curcolor[4];
			(*(Tglvui)(glGetFloatvInfo.oldfunc      ))(GL_CURRENT_COLOR, curcolor);
			(*(Tgl1ui)(glDisableInfo.oldfunc        ))(GL_DEPTH_TEST);
			(*(Tgl1ui)(glEnableInfo .oldfunc        ))(GL_BLEND);
			(*(xglBlendFunc)(glBlendFuncInfo.oldfunc))(GL_SRC_ALPHA, GL_ONE);
			(*(Tgl4f )(glColor4fInfo.oldfunc        ))(curcolor[0], curcolor[1], curcolor[2], colorList.get(10)->onebased_a );
		}
		break;
		
	}
	
	switch (cvar.glextra)
	{
	case 0:break;
	case 1:
		if(mode != GL_TRIANGLES && mode != GL_TRIANGLE_STRIP  && mode != GL_TRIANGLE_FAN  && mode != GL_QUADS) 
		{
			(*(TglTexEnvi)(glTexEnviInfo .oldfunc ))(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
		}
		break;
	case 2:
		if(mode != GL_TRIANGLES && mode != GL_TRIANGLE_STRIP  && mode != GL_TRIANGLE_FAN  && mode != GL_QUADS) 
		{
			(*(TglTexEnvi)(glTexEnviInfo .oldfunc ))(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
		}
		break;
	case 3:
		if(mode == GL_POLYGON)
		{
			ColorEntry* c = colorList.get(14);
			(*(Tgl3f )(glColor3fInfo        .oldfunc ))( c->onebased_r, c->onebased_g, c->onebased_b);
			(*(Tgl2ui)(glPolygonModeInfo    .oldfunc ))(GL_FRONT_AND_BACK, GL_LINE);
			(*(xglLineWidth)(glLineWidthInfo.oldfunc ))(2);
		}
		else 
		{
			(*(Tgl2ui)(glPolygonModeInfo.oldfunc ))(GL_FRONT_AND_BACK, GL_FILL);
		}
		break;
	}  

	
	if(cvar.nosky)
	{
		//if(mode==GL_QUADS)
		//{
		//	float curcolor[4];
		//	(*(Tglvui)(glGetFloatvInfo.oldfunc))(GL_CURRENT_COLOR, curcolor);
		//	if(curcolor[0] == 1 && curcolor[1] == 1 && curcolor[2] == 1)
		//	{
		//		//float texCoords[10];
		//		//(*(Tglvui)(glGetFloatvInfo.oldfunc))(GL_CURRENT_TEXTURE_COORDS, texCoords);
		//		//
		//		//if(texCoords[6] > 512 || texCoords[7] > 512)
		//		//{
		//			mode = 0;
		//		//}
		//	}
		//} 
	}
	
	(*(Tgl1ui)(glBeginInfo.oldfunc))(mode);
}

//========================================================================================
void APIENTRY pglVertex3f( float x, float y, float z) 
{
	if (cvar.lambert && bIsHooked)
	{ 
		ColorEntry* c = colorList.get(15);
		(*(Tgl3f )(glColor3fInfo    .oldfunc ))( c->onebased_r, c->onebased_g, c->onebased_b);
	}
	(*(Tgl3f)(glVertex3fInfo.oldfunc))(x, y, z);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -