Posts: 21
Threads: 5
Joined: Feb 2014
Reputation:
0
10-30-2014, 01:10 PM
Hi,
recently I got interest in emulation. I was lurking rpcs3 source code on github. There was a gl renderer.
https://github.com/DHrpcs3/rpcs3/blob/master/GL/glext.h
I look at them. It was full of macro with specific addresses and function prototypes. What are they actually? For example: look at this line.
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
Now it says, whenever I say "GL_UNSIGNED_SHORT_4_4_4_4", it is equal to an address of "0x8033". But what is in that address?
Posts: 11
Threads: 0
Joined: Mar 2014
Reputation:
0
10-30-2014, 01:23 PM
(This post was last modified: 10-30-2014, 01:24 PM by Ashe.)
It's not an address, it's a simple numeric constant (basically it's an enum).
(btw: that header is not an OpenGL renderer, and your question is more about basic C than emulation)
Posts: 21
Threads: 5
Joined: Feb 2014
Reputation:
0
what will we do with those enumerations? Also there are a whole bunch of function prototype, so those are enumeration too?
Is it because, we want to call some gl function(which will be executed by gpu driver) or we want to use some data structures, but we do not want to type lengthy names, so we define them as enums; and we just use those enums in stead of big lengthy names??
Posts: 107
Threads: 0
Joined: Feb 2014
Reputation:
5
10-30-2014, 02:49 PM
(This post was last modified: 10-30-2014, 02:59 PM by Bigpet.)
The reason for the constant definitions is easy to show. Just look at this without the constant aliases
glTexImage2D( 0x0DE1 , 0, 0x8051, 512, 512, 0, 0x1907, 0x1401, data)
and with the constant definitions:
glTexImage2D(GL_TEXTURE_2D , 0, GL_RGB8, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, data)
The function prototypes are there for the same reason they're in any header, so that you can use them and link against something that implements them.
The thing with the OpenGL extensions is just that they are loaded at runtime in some implementations because you can't know at link-time which extensions are available on all system you will be running on.
Anyway, this has nothing to do with rpcs3 specifically and we did not manually write the glext.h header (it's from the official opengl site https://www.opengl.org/registry/api/GL/glext.h ).
Posts: 993
Threads: 12
Joined: Jul 2014
Reputation:
17
You just made me notice that they are kinda old, submited a pull request for the updated OpenGL 4.5 specification file.
Posts: 21
Threads: 5
Joined: Feb 2014
Reputation:
0
(10-30-2014, 02:49 PM)Bigpet Wrote: The reason for the constant definitions is easy to show. Just look at this without the constant aliases
glTexImage2D( 0x0DE1 , 0, 0x8051, 512, 512, 0, 0x1907, 0x1401, data)
and with the constant definitions:
glTexImage2D(GL_TEXTURE_2D , 0, GL_RGB8, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, data)
The function prototypes are there for the same reason they're in any header, so that you can use them and link against something that implements them.
The thing with the OpenGL extensions is just that they are loaded at runtime in some implementations because you can't know at link-time which extensions are available on all system you will be running on.
Anyway, this has nothing to do with rpcs3 specifically and we did not manually write the glext.h header (it's from the official opengl site https://www.opengl.org/registry/api/GL/glext.h ). Why can't we use
glTexImage2D( a , 0, b, 512, 512, 0, c, d, data)
in stead of,
glTexImage2D( 0x0DE1 , 0, 0x8051, 512, 512, 0, 0x1907, 0x1401, data)
, This saved us more typing!
Personally, for me, this is more human friendly:
glTexImage2D(GL_TEXTURE_2D , 0, GL_RGB8, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, data)
May be you guys are more robot than human, lol So you use this:
glTexImage2D( 0x0DE1 , 0, 0x8051, 512, 512, 0, 0x1907, 0x1401, data)
in stead of,
glTexImage2D(GL_TEXTURE_2D , 0, GL_RGB8, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, data)
this.
Posts: 107
Threads: 0
Joined: Feb 2014
Reputation:
5
(10-30-2014, 03:28 PM)gamenoob Wrote: Personally, for me, this is more human friendly That is the point
Posts: 21
Threads: 5
Joined: Feb 2014
Reputation:
0
|