本文整理汇总了C++中R_Color函数的典型用法代码示例。如果您正苦于以下问题:C++ R_Color函数的具体用法?C++ R_Color怎么用?C++ R_Color使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了R_Color函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UI_DrawTooltip
/**
* @brief Generic tooltip function
*/
int UI_DrawTooltip (const char* string, int x, int y, int maxWidth)
{
const char* font = "f_small";
int height = 0, width = 0;
if (Q_strnull(string) || !font)
return 0;
R_FontTextSize(font, string, maxWidth, LONGLINES_WRAP, &width, &height, nullptr, nullptr);
if (!width)
return 0;
x += 5;
y += 5;
if (x + width + 3 > VID_NORM_WIDTH)
x -= width + 10;
if (y + height + 3 > VID_NORM_HEIGHT)
y -= height + 10;
UI_DrawFill(x - 1, y - 1, width + 4, height + 4, tooltipBG);
R_Color(tooltipColor);
UI_DrawString(font, ALIGN_UL, x + 1, y + 1, x + 1, maxWidth, 0, string);
R_Color(nullptr);
return width;
}
示例2: R_DrawFloor
/**
* @brief Draws a marker on the ground to indicate pathing CL_AddPathingBox
* @sa CL_AddPathing
* @sa RF_BOX
*/
static void R_DrawFloor (const entity_t * e)
{
image_t *cellIndicator = R_FindImage("pics/sfx/cell", it_pic);
const float dx = PLAYER_WIDTH * 2;
const vec4_t color = {e->color[0], e->color[1], e->color[2], e->alpha};
const float size = 4.0;
/** @todo use default_texcoords */
const vec2_t texcoords[] = { { 0.0, 1.0 }, { 1.0, 1.0 }, { 1.0, 0.0 }, { 0.0, 0.0 } };
const vec3_t points[] = { { e->origin[0] - size, e->origin[1] + dx + size, e->origin[2] }, { e->origin[0] + dx
+ size, e->origin[1] + dx + size, e->origin[2] }, { e->origin[0] + dx + size, e->origin[1] - size,
e->origin[2] }, { e->origin[0] - size, e->origin[1] - size, e->origin[2] } };
glDisable(GL_DEPTH_TEST);
R_Color(color);
R_BindTexture(cellIndicator->texnum);
/* circle points */
R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, texcoords);
R_BindArray(GL_VERTEX_ARRAY, GL_FLOAT, points);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
R_BindDefaultArray(GL_TEXTURE_COORD_ARRAY);
R_BindDefaultArray(GL_VERTEX_ARRAY);
refdef.batchCount++;
glEnable(GL_DEPTH_TEST);
R_Color(NULL);
}
示例3: R_DrawCircle
void R_DrawCircle (float radius, const vec4_t color, float thickness, const vec3_t shift)
{
vec3_t points[16];
const size_t steps = lengthof(points);
unsigned int i;
glEnable(GL_LINE_SMOOTH);
glLineWidth(thickness);
R_Color(color);
for (i = 0; i < steps; i++) {
const float a = 2.0f * M_PI * (float) i / (float) steps;
VectorSet(points[i], shift[0] + radius * cos(a), shift[1] + radius * sin(a), shift[2]);
}
R_BindArray(GL_VERTEX_ARRAY, GL_FLOAT, points);
glDrawArrays(GL_LINE_LOOP, 0, steps);
R_BindDefaultArray(GL_VERTEX_ARRAY);
refdef.batchCount++;
R_Color(NULL);
glLineWidth(1.0f);
glDisable(GL_LINE_SMOOTH);
}
示例4: R_DrawRect
/**
* @brief Draws a rect to the screen. Also has support for stippled rendering of the rect.
*
* @param[in] x X-position of the rect
* @param[in] y Y-position of the rect
* @param[in] w Width of the rect
* @param[in] h Height of the rect
* @param[in] color RGBA color of the rect
* @param[in] lineWidth Line strength in pixel of the rect
* @param[in] pattern Specifies a 16-bit integer whose bit pattern determines
* which fragments of a line will be drawn when the line is rasterized.
* Bit zero is used first; the default pattern is all 1's
* @note The stipple factor is @c 2 for this function
*/
void R_DrawRect (int x, int y, int w, int h, const vec4_t color, float lineWidth, int pattern)
{
const float nx = x * viddef.rx;
const float ny = y * viddef.ry;
const float nw = w * viddef.rx;
const float nh = h * viddef.ry;
const vec2_t points[] = { { nx, ny }, { nx + nw, ny }, { nx + nw, ny + nh }, { nx, ny + nh } };
R_Color(color);
glDisable(GL_TEXTURE_2D);
glLineWidth(lineWidth);
#ifndef HAVE_GLES
glLineStipple(2, pattern);
glEnable(GL_LINE_STIPPLE);
#endif
glVertexPointer(2, GL_FLOAT, 0, points);
glDrawArrays(GL_LINE_LOOP, 0, 4);
R_BindDefaultArray(GL_VERTEX_ARRAY);
refdef.batchCount++;
glEnable(GL_TEXTURE_2D);
glLineWidth(1.0f);
#ifndef HAVE_GLES
glDisable(GL_LINE_STIPPLE);
#endif
R_Color(NULL);
}
示例5: R_DrawArrow
/**
* @brief Draws an arrow between two points
* @sa CL_AddArrow
* @sa RF_BOX
*/
static void R_DrawArrow (const entity_t* e)
{
const vec3_t upper = { e->origin[0] + 2, e->origin[1], e->origin[2] };
const vec3_t mid = { e->origin[0], e->origin[1] + 2, e->origin[2] };
const vec3_t lower = { e->origin[0], e->origin[1], e->origin[2] + 2 };
const vec4_t color = { e->color[0], e->color[1], e->color[2], e->alpha };
const vec3_t points[] = { { e->oldorigin[0], e->oldorigin[1], e->oldorigin[2] }, { upper[0], upper[1], upper[2] },
{ mid[0], mid[1], mid[2] }, { lower[0], lower[1], lower[2] } };
R_Color(color);
glDisable(GL_TEXTURE_2D);
glEnable(GL_LINE_SMOOTH);
R_BindArray(GL_VERTEX_ARRAY, GL_FLOAT, points);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
R_BindDefaultArray(GL_VERTEX_ARRAY);
refdef.batchCount++;
glDisable(GL_LINE_SMOOTH);
glEnable(GL_TEXTURE_2D);
R_Color(nullptr);
}
示例6: UI_GetFontFromNode
void uiTextEntryNode::draw (uiNode_t* node)
{
const float* textColor;
vec2_t pos;
const char* font = UI_GetFontFromNode(node);
uiSpriteStatus_t iconStatus = SPRITE_STATUS_NORMAL;
if (node->disabled) {
textColor = node->disabledColor;
iconStatus = SPRITE_STATUS_DISABLED;
} else if (node->state) {
textColor = node->color;
iconStatus = SPRITE_STATUS_HOVER;
} else {
textColor = node->color;
}
if (UI_HasFocus(node)) {
textColor = node->selectedColor;
}
UI_GetNodeAbsPos(node, pos);
if (EXTRADATA(node).background) {
UI_DrawSpriteInBox(false, EXTRADATA(node).background, iconStatus, pos[0], pos[1], node->box.size[0], node->box.size[1]);
}
if (char const* const text = UI_GetReferenceString(node, node->text)) {
char buf[MAX_VAR];
if (EXTRADATA(node).isPassword) {
size_t size = UTF8_strlen(text);
if (size > MAX_VAR - 2)
size = MAX_VAR - 2;
memset(buf, HIDECHAR, size);
buf[size] = '\0';
} else {
/* leave one byte empty for the text-based cursor */
UTF8_strncpyz(buf, text, sizeof(buf) - 1);
}
/** @todo Make the cursor into a real graphical object instead of using a text character. */
if (UI_HasFocus(node)) {
if (CL_Milliseconds() % 1000 < 500) {
UTF8_insert_char_at(buf, sizeof(buf), EXTRADATA(node).cursorPosition, (int)CURSOR_ON);
} else {
UTF8_insert_char_at(buf, sizeof(buf), EXTRADATA(node).cursorPosition, (int)CURSOR_OFF);
}
}
if (*buf != '\0') {
R_Color(textColor);
UI_DrawStringInBox(font, (align_t)node->contentAlign,
pos[0] + node->padding, pos[1] + node->padding,
node->box.size[0] - node->padding - node->padding, node->box.size[1] - node->padding - node->padding,
buf);
R_Color(nullptr);
}
}
}
示例7: R_DrawBspNormals
/**
* @brief Developer tool for viewing BSP vertex normals. Only Phong interpolated
* surfaces show their normals when r_shownormals > 1.
*/
void R_DrawBspNormals (int tile)
{
int i, j, k;
const mBspSurface_t* surf;
const mBspModel_t* bsp;
const vec4_t color = {1.0, 0.0, 0.0, 1.0};
if (!r_shownormals->integer)
return;
R_EnableTexture(&texunit_diffuse, false);
R_ResetArrayState(); /* default arrays */
R_Color(color);
k = 0;
bsp = &r_mapTiles[tile]->bsp;
surf = bsp->surfaces;
for (i = 0; i < bsp->numsurfaces; i++, surf++) {
if (surf->frame != r_locals.frame)
continue; /* not visible */
if (surf->texinfo->flags & SURF_WARP)
continue; /* don't care */
if (r_shownormals->integer > 1 && !(surf->texinfo->flags & SURF_PHONG))
continue; /* don't care */
/* avoid overflows, draw in batches */
if (k > r_state.array_size - 512) {
glDrawArrays(GL_LINES, 0, k / 3);
k = 0;
refdef.batchCount++;
}
for (j = 0; j < surf->numedges; j++) {
vec3_t end;
const GLfloat* vertex = &bsp->verts[(surf->index + j) * 3];
const GLfloat* normal = &bsp->normals[(surf->index + j) * 3];
VectorMA(vertex, 12.0, normal, end);
memcpy(&r_state.vertex_array_3d[k], vertex, sizeof(vec3_t));
memcpy(&r_state.vertex_array_3d[k + 3], end, sizeof(vec3_t));
k += sizeof(vec3_t) / sizeof(vec_t) * 2;
R_ReallocateStateArrays(k);
}
}
glDrawArrays(GL_LINES, 0, k / 3);
refdef.batchCount++;
R_EnableTexture(&texunit_diffuse, true);
R_Color(nullptr);
}
示例8: UI_AbstractOptionGetCurrentValue
void uiSelectBoxNode::draw (uiNode_t* node)
{
uiNode_t* option;
int selBoxX, selBoxY;
const char* ref;
const char* font;
vec2_t nodepos;
const char* imageName;
const image_t* image;
static vec4_t invisColor = {1.0, 1.0, 1.0, 0.7};
ref = UI_AbstractOptionGetCurrentValue(node);
if (ref == nullptr)
return;
UI_GetNodeAbsPos(node, nodepos);
imageName = UI_GetReferenceString(node, node->image);
if (!imageName)
imageName = "ui/selectbox";
image = UI_LoadImage(imageName);
font = UI_GetFontFromNode(node);
selBoxX = nodepos[0] + SELECTBOX_SIDE_WIDTH;
selBoxY = nodepos[1] + SELECTBOX_SPACER;
/* left border */
UI_DrawNormImage(false, nodepos[0], nodepos[1], SELECTBOX_SIDE_WIDTH, node->box.size[1],
SELECTBOX_SIDE_WIDTH, SELECTBOX_DEFAULT_HEIGHT, 0.0f, 0.0f, image);
/* stretched middle bar */
UI_DrawNormImage(false, nodepos[0] + SELECTBOX_SIDE_WIDTH, nodepos[1], node->box.size[0]-SELECTBOX_SIDE_WIDTH-SELECTBOX_RIGHT_WIDTH, node->box.size[1],
12.0f, SELECTBOX_DEFAULT_HEIGHT, 7.0f, 0.0f, image);
/* right border (arrow) */
UI_DrawNormImage(false, nodepos[0] + node->box.size[0] - SELECTBOX_RIGHT_WIDTH, nodepos[1], SELECTBOX_DEFAULT_HEIGHT, node->box.size[1],
12.0f + SELECTBOX_RIGHT_WIDTH, SELECTBOX_DEFAULT_HEIGHT, 12.0f, 0.0f, image);
/* draw the label for the current selected option */
for (option = UI_AbstractOptionGetFirstOption(node); option; option = option->next) {
if (!Q_streq(OPTIONEXTRADATA(option).value, ref))
continue;
if (option->invis)
R_Color(invisColor);
const char* label = CL_Translate(OPTIONEXTRADATA(option).label);
UI_DrawString(font, ALIGN_UL, selBoxX, selBoxY,
selBoxX, node->box.size[0] - 4,
0, label, 0, 0, nullptr, false, LONGLINES_PRETTYCHOP);
R_Color(nullptr);
break;
}
/* must we draw the drop-down list */
if (UI_GetMouseCapture() == node) {
UI_CaptureDrawOver(node);
}
}
示例9: R_DrawBox
/**
* @brief Draws the field marker entity is specified in CL_AddTargeting
* @sa CL_AddTargeting
* @sa RF_BOX
*/
static void R_DrawBox (const entity_t* e)
{
const vec4_t color = {e->color[0], e->color[1], e->color[2], e->alpha};
if (e->texture) {
R_Color(color);
R_BindTexture(e->texture->texnum);
if (VectorNotEmpty(e->eBox.mins) && VectorNotEmpty(e->eBox.maxs)) {
R_DrawTexturedBox(e->eBox.mins, e->eBox.maxs);
} else {
R_DrawTexturedBox(e->oldorigin, e->origin);
}
R_Color(nullptr);
return;
}
glDisable(GL_TEXTURE_2D);
R_Color(color);
if (VectorNotEmpty(e->eBox.mins) && VectorNotEmpty(e->eBox.maxs)) {
R_DrawBoundingBox(e->eBox);
} else {
vec3_t points[] = { { e->oldorigin[0], e->oldorigin[1], e->oldorigin[2] }, { e->oldorigin[0], e->origin[1],
e->oldorigin[2] }, { e->origin[0], e->origin[1], e->oldorigin[2] }, { e->origin[0], e->oldorigin[1],
e->oldorigin[2] } };
glLineWidth(2.0f);
R_BindArray(GL_VERTEX_ARRAY, GL_FLOAT, points);
/** @todo fill one array */
glDrawArrays(GL_LINE_LOOP, 0, 4);
refdef.batchCount++;
points[0][2] = e->origin[2];
points[1][2] = e->origin[2];
points[2][2] = e->origin[2];
points[3][2] = e->origin[2];
glDrawArrays(GL_LINE_LOOP, 0, 4);
refdef.batchCount++;
points[0][2] = e->oldorigin[2];
points[1][1] = e->oldorigin[1];
points[2][2] = e->oldorigin[2];
points[3][1] = e->origin[1];
glDrawArrays(GL_LINES, 0, 4);
refdef.batchCount++;
points[0][0] = e->origin[0];
points[1][0] = e->origin[0];
points[2][0] = e->oldorigin[0];
points[3][0] = e->oldorigin[0];
glDrawArrays(GL_LINES, 0, 4);
refdef.batchCount++;
R_BindDefaultArray(GL_VERTEX_ARRAY);
}
glEnable(GL_TEXTURE_2D);
R_Color(nullptr);
}
示例10: UI_CustomButtonNodeDraw
/**
* @brief Handles CustomButton draw
*/
static void UI_CustomButtonNodeDraw (uiNode_t *node)
{
const char *text;
int texY;
const float *textColor;
const char *image;
vec2_t pos;
static vec4_t disabledColor = {0.5, 0.5, 0.5, 1.0};
uiSpriteStatus_t iconStatus = SPRITE_STATUS_NORMAL;
const char *font = UI_GetFontFromNode(node);
if (!node->onClick || node->disabled) {
/** @todo need custom color when button is disabled */
textColor = disabledColor;
texY = UI_CUSTOMBUTTON_TEX_HEIGHT * 2;
iconStatus = SPRITE_STATUS_DISABLED;
} else if (node->state) {
textColor = node->selectedColor;
texY = UI_CUSTOMBUTTON_TEX_HEIGHT;
iconStatus = SPRITE_STATUS_HOVER;
} else {
textColor = node->color;
texY = 0;
}
UI_GetNodeAbsPos(node, pos);
image = UI_GetReferenceString(node, node->image);
if (image) {
const int texX = rint(EXTRADATA(node).texl[0]);
texY += EXTRADATA(node).texl[1];
UI_DrawNormImageByName(qfalse, pos[0], pos[1], node->size[0], node->size[1],
texX + node->size[0], texY + node->size[1], texX, texY, image);
}
if (EXTRADATA(node).background) {
UI_DrawSpriteInBox(qfalse, EXTRADATA(node).background, iconStatus, pos[0], pos[1], node->size[0], node->size[1]);
}
if (EXTRADATA(node).super.icon) {
UI_DrawSpriteInBox(EXTRADATA(node).super.flipIcon, EXTRADATA(node).super.icon, iconStatus, pos[0], pos[1], node->size[0], node->size[1]);
}
text = UI_GetReferenceString(node, node->text);
if (text != NULL && *text != '\0') {
R_Color(textColor);
UI_DrawStringInBox(font, node->contentAlign,
pos[0] + node->padding, pos[1] + node->padding,
node->size[0] - node->padding - node->padding, node->size[1] - node->padding - node->padding,
text, LONGLINES_PRETTYCHOP);
R_Color(NULL);
}
}
示例11: R_DrawMeshShadow
/**
* @brief Re-draws the mesh using the stencil test. Meshes with stale lighting
* information, or with a lighting point above our view, are not drawn.
*/
static void R_DrawMeshShadow (entity_t *e, const mAliasMesh_t *mesh)
{
vec4_t color;
const bool oldBlend = r_state.blend_enabled;
const bool lighting = r_state.lighting_enabled;
r_program_t *program = r_state.active_program;
if (!r_stencilshadows->integer)
return;
if (!r_shadows->value)
return;
if (r_wire->integer)
return;
if (e->flags & RF_NO_SHADOW)
return;
if (e->flags & RF_TRANSLUCENT)
return;
if (!R_UpdateShadowOrigin(e))
return;
if (e->lighting->shadowOrigin[2] > refdef.viewOrigin[2])
return;
Vector4Set(color, 0.0, 0.0, 0.0, r_shadows->value * MESH_SHADOW_ALPHA);
R_Color(color);
R_EnableTexture(&texunit_diffuse, false);
R_EnableBlend(true);
R_RotateForMeshShadow(e);
R_EnableStencilTest(true);
if (lighting)
R_EnableLighting(NULL, false);
glDrawArrays(GL_TRIANGLES, 0, mesh->num_tris * 3);
refdef.batchCount++;
if (lighting)
R_EnableLighting(program, true);
R_EnableStencilTest(false);
R_RotateForMeshShadow(NULL);
R_EnableBlend(oldBlend);
R_EnableTexture(&texunit_diffuse, true);
R_Color(NULL);
}
示例12: R_DrawBoundingBoxes
void R_DrawBoundingBoxes (void)
{
int i;
const int step = 3 * 8;
const int bboxes = r_bbox_array.bboxes_index / step;
const glIndex indexes[] = { 2, 1, 0, 1, 4, 5, 1, 7, 3, 2, 7, 6, 2, 4, 0 };
const glIndex indexes2[] = { 4, 6, 7 };
if (!r_bbox_array.bboxes_index)
return;
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
R_Color(NULL);
for (i = 0; i < bboxes; i++) {
const float *bbox = &r_bbox_array.bboxes[i * step];
R_BindArray(GL_VERTEX_ARRAY, GL_FLOAT, bbox);
/* Draw top and sides */
glDrawElements(GL_TRIANGLE_FAN, 15, GLINDEX, indexes);
/* Draw bottom */
glDrawElements(GL_TRIANGLE_FAN, 3, GLINDEX, indexes2);
}
R_BindDefaultArray(GL_VERTEX_ARRAY);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
r_bbox_array.bboxes_index = 0;
}
示例13: R_SetSurfaceState
/**
* @brief Set the surface state according to surface flags and bind the texture
* @sa R_DrawSurfaces
*/
static void R_SetSurfaceState (const mBspSurface_t *surf)
{
image_t *image;
if (r_state.blend_enabled) { /* alpha blend */
vec4_t color = {1.0, 1.0, 1.0, 1.0};
switch (surf->texinfo->flags & (SURF_BLEND33 | SURF_BLEND66)) {
case SURF_BLEND33:
color[3] = 0.33;
break;
case SURF_BLEND66:
color[3] = 0.66;
break;
}
R_Color(color);
}
image = surf->texinfo->image;
R_BindTexture(image->texnum); /* texture */
if (texunit_lightmap.enabled) { /* lightmap */
if (surf->flags & MSURF_LIGHTMAP)
R_BindLightmapTexture(surf->lightmap_texnum);
}
R_SetSurfaceBumpMappingParameters(surf, image->normalmap, image->specularmap);
R_EnableGlowMap(image->glowmap);
R_CheckError();
}
示例14: R_DrawFills
void R_DrawFills (void)
{
if (!r_fill_arrays.vert_index)
return;
R_EnableTexture(&texunit_diffuse, false);
R_EnableColorArray(true);
/* alter the array pointers */
R_BindArray(GL_COLOR_ARRAY, GL_UNSIGNED_BYTE, r_fill_arrays.colors);
glVertexPointer(2, GL_SHORT, 0, r_fill_arrays.verts);
glDrawArrays(GL_QUADS, 0, r_fill_arrays.vert_index / 2);
refdef.batchCount++;
/* and restore them */
R_BindDefaultArray(GL_VERTEX_ARRAY);
R_BindDefaultArray(GL_COLOR_ARRAY);
R_EnableColorArray(false);
R_EnableTexture(&texunit_diffuse, true);
r_fill_arrays.vert_index = r_fill_arrays.color_index = 0;
R_Color(NULL);
}
示例15: R_SetMeshShellColor_default
/**
* @brief Sets the active shell color for the given entity.
*/
static void R_SetMeshShellColor_default(const r_entity_t *e) {
vec4_t color = { 0.0, 0.0, 0.0, 1.0 };
VectorCopy(e->shell, color);
R_Color(color);
}