MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / initgl

Function initgl

Source/SysGL/HLEGraphics/RendererGL.cpp:89–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87static u32 gColorBuffer[kMaxVertices];
88
89bool initgl()
90{
91 DAEDALUS_ASSERT(gN64FramentLibrary == NULL, "Already initialised");
92
93 // FIXME(strmnnrmn): need a nicer 'load file' utility function.
94 {
95 IO::Filename shader_path;
96 IO::Path::Combine(shader_path, gDaedalusExePath, "n64.psh");
97
98 FILE * fh = fopen(shader_path, "r");
99 if (!fh)
100 {
101 DAEDALUS_ERROR("Couldn't load shader source %s", shader_path);
102 fprintf(stderr, "ERROR: couldn't load shader source %s\n", shader_path);
103 return false;
104 }
105
106 fseek(fh, 0, SEEK_END);
107 size_t l = ftell(fh);
108 fseek(fh, 0, SEEK_SET);
109 char * p = (char *)malloc(l+1);
110 fread(p, l, 1, fh);
111 p[l] = 0;
112 fclose(fh);
113
114 gN64FramentLibrary = p;
115 }
116
117 // Only do software emulation of mirror_s/mirror_t if we're not doing accurate UV handling
118 gRDPStateManager.SetEmulateMirror(!gAccurateUVPipe);
119
120 // FIXME(strmnnrmn): we shouldn't need these with GLEW, but they don't seem to resolve on OSX.
121 GLboolean status = GL_TRUE;
122 RESOLVE_GL_FCN(PFN_glGenVertexArrays, pglGenVertexArrays, "glGenVertexArrays");
123 RESOLVE_GL_FCN(PFN_glDeleteVertexArrays, pglDeleteVertexArrays, "glDeleteVertexArrays");
124 RESOLVE_GL_FCN(PFN_glBindVertexArray, pglBindVertexArray, "glBindVertexArray");
125
126 pglGenVertexArrays(1, &gVAO);
127 pglBindVertexArray(gVAO);
128
129 glGenBuffers(kNumBuffers, gVBOs);
130
131 glBindBuffer(GL_ARRAY_BUFFER, gVBOs[kPositionBuffer]);
132 glBufferData(GL_ARRAY_BUFFER, sizeof(gPositionBuffer), gPositionBuffer, GL_DYNAMIC_DRAW);
133
134 glBindBuffer(GL_ARRAY_BUFFER, gVBOs[kTexCoordBuffer]);
135 glBufferData(GL_ARRAY_BUFFER, sizeof(gTexCoordBuffer), gTexCoordBuffer, GL_DYNAMIC_DRAW);
136
137 glBindBuffer(GL_ARRAY_BUFFER, gVBOs[kColorBuffer]);
138 glBufferData(GL_ARRAY_BUFFER, sizeof(gColorBuffer), gColorBuffer, GL_DYNAMIC_DRAW);
139 return true;
140}
141
142
143void sceGuFog(f32 mn, f32 mx, u32 col)

Callers 1

InitialiseMethod · 0.85

Calls 2

SetEmulateMirrorMethod · 0.80
CombineFunction · 0.50

Tested by

no test coverage detected