This is Google's cache of http://www.gamedeception.net/archive/index.php?t-53.html. It is a snapshot of the page as it appeared on Aug 11, 2013 03:40:20 GMT. The current page could have changed in the meantime. Learn more
Tip: To quickly find your search term on this page, press Ctrl+F or ⌘-F (Mac) and use the find bar.

Text-only version
 
OpenGL Code Sanction. [Archive] - GameDeception - A Development Site for Reverse Engineering

View Full Version : OpenGL Code Sanction.



Azorbix
11-30-2002, 08:35 PM
I created this thread to help other/newer coders put nice features into their OpenGL hacks, and I also dont have any ideas for my hack, so I created this thread to share ideas and source code...


Simple OpenGL Zoom...


void sys_glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
{
if(zoom && GetAsyncKeyState(VK_CONTROL))
{
int zoom_lvl = 30;
top = zNear * tan(zoom_lvl * 3.1428571428571428571428571428571 / 360.0);
bottom = -top;
left = bottom * 1.3333333333333333333333333333333;
right = top * 1.3333333333333333333333333333333;
}

(*orig_glFrustum) (left, right, bottom, top, zNear, zFar);
}

Simple WireFrame Mode...

if(wireframe)
{
if(mode == GL_POLYGON)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor3f(0.2f, 0.9f, 0.2f);
}
if(mode != GL_POLYGON)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
}

If your going to use code from this thread, please post something in return, dont be a bum!

Crusader
11-30-2002, 09:01 PM
Very simple winamp control:

#include <windows.h>
const int AMP_PREVSONG = 40044;
const int AMP_PLAY = 40045;
const int AMP_PAUSE = 40046;
const int AMP_STOP = 40047;
const int AMP_NEXTSONG = 40048;
HWND AMP_HANDLE;

void WinAmpInit()
{
AMP_HANDLE = FindWindow ("Winamp v1.x", NULL);
}

void WinAmpCommand (int command)
{
if (AMP_HANDLE)
{
switch(command)
{
case 0: //play
SendMessage (AMP_HANDLE, WM_COMMAND, AMP_PLAY, 0);
return;
case 1: //stop
SendMessage (AMP_HANDLE, WM_COMMAND, AMP_STOP, 0);
return;
case 2: //pause
SendMessage (AMP_HANDLE, WM_COMMAND, AMP_PAUSE, 0);
return;
case 3: // prev song
SendMessage (AMP_HANDLE, WM_COMMAND, AMP_PREVSONG, 0);
return;
case 4: //next song
SendMessage (AMP_HANDLE, WM_COMMAND, AMP_NEXTSONG, 0);
return;
}
}
}

int WinAmpState()
{
return SendMessage(AMP_HANDLE,WM_USER, 0, 104);
}

v0id
12-11-2002, 12:26 PM
Your supposed to be helping others learn how to use opengl with languages such as c++, pasting code will get them no where, i suggest a text instruction :)

Azorbix
12-11-2002, 09:06 PM
maybe your right... Oh well! Too late now, keep um comming!

smn
12-11-2002, 09:55 PM
code helps me alot, it SHOWS me how its used and dosent just TELL me.

Gna
12-25-2002, 01:50 PM
what about some code for q3?

Gna
12-25-2002, 01:51 PM
i trying to make q3 hack but i´v tried many ways and allways are some walls transparent this sucks wanna see only models hacked

alias
12-25-2002, 02:54 PM
tested FlameGLv0.2? maybe some of it works? then find me on #flamegl and we will try and fix the bits that dont? juts an idea


alias

Gna
12-25-2002, 04:40 PM
#flamegl and server? quakenet?

Crusader
12-25-2002, 04:50 PM
irc.rizenet.org

Banana
03-31-2003, 06:01 AM
Everybody was crying out for this so ill release it:
Snake Game from OGC converted to be used with any platform by changing just two lines:

(was to large to be copied-and-pasted here)
_-¯ D'load ¯-_ (http://home.arcor.de/banana_pwnz_me/files/snake_game_src.zip)

