- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
<分区>
我已经创建了这 3 个子窗口,但现在我想在其中一个(第一个)中绘制一个矩形。我没有错误,但它没有显示任何内容(只有 3 个空的子窗口)...
这是C语言的代码:
#include "glut.h"
#include <stdio.h>
// ***** Main Window *****//
#define GAP 10 // gap between subwindows
// define the window position on screen
float main_window_x;
float main_window_y;
// variables representing the window size
float main_window_w = 256 + GAP * 2;
float main_window_h = 256 + 64 + GAP * 3;
// variable representing the window title
char *window_title = "SubWindow Template";
// Represents the window id
int main_window;
// ***** Sub Window 1 *****//
// define the window position on screen
float subwindow1_x = GAP;
float subwindow1_y = GAP;
// variables representing the window size
float subwindow1_w = 256;
float subwindow1_h = 220;
// Represents the subwindow id
int subwindow_1;
// ***** Sub Window 2 *****//
// define the window position on screen
float subwindow2_x = GAP;
float subwindow2_y = GAP + 220 + GAP;
// variables representing the window size
float subwindow2_w = 123;
float subwindow2_h = 100;
// Represents the subwindow id
int subwindow_2;
// ***** Sub Window 3 *****//
// define the window position on screen
float subwindow3_x = GAP + 123 + GAP;
float subwindow3_y = GAP + 220 + GAP;
// variables representing the window size
float subwindow3_w = 123;
float subwindow3_h = 100;
// Represents the subwindow id
int subwindow_3;
void main_display(void)
{
// Set background color to black
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
// Swap front and back buffers
glutSwapBuffers();
}
void subwindow1_display(void)
{
// Set background color to white
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
// Set drawing color to gray
glColor3f(0.75, 0.75, 0.75);
glBegin(GL_QUADS);
glVertex2i(GAP + 20, GAP + 10);
glVertex2i(GAP + 40, GAP + 10);
glVertex2i(GAP + 40, GAP + 30);
glVertex2i(GAP + 20, GAP + 30);
glEnd();
glFlush();
// Swap front and back buffers
glutSwapBuffers();
}
void subwindow2_display(void)
{
// Set background color to white
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
// Set drawing color to blue
glColor3f(0, 0, 1);
// Swap front and back buffers
glutSwapBuffers();
}
void subwindow3_display(void)
{
// Set background color to white
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
// Set drawing color to blue
glColor3f(0, 0, 1);
// Swap front and back buffers
glutSwapBuffers();
}
// ***** General *****//
// Tells whether to display the window full screen or not
int full_screen = 0;
void main_reshape(int width, int height)
{
// Just take the case when the user tries
// to make the size of the window very small...
if (width < GAP * 4 || height < GAP * 6)
{
glutSetWindow(main_window);
glutReshapeWindow(main_window_w, main_window_h);
return;
}
// Change the subwindow 1 dimensions as window dimensions change
// main_window_w ---> subwindow1_w
// main_window_w' (width) ---> ??
// ==>
subwindow1_w = (subwindow1_w * (width - GAP * 2.0)) / (main_window_w - GAP * 2.0);
subwindow1_h = (subwindow1_h * (height - GAP * 3.0)) / (main_window_h - GAP * 3.0);
// Set subwindow 1 as current window and then reposition and resize it
glutSetWindow(subwindow_1);
glutPositionWindow(GAP, GAP);
glutReshapeWindow(subwindow1_w, subwindow1_h);
// Change the subwindow 2 dimensions as window dimensions change
subwindow2_w = (subwindow2_w * (width - GAP * 2.0)) / (main_window_w - GAP * 2.0);
subwindow2_h = (subwindow2_h * (height - GAP * 3.0)) / (main_window_h - GAP * 3.0);
// Set subwindow 2 as current window and then reposition and resize it
glutSetWindow(subwindow_2);
glutPositionWindow(GAP, GAP + subwindow1_h + GAP);
glutReshapeWindow(subwindow2_w, subwindow2_h);
// Change the subwindow 3 dimensions as window dimensions change
subwindow3_w = (subwindow3_w * (width - GAP * 2.0)) / (main_window_w - GAP * 2.0);
subwindow3_h = (subwindow3_h * (height - GAP * 3.0)) / (main_window_h - GAP * 3.0);
// Set subwindow 3 as current window and then reposition and resize it
glutSetWindow(subwindow_3);
glutPositionWindow(GAP * 2 + 123, GAP + subwindow1_h + GAP);
glutReshapeWindow(subwindow3_w, subwindow3_h);
// Stay updated with the window width and height
main_window_w = width;
main_window_h = height;
}
//-------------------------------------------------------------------------
// SubWindow 1 Reshape Function.
//
// Preserve aspect ratio of viewport when subwindow is resized.
//-------------------------------------------------------------------------
void subwindow1_reshape(int width, int height)
{
// Represents a side of the viewport. A viewport is intended to
// to take a square shape so that the aspect ratio is reserved
int viewport_side = 0;
// Viewport x and y positions (Center viewport)
int viewport_x = 0, viewport_y = 0;
// Calculate viewport side
viewport_side = (width > height) ? height : width;
// Calculate viewport position
viewport_x = (width - viewport_side) / 2;
viewport_y = (height - viewport_side) / 2;
// Preserve aspect ratio
glViewport(viewport_x, viewport_y, viewport_side, viewport_side);
// Set subwindow width and height
subwindow1_w = width;
subwindow1_h = height;
}
//-------------------------------------------------------------------------
// SubWindow 2 Reshape Function.
//
// Preserve aspect ratio of viewport when subwindow is resized.
//-------------------------------------------------------------------------
void subwindow2_reshape(int width, int height)
{
// Represents a side of the viewport. A viewport is intended to
// to take a square shape so that the aspect ratio is reserved
int viewport_side = 0;
// Viewport x and y positions (Center viewport)
int viewport_x = 0, viewport_y = 0;
// Calculate viewport side
viewport_side = (width > height) ? height : width;
// Calculate viewport position
viewport_x = (width - viewport_side) / 2;
viewport_y = (height - viewport_side) / 2;
// Preserve aspect ratio
glViewport(viewport_x, viewport_y, viewport_side, viewport_side);
// Set subwindow width and height
subwindow2_w = width;
subwindow2_h = height;
}
//-------------------------------------------------------------------------
// SubWindow 3 Reshape Function.
//
// Preserve aspect ratio of viewport when subwindow is resized.
//-------------------------------------------------------------------------
void subwindow3_reshape(int width, int height)
{
// Represents a side of the viewport. A viewport is intended to
// to take a square shape so that the aspect ratio is reserved
int viewport_side = 0;
// Viewport x and y positions (Center viewport)
int viewport_x = 0, viewport_y = 0;
// Calculate viewport side
viewport_side = (width > height) ? height : width;
// Calculate viewport position
viewport_x = (width - viewport_side) / 2;
viewport_y = (height - viewport_side) / 2;
// Preserve aspect ratio
glViewport(viewport_x, viewport_y, viewport_side, viewport_side);
// Set subwindow width and height
subwindow3_w = width;
subwindow3_h = height;
}
//-------------------------------------------------------------------------
// Redisplay contents of subwindow 1 and subwindow 2 and subwindow3.
//-------------------------------------------------------------------------
void redisplay_all(void)
{
glutSetWindow(subwindow_1);
glutPostRedisplay();
glutSetWindow(subwindow_2);
glutPostRedisplay();
glutSetWindow(subwindow_3);
glutPostRedisplay();
}
//-------------------------------------------------------------------------
// This function sets the window x and y coordinates
// such that the window becomes centered
//-------------------------------------------------------------------------
void centerOnScreen()
{
main_window_x = (glutGet(GLUT_SCREEN_WIDTH) - main_window_w) / 2;
main_window_y = (glutGet(GLUT_SCREEN_HEIGHT) - main_window_h) / 2;
}
//-------------------------------------------------------------------------
// Program Main method.
//-------------------------------------------------------------------------
int main(int argc, char **argv)
{
/**** Main Window **** */
glutInit(&argc, argv);
// Set the main window x and y coordinates such that the
// window becomes centered
centerOnScreen();
glutInitWindowSize(main_window_w, main_window_h);
glutInitWindowPosition(main_window_x, main_window_y);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
main_window = glutCreateWindow(window_title);
glutDisplayFunc(main_display);
glutReshapeFunc(main_reshape);
/**** Subwindow 1 **** */
subwindow_1 = glutCreateSubWindow(main_window, subwindow1_x, subwindow1_y, subwindow1_w, subwindow1_h);
glutDisplayFunc(subwindow1_display);
glutReshapeFunc(subwindow1_reshape);
/**** Subwindow 2 **** */
subwindow_2 = glutCreateSubWindow(main_window, subwindow2_x, subwindow2_y, subwindow2_w, subwindow2_h);
glutDisplayFunc(subwindow2_display);
glutReshapeFunc(subwindow2_reshape);
/**** Subwindow 3 **** */
subwindow_3 = glutCreateSubWindow(main_window, subwindow3_x, subwindow3_y, subwindow3_w, subwindow3_h);
glutDisplayFunc(subwindow3_display);
glutReshapeFunc(subwindow3_reshape);
// View in full screen if the full_screen flag is on
if (full_screen)
glutFullScreen();
// Start GLUT event processing loop
glutMainLoop();
return 0;
}
Draw joust是什么游戏 Draw joust是一款voodoo推出的玩家对战类游戏,Draw joust游戏中文版叫做手绘战车游戏。 这次voodoo将该游戏的玩法再度升级,难度也有所提
我在本地托管了 draw.io,我们正在使用它来直观地表示仓库中托盘的位置。问题在于,当你在周围拖动托盘时,你经常会不小心调整它们的大小,这很痛苦。无论如何我可以禁用它或锁定托盘的大小吗? 最佳答案
我想在 draw.io 中格式化一个矩形,这样只有一个边框(左边框)是黑色的,其他边框:顶部、右侧和底部必须保持“清晰”。 我试图找出正确的编码来仅影响这些元素,但似乎您只能使用样式键影响整个边框:i
我的线正在连接,即使我没有将它们设置为多边形。 我的脚本基于 pyshp 包。 我的脚本如下所示: w=Shapefile.Writer() #shapetype 11 is a polylineZ
我在表单值中有一个标题(“cadeau check 50 €”),我想使用 arial.ttf 将其写入背景图像。我的文字是正确的,但对于欧元符号。我有 2 [] 到位。我不知道问题出在哪里。这是 P
我收到上述错误。我需要帮助修复它。我看过this question它似乎对我没有任何帮助,我在与需要它的指令相同的元素上拥有所需的指令。我也不明白为什么我的错误说无法找到指令“绘图”所需的 Contr
我正在使用 VBUC 将 VB6 应用程序迁移到 C#但我得到了这个错误: 无法将类型“System.Drawing.Image”转换为“System.Drawing.Icon”我的代码是:
我有一行代码是从某个地方借来的,Visual Studio 无法解决 Bitmap或 ImageConverter类引用。 我有: using System.Drawing; 代码行是 Image x
我正在尝试将花费很长时间的大型 Lucidchart 图转换为 Draw.io。 Draw.io 推荐 ctr-a、ctr-c、ctr-v,但这似乎不起作用。然而,Draw.io 也隐晦地提到: dr
我想显示一个相对较长的图表。我曾经使用过 javafx Canvas ,但有时会出现缓冲区溢出异常,因为绘制了很多值。我正在寻找一种不同的方法,并找到了一种使用 java.awt.graphics2d
我很困惑 System.Drawing.Image 和 System.Drawing.Bitmap 之间有什么不同 有人可以解释这两种类型之间的主要区别吗? 为什么要使用 System.Drawing
声明了一个位图 private Bitmap img1 = null; private Bitmap img2 = null; 从openFileDialog中选择图像后,图像将被放置。 选定的图
我想遍历 System.Drawing.Color 结构并使用它来初始化笔列表。 我是这样试的,但是字段类型不合适: colorList = new List(); foreach (
System.Drawing.Point 和 System.Drawing.PointF 有什么区别。你能举个这两者之间的例子吗? 提前致谢。 最佳答案 Point 使用整数坐标(int 代表 X 和
我正在为我们公司开发 WinForm 打印应用程序。 打印文档时,我需要获取文档上每个控件的System.Drawing.Color属性,并创建一个System.Drawing.Brush对象来画出来
我正在使用这个从另一个应用程序获取图标: Icon IEIcon = Icon.ExtractAssociatedIcon(@"C:\Program Files\Internet Explorer\
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
在 UIView 子类中,我覆盖了 Draw 子类以绘制一些自定义文本,但文本始终绘制为翻转文本。 这是我正在使用的代码: class TextViewProblem : UIView { publi
我想从 Zotero 导出的嵌套 XML/JSON(嵌套在子集合和集合中的单个项目)以编程方式生成 draw.io map 图。 我已经有了基本的 JSON/XML,可以适应 draw.io 的格式,
1) 重新绘制与绘制 这是一个哲学问题,但是...在不同分辨率下渲染游戏的“正确”或“可接受”的方式是什么(2d,我理解 OGL 视角如何工作...)?我应该为我的图像(如 Android APK)添
我是一名优秀的程序员,十分优秀!