Bug Summary

File:/home/anal/dolphin-emu/Source/Core/VideoBackends/Software/Src/SWRenderer.cpp
Location:line 118, column 3
Description:Value stored to 'p' is never read

Annotated Source Code

1// Copyright 2013 Dolphin Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include "Common.h"
6#include <math.h>
7
8#include "../../OGL/Src/GLUtil.h"
9#include "RasterFont.h"
10#include "SWRenderer.h"
11#include "SWStatistics.h"
12
13#include "OnScreenDisplay.h"
14
15static GLuint s_RenderTarget = 0;
16
17static GLint attr_pos = -1, attr_tex = -1;
18static GLint uni_tex = -1;
19static GLuint program;
20
21// Rasterfont isn't compatible with GLES
22// degasus: I think it does, but I can't test it
23#ifndef USE_GLES
24RasterFont* s_pfont = NULL__null;
25#endif
26
27void SWRenderer::Init()
28{
29}
30
31void SWRenderer::Shutdown()
32{
33 glDeleteProgram__glewDeleteProgram(program);
34 glDeleteTextures(1, &s_RenderTarget);
35#ifndef USE_GLES
36 delete s_pfont;
37 s_pfont = 0;
38#endif
39}
40
41void CreateShaders()
42{
43 static const char *fragShaderText =
44 "varying " PREC " vec2 TexCoordOut;\n"
45 "uniform sampler2D Texture;\n"
46 "void main() {\n"
47 " " PREC " vec4 tmpcolor;\n"
48 " tmpcolor = texture2D(Texture, TexCoordOut);\n"
49 " gl_FragColor = tmpcolor;\n"
50 "}\n";
51 static const char *vertShaderText =
52 "attribute vec4 pos;\n"
53 "attribute vec2 TexCoordIn;\n "
54 "varying vec2 TexCoordOut;\n "
55 "void main() {\n"
56 " gl_Position = pos;\n"
57 " TexCoordOut = TexCoordIn;\n"
58 "}\n";
59
60 program = OpenGL_CompileProgram(vertShaderText, fragShaderText);
61
62 glUseProgram__glewUseProgram(program);
63
64 uni_tex = glGetUniformLocation__glewGetUniformLocation(program, "Texture");
65 attr_pos = glGetAttribLocation__glewGetAttribLocation(program, "pos");
66 attr_tex = glGetAttribLocation__glewGetAttribLocation(program, "TexCoordIn");
67}
68
69void SWRenderer::Prepare()
70{
71 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
72 glPixelStorei(GL_UNPACK_ALIGNMENT0x0CF5, 4); // 4-byte pixel alignment
73 glGenTextures(1, &s_RenderTarget);
74
75 CreateShaders();
76 // TODO: Enable for GLES once RasterFont supports GLES
77#ifndef USE_GLES
78 s_pfont = new RasterFont();
79 glEnable(GL_TEXTURE_2D0x0DE1);
80#endif
81 GL_REPORT_ERRORD()(void)0;
82}
83
84void SWRenderer::RenderText(const char* pstr, int left, int top, u32 color)
85{
86#ifndef USE_GLES
87 int nBackbufferWidth = (int)GLInterface->GetBackBufferWidth();
88 int nBackbufferHeight = (int)GLInterface->GetBackBufferHeight();
89 glColor4f(((color>>16) & 0xff)/255.0f, ((color>> 8) & 0xff)/255.0f,
90 ((color>> 0) & 0xff)/255.0f, ((color>>24) & 0xFF)/255.0f);
91 s_pfont->printMultilineText(pstr,
92 left * 2.0f / (float)nBackbufferWidth - 1,
93 1 - top * 2.0f / (float)nBackbufferHeight,
94 0, nBackbufferWidth, nBackbufferHeight);
95#endif
96}
97
98void SWRenderer::DrawDebugText()
99{
100 char debugtext_buffer[8192];
101 char *p = debugtext_buffer;
102 p[0] = 0;
103
104 if (g_SWVideoConfig.bShowStats)
105 {
106 p+=sprintf(p,"Objects: %i\n",swstats.thisFrame.numDrawnObjects);
107 p+=sprintf(p,"Primitives: %i\n",swstats.thisFrame.numPrimatives);
108 p+=sprintf(p,"Vertices Loaded: %i\n",swstats.thisFrame.numVerticesLoaded);
109
110 p+=sprintf(p,"Triangles Input: %i\n",swstats.thisFrame.numTrianglesIn);
111 p+=sprintf(p,"Triangles Rejected: %i\n",swstats.thisFrame.numTrianglesRejected);
112 p+=sprintf(p,"Triangles Culled: %i\n",swstats.thisFrame.numTrianglesCulled);
113 p+=sprintf(p,"Triangles Clipped: %i\n",swstats.thisFrame.numTrianglesClipped);
114 p+=sprintf(p,"Triangles Drawn: %i\n",swstats.thisFrame.numTrianglesDrawn);
115
116 p+=sprintf(p,"Rasterized Pix: %i\n",swstats.thisFrame.rasterizedPixels);
117 p+=sprintf(p,"TEV Pix In: %i\n",swstats.thisFrame.tevPixelsIn);
118 p+=sprintf(p,"TEV Pix Out: %i\n",swstats.thisFrame.tevPixelsOut);
Value stored to 'p' is never read
119 }
120
121 // Render a shadow, and then the text.
122 SWRenderer::RenderText(debugtext_buffer, 21, 21, 0xDD000000);
123 SWRenderer::RenderText(debugtext_buffer, 20, 20, 0xFFFFFF00);
124}
125
126void SWRenderer::DrawTexture(u8 *texture, int width, int height)
127{
128 GLsizei glWidth = (GLsizei)GLInterface->GetBackBufferWidth();
129 GLsizei glHeight = (GLsizei)GLInterface->GetBackBufferHeight();
130
131 // Update GLViewPort
132 glViewport(0, 0, glWidth, glHeight);
133 glScissor(0, 0, glWidth, glHeight);
134
135 glBindTexture(GL_TEXTURE_2D0x0DE1, s_RenderTarget);
136
137 glTexImage2D(GL_TEXTURE_2D0x0DE1, 0, GL_RGBA0x1908, (GLsizei)width, (GLsizei)height, 0, GL_RGBA0x1908, GL_UNSIGNED_BYTE0x1401, texture);
138 glTexParameteri(GL_TEXTURE_2D0x0DE1, GL_TEXTURE_MAG_FILTER0x2800, GL_NEAREST0x2600);
139 glTexParameteri(GL_TEXTURE_2D0x0DE1, GL_TEXTURE_MIN_FILTER0x2801, GL_NEAREST0x2600);
140
141 glUseProgram__glewUseProgram(program);
142 static const GLfloat verts[4][2] = {
143 { -1, -1}, // Left top
144 { -1, 1}, // left bottom
145 { 1, 1}, // right bottom
146 { 1, -1} // right top
147 };
148 static const GLfloat texverts[4][2] = {
149 {0, 1},
150 {0, 0},
151 {1, 0},
152 {1, 1}
153 };
154
155 glVertexAttribPointer__glewVertexAttribPointer(attr_pos, 2, GL_FLOAT0x1406, GL_FALSE0, 0, verts);
156 glVertexAttribPointer__glewVertexAttribPointer(attr_tex, 2, GL_FLOAT0x1406, GL_FALSE0, 0, texverts);
157 glEnableVertexAttribArray__glewEnableVertexAttribArray(attr_pos);
158 glEnableVertexAttribArray__glewEnableVertexAttribArray(attr_tex);
159 glUniform1i__glewUniform1i(uni_tex, 0);
160 glActiveTexture__glewActiveTexture(GL_TEXTURE00x84C0);
161 glDrawArrays(GL_TRIANGLE_FAN0x0006, 0, 4);
162 glDisableVertexAttribArray__glewDisableVertexAttribArray(attr_pos);
163 glDisableVertexAttribArray__glewDisableVertexAttribArray(attr_tex);
164
165 glBindTexture(GL_TEXTURE_2D0x0DE1, 0);
166 GL_REPORT_ERRORD()(void)0;
167}
168
169void SWRenderer::SwapBuffer()
170{
171 // Do our OSD callbacks
172 OSD::DoCallbacks(OSD::OSD_ONFRAME);
173
174 DrawDebugText();
175
176 glFlush();
177
178 GLInterface->Swap();
179
180 swstats.ResetFrame();
181
182 glClear(GL_COLOR_BUFFER_BIT0x00004000 | GL_DEPTH_BUFFER_BIT0x00000100);
183
184 GL_REPORT_ERRORD()(void)0;
185}