e]v[pty`
03-31-2003, 01:40 PM
omf! i just added snake last week!

:(

lol i changed a lot more than 2 lines :eek: :D

Banana
04-02-2003, 04:29 AM
I modified it so you just have to change 2 lines...

gfreeman1
04-03-2003, 06:12 PM
Not sure if this is really useful or not, but i got sick of not being able to use black with pfnFillRGBA, so i wrote a small opengl function to do so:



void glFillRGBA(GLfloat x, GLfloat y, int w, int h, int r, int g, int b, int a)
{
glDisable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
float fr = (float)r/255.0f;
float fg = (float)g/255.0f;
float fb = (float)b/255.0f;
float fa = (float)a/255.0f;
glColor4f(fr,fg,fb,fa);
glBegin(GL_QUADS);
glVertex2f(x,y);
glVertex2f(x+w,y);
glVertex2f(x+w,y+h);
glVertex2f(x,y+h);
glEnd();
glDisable(GL_BLEND);
}


example:

glFillRGBA(100,100,10,10,0.0f,0.0f,0.0f,0.5f);

draws a 50% transparent black box at 100,100 with width and height of 10

SuperDave
04-09-2003, 05:58 PM
With what gfreeman1 posted you could have pure openGL OGC like command menu that is edited out of game instead having to compile a new one everytime you add something. You would need a cvar base structure (this is not hard to do). So this is indeed very useful gfreeman1.

Xero
04-10-2003, 07:56 PM
Originally posted by v0id
Your supposed to be helping others learn how to use opengl with languages such as c++, pasting code will get them no where, i suggest a text instruction :)

In that case they should learn C++ first then come back here and read the code. if you know C++ all u need is code with maybe minor explanation.

Xero
04-10-2003, 07:59 PM
Originally posted by gfreeman1
Not sure if this is really useful or not, but i got sick of not being able to use black with pfnFillRGBA, so i wrote a small opengl function to do so:



void glFillRGBA(GLfloat x, GLfloat y, int w, int h, int r, int g, int b, ...
...
}

draws a 50% transparent black box at 100,100 with width and height of 10

Kinda cheap, I wrote a whole graphics engine for doing things like this for my hack, including making 3D button like boxes, image drawing from tgas and bmps, bitmap fonts, etc.
-Xero

Azorbix
04-10-2003, 08:31 PM
lol, I bet you did write a graphics engine...

Which means, you didnt use OpenGL or Direct3D at all to do your drawing.

DllMain
04-10-2003, 08:32 PM
You know you are bored WHEN...

edit: omfg new status! IM LOYAL!!!1111

jawzweb
12-04-2003, 05:37 PM
You need to re-enable GL_TEXTURE_2D in that glFillRGBA function otherwise nothing else is going to be drawn. :(

Just stick glEnable(GL_TEXTURE_2D); after you re-disable the blending.

amateur
12-06-2003, 04:10 PM
better to get the status of the function and restore it only if needed once its done drawing your function.

VisualPerfection
12-06-2003, 09:42 PM
Originally posted by Azorbix
lol, I bet you did write a graphics engine...

Which means, you didnt use OpenGL or Direct3D at all to do your drawing.
Dude an engine HANDLES the drawing it doesn't necessarily push the polygons to the card.... A graphicsengine utilizes graphics api's such as GL/D3D....

Azorbix
12-06-2003, 10:01 PM
ok man, this thread is like 8 months old...

newbie101
04-06-2004, 10:37 PM
Originally posted by Azorbix
ok man, this thread is like 8 months old...

but usefull!

r00tg04t
07-10-2004, 03:20 AM
yeah almoust dud

o({})o
09-17-2004, 09:45 PM
As long as someone brought this thread back, I might as well post something useful in it again....



bool bLambert = false;
bool bKeyDown = false;

void sys_glColor3f (GLfloat red, GLfloat green, GLfloat blue)
{
if (bLambert && red <= 0.1f && green <= 0.1f && blue <= 0.1f)
{
(*orig_glColor3f) (1.0f, 1.0f, 1.0f);
}
else
{
(*orig_glColor3f) (red, green, blue);
}
}

void sys_glViewport (GLint x, GLint y, GLsizei width, GLsizei height)
{
if(GetAsyncKeyState(VK_F1) < 0 && !bKeyDown)
{
bLambert = !bLambert;

bKeyDown = true;
}
else if(!(GetAsyncKeyState(VK_F1) < 0))
{
bKeyDown = false;
}

(*orig_glViewport) (x, y, width, height);
}


This type of lambert is only active when something is in the dark.... Some lambert hacks are just poorly done fullbrights unfortunately. I tried this in single player HL, and it works there, no idea if you can even still use it online in any HL mod :x....

btw- it is cool to watch something walk into the dark with this on since it will light up different parts of the model as it moves into the shadow :P.... I don't remember why I use those comparisons, or if they are even needed, but I am too lazy to check >_<

De-Sire
09-17-2004, 09:52 PM
Pretty creative concept hebe :square-ey

BiGmAc
09-18-2004, 04:48 AM
you should make a fader, so the darker the place, the brighter the player =)

o({})o
09-18-2004, 02:24 PM
Did you test the code I posted? It essentially does that... but, now that I think of it, I think that is cool idea :P... I gonna try it out.... should only be a small change like this or something:



void sys_glColor3f (GLfloat red, GLfloat green, GLfloat blue)
{
if (bLambert && red <= 0.1f && green <= 0.1f && blue <= 0.1f)
{
(*orig_glColor3f) (1.0f - red, 1.0f - green, 1.0f - blue);
}
else
{
(*orig_glColor3f) (red, green, blue);
}
}

hrm... didn't work.... I gonna check it out a bit more >_<

Also, I tested without the comparisons, makes no difference. I guess hl engine only use glColor3f to draw shadows, so no use testing for anything else? hrm, whatever :P